日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android中简单视频播放器demo(附githup下载源码)

發(fā)布時間:2023/12/10 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android中简单视频播放器demo(附githup下载源码) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

android 簡單視頻播放器demo(免費,贊)

關(guān)于我

每篇文章博主都會仔細來回閱讀,語文不好,發(fā)現(xiàn)有語法錯誤,麻煩評論留言,一定改。
著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請注明出處

介紹

githup上的下載路徑為:https://github.com/wenfujing/video_svg,下載最新的庫文件,并且導(dǎo)入到項目的LIB下便可以使用。

該庫以及DEMO本地下載鏈接:下載地址

知識儲備

Android-Universal-Image-Loader是一個開源的UI組件程序,該項目的目的是提供一個可重復(fù)使用的儀器為異步圖像加載,緩存和顯示。所以,如果你的程序里需要這個功能的話,那么不妨試試它。因為已經(jīng)封裝好了一些類和方法。我們 可以直接拿來用了。而不用重復(fù)去寫了。其實,寫一個這方面的程序還是比較麻煩的,要考慮多線程,緩存,內(nèi)存溢出等很多方面。但是,你也可以參考這個例子來自己寫出更好的程序。在此為大家介紹一下。效果圖如下:

效果圖

實現(xiàn)步驟

1、使用
1.1 在project的build.gradle添加如下代碼和引入lib庫

android {compileSdkVersion 29buildToolsVersion "29.0.2"defaultConfig {applicationId "com.ocwvar.video_svg"minSdkVersion 19targetSdkVersion 29versionCode 1versionName "1.0"testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"}buildTypes {release {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}}

//依賴(圖像異步加載)

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'

1.2 運行所需權(quán)限

<uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

1.3 布局文件

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><fm.jiecao.jcvideoplayer_lib.JCVideoPlayerandroid:id="@+id/jcvideoplayer"android:layout_width="match_parent"android:layout_height="match_parent" /></LinearLayout>

1.4 配置清單文件

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.ocwvar.video_svg"><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/AppTheme"><activity android:name=".MainActivity"android:configChanges="orientation"android:screenOrientation="portrait"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activityandroid:name=".ListActivity"android:screenOrientation="portrait" /><activityandroid:name=".ListViewpagerActivity"android:screenOrientation="portrait" /><activityandroid:name=".SetSkinActivity"android:screenOrientation="portrait" /></application></manifest>

1.5 activity 中調(diào)運
一行代碼調(diào)用,大部分需求都能實現(xiàn),

public class MainActivity extends AppCompatActivity implements View.OnClickListener {JCVideoPlayer videoController1, videoController2, videoController3;Button btnToList, btnToListViewpager, btnToFullscreen, btnToChangecolor;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);/*** 如果沒有埋點需求,可以不用注冊eventbus* <br>* if you do not want to get Buried Point , you do not need regist eventbus here*/EventBus.getDefault().register(this);videoController1 = (JCVideoPlayer) findViewById(R.id.videocontroller1);videoController1.setUp("http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4","http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640","簡單代碼實現(xiàn)視頻播放");videoController2 = (JCVideoPlayer) findViewById(R.id.videocontroller2);videoController2.setUp("http://2449.vod.myqcloud.com/2449_ded7b566b37911e5942f0b208e48548d.f20.mp4",//"http://p.qpic.cn/videoyun/0/2449_ded7b566b37911e5942f0b208e48548d_2/640","簡單代碼實現(xiàn)視頻播放", false);videoController3 = (JCVideoPlayer) findViewById(R.id.videocontroller3);videoController3.setUp("http://121.40.64.47/resource/mp3/music_yangguang3.mp3",//"http://p.qpic.cn/videoyun/0/2449_38e65894d9e211e5b0e0a3699ca1d490_1/640","簡單代碼實現(xiàn)視頻播放");btnToList = (Button) findViewById(R.id.to_list_activity);btnToListViewpager = (Button) findViewById(R.id.to_list_viewpager_activity);btnToFullscreen = (Button) findViewById(R.id.to_fullscreen);btnToChangecolor = (Button) findViewById(R.id.to_changecolor_activity);btnToList.setOnClickListener(this);btnToListViewpager.setOnClickListener(this);btnToFullscreen.setOnClickListener(this);btnToChangecolor.setOnClickListener(this);}@Overrideprotected void onPause() {super.onPause();JCVideoPlayer.releaseAllVideos();}public void onEventMainThread(VideoEvents event) {if (event.type == VideoEvents.POINT_START_ICON) {Log.i("Video Event", "POINT_START_ICON" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_START_THUMB) {Log.i("Video Event", "POINT_START_THUMB" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_STOP) {Log.i("Video Event", "POINT_STOP" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_STOP_FULLSCREEN) {Log.i("Video Event", "POINT_STOP_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_RESUME) {Log.i("Video Event", "POINT_RESUME" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_RESUME_FULLSCREEN) {Log.i("Video Event", "POINT_RESUME_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_CLICK_BLANK) {Log.i("Video Event", "POINT_CLICK_BLANK" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_CLICK_BLANK_FULLSCREEN) {Log.i("Video Event", "POINT_CLICK_BLANK_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_CLICK_SEEKBAR) {Log.i("Video Event", "POINT_CLICK_SEEKBAR" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_CLICK_SEEKBAR_FULLSCREEN) {Log.i("Video Event", "POINT_CLICK_SEEKBAR_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_AUTO_COMPLETE) {Log.i("Video Event", "POINT_AUTO_COMPLETE" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_AUTO_COMPLETE_FULLSCREEN) {Log.i("Video Event", "POINT_AUTO_COMPLETE_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_ENTER_FULLSCREEN) {Log.i("Video Event", "POINT_ENTER_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);} else if (event.type == VideoEvents.POINT_QUIT_FULLSCREEN) {Log.i("Video Event", "POINT_QUIT_FULLSCREEN" + " title is : " + event.obj + " url is : " + event.obj1);}}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.to_list_activity:startActivity(new Intent(MainActivity.this, ListActivity.class));break;case R.id.to_list_viewpager_activity:startActivity(new Intent(MainActivity.this, ListViewpagerActivity.class));break;case R.id.to_fullscreen://進入全屏播放JCVideoPlayer.toFullscreenActivity(this,"http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4","http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640","簡單代碼實現(xiàn)視頻播放");break;case R.id.to_changecolor_activity:startActivity(new Intent(this, SetSkinActivity.class));break;}}@Overrideprotected void onDestroy() {super.onDestroy();EventBus.getDefault().unregister(this);}}

參照項目:https://github.com/qiushi123/VideoDemoQcl

來源:渭水河畔_wenfujing

如何插入一段漂亮的代碼片

去博客設(shè)置頁面,選擇一款你喜歡的代碼片高亮樣式,下面展示同樣高亮的 代碼片.

// An highlighted block var foo = 'bar';

總結(jié)

以上是生活随笔為你收集整理的android中简单视频播放器demo(附githup下载源码)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。