Page 1 of 1

My simple test exampe app can not show video

Posted: 12 Jun 2014 20:25
by dfdf
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!

Re: My simple test exampe app can not show video

Posted: 14 Jun 2014 17:32
by edwardw
You need to wait for surfaceChanged() then call libVLC.attachSurface().

Re: My simple test exampe app can not show video

Posted: 16 Jun 2014 19:02
by dfdf
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(); } };

Re: My simple test exampe app can not show video

Posted: 16 Jun 2014 21:33
by edwardw
It seems that you are missing code or you are not presenting the whole.