My simple test exampe app can not show video

VLC for Android and Chrome OS specific usage questions
dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

My simple test exampe app can not show video

Postby dfdf » 12 Jun 2014 20:25

Hi Ed,

I write a simple exampe app for testing vlc,but can only hear the sound,my code looks like this:

Code: Select all

public class MainActivity extends ActionBarActivity implements IVideoPlayer{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.player); setVolumeControlStream(AudioManager.STREAM_MUSIC); v=getLibVlcInstance(ctxt); attachsurface(); v.eventVideoPlayerActivityCreated(true); loadMedia(); } void attachsurface(){ mSurface = (SurfaceView)findViewById(R.id.player_surface); mSurfaceHolder = mSurface.getHolder(); String chroma = set().getString("chroma_format", ""); if (LibVlcUtil.isGingerbreadOrLater() && chroma.equals("YV12")) { mSurfaceHolder.setFormat(ImageFormat.YV12); } else if (chroma.equals("RV16")) { mSurfaceHolder.setFormat(PixelFormat.RGB_565); } else { mSurfaceHolder.setFormat(PixelFormat.RGBX_8888); } mSurfaceHolder.addCallback(mSurfaceCallback); }
what's wrong with me? Thanks for your help!

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: My simple test exampe app can not show video

Postby edwardw » 14 Jun 2014 17:32

You need to wait for surfaceChanged() then call libVLC.attachSurface().

dfdf
Blank Cone
Blank Cone
Posts: 39
Joined: 22 Dec 2013 23:54

Re: My simple test exampe app can not show video

Postby dfdf » 16 Jun 2014 19:02

I have already used surfaceChanged(),in my surfaceChanged(),I run mSurfaceHolder.addCallback(mSurfaceCallback),the callback like this:

Code: Select all

private final Callback mSurfaceCallback = new Callback() { @Override public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) { String chroma = set().getString("chroma_format", ""); if (LibVlcUtil.isGingerbreadOrLater() && chroma.equals("YV12")) { mSurfaceHolder.setFormat(ImageFormat.YV12); } else if (chroma.equals("RV16")) { mSurfaceHolder.setFormat(PixelFormat.RGB_565); } else { mSurfaceHolder.setFormat(PixelFormat.RGBX_8888); } v.attachSurface(holder.getSurface(),MainActivity.this); } @Override public void surfaceCreated(SurfaceHolder holder) { } @Override public void surfaceDestroyed(SurfaceHolder holder) { v.detachSurface(); } };

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: My simple test exampe app can not show video

Postby edwardw » 16 Jun 2014 21:33

It seems that you are missing code or you are not presenting the whole.


Return to “VLC for Android and Chrome OS”

Who is online

Users browsing this forum: No registered users and 4 guests