Android使用視頻播放器的流程介紹
視頻播放器功能相對來說還是比較常見的功能,如果自己寫的話可能需要花費(fèi)比較多的時間,今天就給大家介紹第三方庫NurVideoPlayer,使用還是比較方便的。
支持屏幕滑動--滑動時間,亮度,聲音,支持全屏-單屏,雙擊暫停--繼續(xù),鎖定屏幕

使用
1、不要忘記項目的根build.gradle配置
allprojects {repositories {...maven { url 'https://jitpack.io' }}}
2、使用前需要先在項目中添加OkHttp的依賴庫
使用最新版本地址:
https://jitpack.io/#nurApplication/NurVideoPlayer/1.0.7
implementation 'com.gitee.nurApplication:NurVideoPlayer:1.0.7'3、添加網(wǎng)絡(luò)權(quán)限
<uses-permission android:name="android.permission.INTERNET"/>xml
<com.nurmemet.nur.nurvideoplayer.NurVideoPlayerandroid:id="@+id/videoView"android:layout_width="match_parent"android:layout_height="match_parent"app:video_height="200dp" />
android:layout_height= 一定要"match_parent"參數(shù)xml中只有一個app:video_height也就是視頻播放器的高度,默認(rèn)值"match_parent"


第一張圖app:video_height="200dp"
第二張圖-默認(rèn)
代碼:
String url = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";nurVideoPlayer = findViewById(R.id.videoView);nurVideoPlayer.setUp(this, url, "this is video name");nurVideoPlayer.start();
參數(shù)
| return | 方法 | 注釋 | 作用 |
|---|---|---|---|
void | setUp(Activity activity, String url, String videoName) | url視頻的地址,videoName | 初始化 |
void | start(); | 開始播放 | |
void | pause(); | 暫停 | |
void | resume(); | 繼續(xù) | |
void | setChangeScreen(boolean fullScreen) | fullScreen=true>全屏 | 更改-(全屏-單屏) |
void | setOnBackPress(OnBackPressListener onBackPressListener) | 沒有調(diào)用就不會顯示(??) | 點(diǎn)擊返回按鈕 |
void | setMonoMode(@NonNull MonoMode mode) | NORMAL LEFT_CHANNEL RIGHT_CHANNEL | 單聲道模式 |
void | seekTo(int msec); | msec---time | 進(jìn)度 |
ImageView | getThumbImageView(); | 你可以用把返回的imageView設(shè)置視頻的封面 | 封面 |
到這里就完成了。
評論
圖片
表情
