Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.