作者 杨谦

1.视频进度控制逻辑

... ... @@ -90,34 +90,6 @@ class CourseDetailActivity
}
})
// // 视频数据
// mViewModel.mVideoLessonNormal.observe(this, {
// binding.apply {
// searchResultAdapter = BasePagerAdapter(
// supportFragmentManager,
// FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
// )
// val list =
// mutableListOf(
// OnlineDetailFragment(
// TrainClassDes(
// courseLesson?.name ?: "",
// courseLesson?.pos_ids ?: "",
// courseLesson?.content ?: ""
// ), TYPE_COURSE_DETAIL_ITEM_NORMAL
// ),
// CourseListFragment(TrainCourseData(TYPE_COURSE_DETAIL_ITEM_NORMAL).apply {
// this.lessonBeanNormal = it.data.detail
// }, "${courseBean?.mTrainClassId}")
// )
// val titles = listOf("课程详情", "课程列表")
// searchResultAdapter?.addData(list.toMutableList())
// searchResultAdapter?.addTitle(titles)
// viewPager.adapter = searchResultAdapter
// tabLayout.setupWithViewPager(viewPager)
// }
// })
mViewModel.mLiveLesson.observe(this, {
binding.apply {
Glide.with(this@CourseDetailActivity).load(it.data.detail.image).into(ivTop)
... ...
... ... @@ -22,6 +22,20 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity
var courseBean: CourseParam? = null
override fun initDataObserver() {
mViewModel.mVideoLesson.observe(this, {
val url = it.data.detail.clazz[0].lessonclassdetail[0].video_url
val bool = it.data.detail.clazz[0].lessonclassdetail[0].is_complete == 1
binding.videoPlayer.apply {
initVideoBuilderMode(
"it.data.detail.image",
url,
this@VideoDetailActivity,
true,
lifecycle
)
setCantTouch(bool)
}
})
}
override fun initView() {
... ... @@ -31,25 +45,19 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity
if (!TextUtils.isEmpty(intent.getStringExtra(ConstantParamKey.COMMON_URL))) {
mViewModel.record(timeGet(binding.videoPlayer.getProgressTime()))
}
if (!isPause && isFinish) {
binding.videoPlayer.setCantTouch(true)
}
}
}
}
override fun initData() {
super.initData()
val url = intent.getStringExtra(ConstantParamKey.COMMON_URL)
val id = intent.getIntExtra(ConstantParamKey.LESSON_ID, 0)
courseBean = intent.getParcelableExtra(ConstantParamKey.COURSE_BEAN)
mViewModel.videoLessonsDetail(id)
mViewModel.courseParam.value = courseBean
url?.apply {
binding.videoPlayer.initVideoBuilderMode(
"it.data.detail.image",
// it.data.detail.classX[0].lessonclassdetail[0].video_url
url,
this@VideoDetailActivity,
true,
lifecycle
)
}
}
fun timeGet(str: String): String {
... ...
... ... @@ -3,6 +3,7 @@ package com.br_technology.securitytrain_master.ui.view.home.adapter
import android.content.Intent
import android.view.View
import com.br_technology.securitytrain_master.R
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.ui.view.home.activity.course.VideoDetailActivity
import com.br_technology.securitytrain_master.ui.view.home.bean.VideoLessonDetailBean
import com.br_technology.securitytrain_master.util.TimeFenMUtils
... ... @@ -32,7 +33,7 @@ class VideoCourseListSecondProvider : BaseNodeProvider() {
data as VideoLessonDetailBean.DetailBean.ClassBean.LessonclassdetailBean
context.startActivity(
Intent(context, VideoDetailActivity::class.java)
.putExtra("id", lessonDetailBean.id)
.putExtra(ConstantParamKey.LESSON_ID, lessonDetailBean.lesson_id)
.putExtra("train_class_id", lessonDetailBean.lesson_id)
)
}
... ...
... ... @@ -4,6 +4,7 @@ import android.content.Intent
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COMMON_URL
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.COURSE_BEAN
import com.br_technology.securitytrain_master.base.common.ConstantParamKey.LESSON_ID
import com.br_technology.securitytrain_master.databinding.FragmentCourseListBinding
import com.br_technology.securitytrain_master.ui.bean.TrainCourseData
import com.br_technology.securitytrain_master.ui.bean.TrainCourseDetailItem
... ... @@ -80,6 +81,7 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin
startActivity(
Intent(activity, VideoDetailActivity::class.java)
.putExtra(COMMON_URL, item.lessonVideoChild?.video_url)
.putExtra(LESSON_ID, item.lessonVideoChild?.lesson_id?.toInt())
.putExtra(COURSE_BEAN, param)
)
}
... ... @@ -88,6 +90,7 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin
startActivity(
Intent(activity, VideoDetailActivity::class.java)
.putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url)
.putExtra(LESSON_ID, item.lessonVideoNormalChild?.lesson_id?.toInt())
.putExtra(
COURSE_BEAN,
(activity as CourseDetailActivity).getCourseBean()
... ... @@ -99,6 +102,7 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin
startActivity(
Intent(activity, VideoDetailActivity::class.java)
.putExtra(COMMON_URL, item.lessonLiveChild?.webrtc_url)
.putExtra(LESSON_ID, item.lessonLiveChild?.id)
.putExtra(
COURSE_BEAN,
(activity as CourseDetailActivity).getCourseBean()
... ...
... ... @@ -5,6 +5,7 @@ import com.br_technology.securitytrain_master.base.network.response.BaseResponse
import com.br_technology.securitytrain_master.base.repository.LessonRepository
import com.br_technology.securitytrain_master.base.view.BaseViewModel
import com.br_technology.securitytrain_master.ui.bean.CourseParam
import com.br_technology.securitytrain_master.ui.bean.LessonTrainVideoDetail
/**
* Time: 12/8/2021 15:46
... ... @@ -17,6 +18,8 @@ class VideoDetailViewModel : BaseViewModel<LessonRepository>() {
val record = MutableLiveData<BaseResponse<Void>>()
val mVideoLesson = MutableLiveData<BaseResponse<LessonTrainVideoDetail>>()
fun record(
view_len: String
) {
... ... @@ -37,4 +40,10 @@ class VideoDetailViewModel : BaseViewModel<LessonRepository>() {
}
}
}
fun videoLessonsDetail(
id: Int
) {
mRepository.lessonVideoDetail(id, mVideoLesson)
}
}
\ No newline at end of file
... ...
... ... @@ -25,6 +25,7 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
private var isPlay = false
private var isPause = false
private var canTouchProgress = false
private var orientationUtils: OrientationUtils? = null
... ... @@ -67,6 +68,12 @@ class MyVideoPlayer : StandardGSYVideoPlayer, LifecycleObserver {
showFull()
}
}
mProgressBar.isEnabled = canTouchProgress
}
fun setCantTouch(bool: Boolean) {
canTouchProgress = bool
mProgressBar.isEnabled = canTouchProgress
}
private fun showFull() {
... ...