2019独角兽企业重金招聘Python工程师标准>>>
今天公司视频要从CC替换成腾讯云,脑壳疼
但是也要硬着脑壳上
首先先把腾讯云视频超级播放器集成到项目里!
1、登陆腾讯云视频官网,下载sdk+开发包
2、我使用的是导入源码的方式,方便修改需求。如果不需要的话也可以直接导入aar包方式
3、集成步骤:
首先将速度快文件夹里的LiteAVSDK_Player_xxxx.arr文件复制到项目里
demo里的lib_tcsuperplayer文件复制到项目里
然后app的build.gradle内添加
implementation(name: 'LiteAVSDK_Player_5.3.6004', ext: 'aar') implementation project(':lib_tcsuperplayer')
项目的build.gradle的allprojects{}内添加
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.SuperPlayerViewandroid: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;@Overrideprotected 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 idmodel.fileid = "5285890781763144364"; // 视频的fileid;// 开始播放mSuperPlayerView.playWithMode(model);} }
如果报错 找不到TXCLog.nativeLogInit() 哪可能是缺少NDK设置
在app的build.gradle里defaultConfig{}里设置ndk即可
defaultConfig {applicationId "com.guorentong.learn.organ"minSdkVersion 16targetSdkVersion 26versionCode 1versionName "1.0.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"javaCompileOptions {annotationProcessorOptions {includeCompileClasspath = true}}ndk {abiFilters "armeabi", "armeabi-v7a"// 如果您使用的是商业版,只能使用 armeabi 架构,即:// abiFilters "armeabi",} }