|
|
package com.br_technology.securitytrain_master.ui.home.activity
|
|
|
|
|
|
import android.content.pm.ActivityInfo
|
|
|
import android.content.res.Configuration
|
|
|
import android.view.View
|
|
|
import android.view.WindowManager
|
|
|
import androidx.fragment.app.FragmentPagerAdapter
|
|
|
import com.br_technology.securitytrain_master.databinding.ActivityOnlineDetailBinding
|
|
|
import com.br_technology.securitytrain_master.ui.home.adapter.ResultPagerAdapter
|
|
|
import com.br_technology.securitytrain_master.ui.home.fragment.CourseListFragment
|
|
|
import com.br_technology.securitytrain_master.ui.home.fragment.OnlineDetailFragment
|
|
|
import com.br_technology.securitytrain_master.ui.home.viewmodel.OnlineDetailViewModel
|
|
|
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
|
|
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
|
|
|
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
|
|
|
import com.shuyu.gsyvideoplayer.listener.LockClickListener
|
|
|
import com.shuyu.gsyvideoplayer.utils.Debuger
|
|
|
import com.shuyu.gsyvideoplayer.utils.OrientationUtils
|
|
|
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Time: 7/30/2021 13:56
|
|
|
* Author: Captain
|
|
|
* Description: 初见时你很迷人
|
|
|
*/
|
|
|
class OnlineDetailActivity
|
|
|
: BaseLifeCycleActivity<OnlineDetailViewModel, ActivityOnlineDetailBinding>(
|
|
|
ActivityOnlineDetailBinding::inflate
|
|
|
) {
|
|
|
|
|
|
var orientationUtils: OrientationUtils ? =null
|
|
|
override fun initDataObserver() {
|
|
|
|
|
|
}
|
|
|
|
|
|
var isPlay : Boolean = false
|
|
|
|
|
|
override fun initData() {
|
|
|
super.initData()
|
|
|
|
|
|
binding.apply {
|
|
|
|
|
|
val searchResultAdapter = ResultPagerAdapter(
|
|
|
supportFragmentManager,
|
|
|
FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
|
|
|
)
|
|
|
val list =
|
|
|
listOf(OnlineDetailFragment(), CourseListFragment())
|
|
|
val titles = listOf("课程详情", "课程列表")
|
|
|
searchResultAdapter.addData(list)
|
|
|
searchResultAdapter.addTitle(titles)
|
|
|
viewPager.adapter = searchResultAdapter
|
|
|
tabLayout.setupWithViewPager(viewPager)
|
|
|
|
|
|
|
|
|
// val source1 =
|
|
|
// "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
|
|
|
// videoPlayer.setUp(source1, true, "测试视频")
|
|
|
|
|
|
//增加封面
|
|
|
|
|
|
|
|
|
//增加title
|
|
|
// videoPlayer.titleTextView.visibility = View.VISIBLE
|
|
|
// //设置返回键
|
|
|
// videoPlayer.backButton.visibility = View.VISIBLE
|
|
|
//设置旋转
|
|
|
orientationUtils = OrientationUtils(this@OnlineDetailActivity, videoPlayer)
|
|
|
|
|
|
val gsyVideoOption = GSYVideoOptionBuilder()
|
|
|
gsyVideoOption
|
|
|
.setIsTouchWiget(true)
|
|
|
.setRotateViewAuto(false)
|
|
|
.setLockLand(false)
|
|
|
.setAutoFullWithSize(true)
|
|
|
.setShowFullAnimation(false)
|
|
|
.setNeedLockFull(true)
|
|
|
.setUrl("http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4")
|
|
|
.setCacheWithPlay(false)
|
|
|
.setVideoTitle("测试视频")
|
|
|
.setVideoAllCallBack(object : GSYSampleCallBack() {
|
|
|
override fun onPrepared(url: String?, vararg objects: Any?) {
|
|
|
super.onPrepared(url, *objects)
|
|
|
//开始播放了才能旋转和全屏
|
|
|
orientationUtils!!.setEnable(true);
|
|
|
isPlay = true;
|
|
|
}
|
|
|
|
|
|
override fun onQuitFullscreen(url: String?, vararg objects: Any?) {
|
|
|
super.onQuitFullscreen(url, *objects)
|
|
|
|
|
|
Debuger.printfError("***** onQuitFullscreen **** " + objects[0]);//title
|
|
|
Debuger.printfError("***** onQuitFullscreen **** " + objects[1]);//当前非全屏player
|
|
|
if (orientationUtils != null) {
|
|
|
orientationUtils!!.backToProtVideo();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}).setLockClickListener(object : LockClickListener {
|
|
|
override fun onClick(view: View?, lock: Boolean) {
|
|
|
if (orientationUtils != null) {
|
|
|
//配合下方的onConfigurationChanged
|
|
|
orientationUtils!!.setEnable(!lock);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}).build(videoPlayer)
|
|
|
|
|
|
videoPlayer.fullscreenButton.setOnClickListener { //直接横屏
|
|
|
toolBar.visibility = View.GONE
|
|
|
|
|
|
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
|
|
|
orientationUtils!!.resolveByClick()
|
|
|
|
|
|
//第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
|
|
|
videoPlayer.startWindowFullscreen(this@OnlineDetailActivity, false, false)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//设置全屏按键功能,这是使用的是选择屏幕,而不是全屏
|
|
|
|
|
|
// videoPlayer.fullscreenButton.setOnClickListener({
|
|
|
//// orientationUtils!!.resolveByClick()
|
|
|
//
|
|
|
// videoPlayer.startWindowFullscreen(this@OnlineDetailActivity, true, true);
|
|
|
// })
|
|
|
|
|
|
//是否可以滑动调整
|
|
|
videoPlayer.setIsTouchWiget(true)
|
|
|
//设置返回按键功能
|
|
|
videoPlayer.backButton.visibility = View.GONE
|
|
|
videoPlayer.startButton.setOnClickListener({
|
|
|
videoPlayer.startPlayLogic()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
super.onDestroy()
|
|
|
GSYVideoManager.releaseAllVideos();
|
|
|
if (orientationUtils != null)
|
|
|
orientationUtils!!.releaseListener();
|
|
|
}
|
|
|
|
|
|
// override fun getGSYVideoPlayer(): StandardGSYVideoPlayer {
|
|
|
// return binding.videoPlayer
|
|
|
// }
|
|
|
//
|
|
|
// override fun getGSYVideoOptionBuilder(): GSYVideoOptionBuilder {
|
|
|
////内置封面可参考SampleCoverVideo
|
|
|
// //内置封面可参考SampleCoverVideo
|
|
|
// val imageView = ImageView(this)
|
|
|
//// loadCover(imageView, url)
|
|
|
// return GSYVideoOptionBuilder()
|
|
|
// .setThumbImageView(imageView)
|
|
|
// .setUrl("https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4")
|
|
|
// .setCacheWithPlay(true)
|
|
|
// .setVideoTitle(" ")
|
|
|
// .setIsTouchWiget(true)
|
|
|
// .setRotateViewAuto(false)
|
|
|
// .setLockLand(false)
|
|
|
// .setShowFullAnimation(false)
|
|
|
// .setNeedLockFull(true)
|
|
|
// .setSeekRatio(1f)
|
|
|
// }
|
|
|
//
|
|
|
// override fun clickForFullScreen() {
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
// override fun getDetailOrientationRotateAuto(): Boolean {
|
|
|
// return false
|
|
|
// }
|
|
|
|
|
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
|
|
super.onConfigurationChanged(newConfig)
|
|
|
// 横屏
|
|
|
if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
|
|
binding.toolBar.visibility=View.GONE
|
|
|
}else{
|
|
|
binding.toolBar.visibility=View.VISIBLE
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|