正好最近做項目有個需要加載網絡視訊技術,就找了找,碰到了這個開源的架構。主要還是網絡請求下來的視訊位址,然後簡單的,賦一下值,非常OK。不過限自己練習用畢竟看需求的嘛,不多介紹複制用吧。
先看看效果大概就是這樣網絡權限:
導入兩個依賴:
implementation 'fm.jiecao:jiecaovideoplayer:4.8.3' //視訊架構依賴
implementation 'com.github.bumptech.glide:glide:4.8.0' //Glide依賴
android:id="@+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
送大家個免費搞笑視訊接口(裡面有的視訊位址過期了,不過不耽誤使用,資料持續更新,參數可拼接)
https://www.apiopen.top/satinGodApi?type=1&page=1
String video = list.get(position).getVideo();//視訊路徑
String name = (String) list.get(position).getTop_commentsName();//視訊名稱
String thumbnail = list.get(position).getThumbnail();//視訊顯示圖檔
if (video != null && name != null && thumbnail != null) {
boolean what= viewHolder.video.setUp(video,
JCVideoPlayer.SCREEN_LAYOUT_LIST, name);
if (what) {
viewHolder.video.thumbImageView.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context).load(thumbnail).into(viewHolder.video.thumbImageView);
}
}