Forked from kswlee/android mediaplayer use textureview
Created
August 4, 2014 14:43
-
-
Save XinyueZ/b689a637909f95792e50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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