視頻播放器:
使用系統(tǒng)自帶的播放器
Uri parse = Uri.parse(data);//顯示數(shù)據(jù)給用戶
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(parse,"video/mp4");
startActivity(intent);?
使用VideoView結(jié)合MediaController來播放視頻
```
<VideoView
? ? android:id="@+id/video_view"
? ? android:layout_width="match_parent"
? ? android:layout_height="200dp" />
public void playVideoView() {
? ? ? ? String mp4path = Environment.getExternalStorageDirectory() + File.separator + "xxx.mp4";
? ? ? ? mVideoView.setVideoURI(Uri.parse(mp4path));
? ? ? ? mVideoView.start();
? ? ? ? mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onCompletion(MediaPlayer mp) {
? ? ? ? ? ? ? ? Log.d(TAG, "onCompletion: ");
? ? ? ? ? ? }
? ? ? ? });
? ? }
```
餃子播放器:
1.依賴
implementation 'cn.jzvd:jiaozivideoplayer:6.2.9'
```
<cn.jzvd.JZVideoPlayerStandard
? ? android:id="@+id/videoplayer"
? ? android:layout_width="match_parent"
? ? android:layout_height="200dp" />
```
2.簡單使用
```
public void jiaoziPlayer(){
? ? String mp4path = Environment.getExternalStorageDirectory() + File.separator + "xxx.mp4";
? ? JZVideoPlayerStandard jzVideoPlayerStandard = (JZVideoPlayerStandard) findViewById(R.id.videoplayer);
? ? jzVideoPlayerStandard.setUp(mp4path
? ? ? ? ?, JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, "餃子閉眼睛");
? ? jzVideoPlayerStandard.thumbImageView.setImageResource(R.drawable.ic_launcher_background);
```