视频播放
读取外部储存权限:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
SurfaceView
SurfaceView SV = (SurfaceView) findViewById(R.id.SV);
final SurfaceHolder holder = SV.getHolder();
new Thread(){
public void run() {
try {
SystemClock.sleep(400);
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource("/storage/sdcard1/视频/2461-毒薬-李雪薇-全世界都恋爱.mp4"); //2461-毒藥-李雪微-全世界都恋爱
mediaPlayer.prepareAsync();
mediaPlayer.setDisplay(holder);
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mediaPlayer.start();
mediaPlayer.seekTo(currentPosition);
}
});
} catch (Exception e) {
e.printStackTrace();
}
};
}.start();
}
VideoView
VideoView VV = (VideoView) findViewById(R.id.VV);
VV.setVideoPath("/storage/sdcard1/视频/2461-毒薬-李雪薇-全世界都恋爱.mp4");
VV.start();