我想从长视频中剪辑2到3分钟。到目前为止,我只能使用videoView
播放长视频。
// Set the media controller buttons
if(mediaController ==null){
mediaController = new MediaController(VideoActivity.this);
// Set the videoView that acts as the anchor for the MediaController.
mediaController.setAnchorView(mVideoView);
// Set MediaController for VideoView
mVideoView.setMediaController(mediaController);
}
try {
// ID of video file.
int id = this.getRawResIdByName("kung_fu_panda_3");
mVideoView.setVideoURI(Uri.parse("android.resource://" + mContext.getPackageName() + "/" + id));
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
mVideoView.requestFocus();
// When the video file ready for playback.
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mediaPlayer) {
mVideoView.seekTo(position);
if (position == 0) {
mVideoView.start();
}
// When video Screen change size.
mediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
// Re-Set the videoView that acts as the anchor for the MediaController
mediaController.setAnchorView(mVideoView);
}
});
}
});