|
|
@@ -1,18 +1,33 @@
|
|
|
package com.yingyang.livebroadcast.activity.video
|
|
|
|
|
|
+import android.os.Bundle
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.tencent.rtmp.TXVodPlayer
|
|
|
import com.yingyang.livebroadcast.databinding.ActivityVideoPlayerBinding
|
|
|
import com.yingyangfly.baselib.base.BaseActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 视频播放页面
|
|
|
*/
|
|
|
@Route(path = RouterUrlCommon.videoPlayer)
|
|
|
class VideoPlayerActivity : BaseActivity<ActivityVideoPlayerBinding>() {
|
|
|
|
|
|
- override fun initViews() {
|
|
|
+ private var url: String = ""
|
|
|
+ private var mVodPlayer: TXVodPlayer? = null
|
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ url = intent.getStringExtra("url") ?: ""
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun initViews() {
|
|
|
+ //创建 player 对象
|
|
|
+ mVodPlayer = TXVodPlayer(this)
|
|
|
+ //关联 player 对象与视频渲染 view
|
|
|
+ mVodPlayer?.setPlayerView(binding.playTxCloudView)
|
|
|
+ mVodPlayer?.startVodPlay(url)
|
|
|
}
|
|
|
|
|
|
override fun initListener() {
|
|
|
@@ -22,4 +37,12 @@ class VideoPlayerActivity : BaseActivity<ActivityVideoPlayerBinding>() {
|
|
|
override fun initData() {
|
|
|
}
|
|
|
|
|
|
+ override fun onDestroy() {
|
|
|
+ super.onDestroy()
|
|
|
+ if (mVodPlayer != null) {
|
|
|
+ mVodPlayer?.stopPlay(true) // true 代表清除最后一帧画面
|
|
|
+ binding.playTxCloudView.onDestroy()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|