Skip to content

Instantly share code, notes, and snippets.

@kswlee
Created May 22, 2013 13:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kswlee/5627632 to your computer and use it in GitHub Desktop.
Save kswlee/5627632 to your computer and use it in GitHub Desktop.
public VideoFrameExtractor(Context context, String path, TextureView textureView) {
mVideoPath = path;
mTextureView = textureView;
textureView.setSurfaceTextureListener(this);
textureView.setTranslationX(-1920);
if (textureView.isAvailable()) {
initPlayer(textureView.getSurfaceTexture());
}
}
private void initPlayer(SurfaceTexture surfaceTexture) {
mPlayer = new MediaPlayer();
Surface surface = new Surface(surfaceTexture);
try {
mPlayer.setDataSource(mVideoPath);
mPlayer.setSurface(surface);
mPlayer.prepare();
extractFrames();
//mPlayer.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment