今天公司視頻要從CC替換成騰訊雲,腦袋疼java
可是也要硬着腦袋上android
首先先把騰訊雲視頻超級播放器集成到項目裏!架構
一、登錄騰訊雲視頻官網,下載sdk+開發包app
二、我使用的是導入源碼的方式,方便修改需求。若是不須要的話也能夠直接導入aar包方式ide
三、集成步驟:測試
首先將速度快文件夾裏的LiteAVSDK_Player_xxxx.arr文件複製到項目裏gradle
demo裏的lib_tcsuperplayer文件複製到項目裏ui
而後app的build.gradle內添加google
implementation(name: 'LiteAVSDK_Player_5.3.6004', ext: 'aar') implementation project(':lib_tcsuperplayer')
項目的build.gradle的allprojects{}內添加spa
allprojects { repositories { google() jcenter() flatDir { dirs 'libs' dirs project(':app').file('libs') } } }
項目的settings.gradle內添加
include ':app', ':lib_tcsuperplayer'
這時候要注意導入的依賴名字LiteAVSDK_Player_xxx要和你複製到項目libs內的一致
還有lib_tcsuperplayer內build.gradle裏的依賴的名字LiteAVSDK_Player_xxx也要一致
否則會報找不到錯誤哦
項目測試一下啊
<com.tencent.liteav.demo.play.SuperPlayerView android:background="@color/black" android:id="@+id/main_super_player_view" android:layout_width="match_parent" android:layout_height="300dp"></com.tencent.liteav.demo.play.SuperPlayerView>
public class MainActivity extends AppCompatActivity { private SuperPlayerView mSuperPlayerView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSuperPlayerView = (SuperPlayerView)findViewById(R.id.main_super_player_view); //經過fileid方式的視頻信息配置 SuperPlayerModel model = new SuperPlayerModel(); model.appid = 1252463788; // 默認的app id model.fileid = "5285890781763144364"; // 視頻的fileid; // 開始播放 mSuperPlayerView.playWithMode(model); } }
若是報錯 找不到TXCLog.nativeLogInit() 哪多是缺乏NDK設置
在app的build.gradle裏defaultConfig{}裏設置ndk便可
defaultConfig { applicationId "com.guorentong.learn.organ" minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } } ndk { abiFilters "armeabi", "armeabi-v7a" // 若是您使用的是商業版,只能使用 armeabi 架構,即: // abiFilters "armeabi", } }