[M2] M2 视频播放
This commit is contained in:
@@ -90,7 +90,7 @@ class PM2DrivingModel private constructor() {
|
||||
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, mMapLocationListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,5)//设置5hz, 1s返回一次
|
||||
CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,2)//设置2hz, 1s返回2次
|
||||
|
||||
CallerTelematicListenerManager.addListener(TAG,mReceivedMsgListener)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import chassis.ChassisStatesOuterClass
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
@@ -15,7 +14,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerBatteryManagementSystem
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import kotlinx.android.synthetic.m2.p_m2_view_status_bar.view.*
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.mogo.och.bus.passenger.ui.widget.video
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.mogo.och.bus.passenger.R
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -26,7 +29,10 @@ class AdvanceImageView @JvmOverloads constructor(
|
||||
addView(imageView, LayoutParams(-1, -1))
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun setImagePath(path: String){
|
||||
imageView?.let { Glide.with(context).load(path).into(it) }
|
||||
imageView?.let { Glide.with(context).load(path)
|
||||
.apply { RequestOptions().placeholder(R.drawable.m2_p_video_holder).centerCrop() }
|
||||
.into(it) }
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.view.ViewGroup
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -48,10 +49,27 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
|
||||
Logger.d("onPageScrollStateChanged", "第一个是视频")
|
||||
val video = viewList[mViewPager.currentItem] as AdvanceVideoView
|
||||
video.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
|
||||
video.setVideo {
|
||||
Logger.d("onPageScrollStateChanged", "视频播放完成")
|
||||
goNextItemView()
|
||||
}
|
||||
video.setVideo( object : GSYSampleCallBack() {
|
||||
|
||||
override fun onPrepared(url: String?, vararg objects: Any?) {
|
||||
super.onPrepared(url, *objects)
|
||||
Logger.d("onPageScrollStateChanged", "onPrepared")
|
||||
video.setCacheImageViewGone()
|
||||
}
|
||||
|
||||
override fun onAutoComplete(url: String?, vararg objects: Any?) {
|
||||
Logger.d("onPageScrollStateChanged", "onAutoComplete()")
|
||||
video.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
|
||||
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
|
||||
}
|
||||
|
||||
override fun onPlayError(url: String?, vararg objects: Any?) {
|
||||
Logger.d("onPageScrollStateChanged", "onPlayError()")
|
||||
video.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
|
||||
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
|
||||
}
|
||||
})
|
||||
|
||||
} else if (viewList[mViewPager.currentItem] is AdvanceImageView) {
|
||||
Logger.d("onPageScrollStateChanged", "startTimer()_1")
|
||||
current = 0//换页重新计算时间
|
||||
@@ -137,10 +155,27 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
|
||||
|
||||
if (viewList[mViewPager.currentItem] is AdvanceVideoView) {
|
||||
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
|
||||
videoView.setVideo {
|
||||
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
|
||||
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
|
||||
}
|
||||
videoView.setVideo(object : GSYSampleCallBack() {
|
||||
override fun onPrepared(url: String?, vararg objects: Any?) {
|
||||
super.onPrepared(url, *objects)
|
||||
Logger.d("onPageScrollStateChanged", "onPrepared")
|
||||
videoView.setCacheImageViewGone()
|
||||
}
|
||||
|
||||
override fun onAutoComplete(url: String?, vararg objects: Any?) {
|
||||
super.onAutoComplete(url, *objects)
|
||||
Logger.d("onPageScrollStateChanged", "onAutoComplete()")
|
||||
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
|
||||
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
|
||||
}
|
||||
|
||||
override fun onPlayError(url: String?, vararg objects: Any?) {
|
||||
super.onPlayError(url, *objects)
|
||||
Logger.d("onPageScrollStateChanged", "onPlayError()")
|
||||
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
|
||||
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
|
||||
}
|
||||
})
|
||||
|
||||
} else if (viewList[mViewPager.currentItem] is AdvanceImageView) {
|
||||
Logger.d("onPageScrollStateChanged", "startTimer()")
|
||||
@@ -166,6 +201,8 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
|
||||
if (viewList[mViewPager.currentItem] is AdvanceImageView) {
|
||||
Logger.d("onPageScrollStateChanged", "增加1s")
|
||||
current += 1000
|
||||
}else{
|
||||
break
|
||||
}
|
||||
if (current >= time) {
|
||||
Logger.d("onPageScrollStateChanged", "5s到,跳转")
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.mogo.och.bus.passenger.ui.widget.video
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.media.MediaPlayer
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.VideoView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import java.lang.RuntimeException
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
|
||||
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -23,7 +23,8 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
|
||||
private var videoRelativeLayout: RelativeLayout? = null
|
||||
private var cacheImage: ImageView? = null
|
||||
private var videoView: VideoView? = null
|
||||
private var videoViewPlayer: StandardGSYVideoPlayer? = null
|
||||
private var gsyVideoOptionBuilder: GSYVideoOptionBuilder? = null
|
||||
private var path: String? = null
|
||||
|
||||
init {
|
||||
@@ -31,33 +32,29 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
videoRelativeLayout = RelativeLayout(context)
|
||||
addView(videoRelativeLayout, LayoutParams(-1, -1))
|
||||
initCacheImgView()
|
||||
initVideoView()
|
||||
}
|
||||
|
||||
private fun initCacheImgView() {
|
||||
cacheImage = ImageView(context)
|
||||
cacheImage?.scaleType = ImageView.ScaleType.FIT_XY
|
||||
addView(cacheImage, LayoutParams(-1, -1))
|
||||
}
|
||||
|
||||
fun setVideoPath(path: String){
|
||||
this.path = path
|
||||
}
|
||||
private fun initVideoView() {
|
||||
videoRelativeLayout = RelativeLayout(context)
|
||||
addView(videoRelativeLayout, LayoutParams(-1, -1))
|
||||
|
||||
|
||||
fun setCacheImageView(imgPath: String){
|
||||
cacheImage?.visibility = VISIBLE
|
||||
cacheImage?.let { Glide.with(context).load(imgPath).into(it) }
|
||||
}
|
||||
|
||||
fun setVideo(onCompletionListener : MediaPlayer.OnCompletionListener) {
|
||||
if (videoView != null){
|
||||
videoRelativeLayout?.removeView(videoView)
|
||||
videoView = null
|
||||
if (videoViewPlayer === null) {
|
||||
//视频播放控件
|
||||
videoViewPlayer = StandardGSYVideoPlayer(context)
|
||||
}
|
||||
if (gsyVideoOptionBuilder === null) {
|
||||
gsyVideoOptionBuilder = GSYVideoOptionBuilder()
|
||||
}
|
||||
|
||||
//视频播放控件
|
||||
videoView = VideoView(context)
|
||||
videoView?.setVideoPath(path)
|
||||
videoView?.setBackgroundColor(Color.TRANSPARENT)
|
||||
videoViewPlayer?.isFocusableInTouchMode = false
|
||||
|
||||
var layoutParams = LayoutParams(-1, -1)
|
||||
//设置videoview占满父view播放
|
||||
@@ -65,29 +62,48 @@ class AdvanceVideoView @JvmOverloads constructor(
|
||||
layoutParams.addRule(ALIGN_PARENT_RIGHT)
|
||||
layoutParams.addRule(ALIGN_PARENT_TOP)
|
||||
layoutParams.addRule(ALIGN_PARENT_BOTTOM)
|
||||
videoRelativeLayout?.addView(videoView, layoutParams)
|
||||
videoView?.setOnCompletionListener(onCompletionListener)
|
||||
videoView?.start()
|
||||
|
||||
videoView?.setOnPreparedListener {
|
||||
UiThreadHandler.postDelayed({
|
||||
cacheImage?.visibility = GONE
|
||||
},500)
|
||||
videoRelativeLayout?.addView(videoViewPlayer, layoutParams)
|
||||
}
|
||||
|
||||
fun setVideoPath(path: String) {
|
||||
this.path = path
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun setCacheImageView(imgPath: String) {
|
||||
cacheImage?.visibility = VISIBLE
|
||||
cacheImage?.let {
|
||||
Glide.with(context)
|
||||
.apply { RequestOptions().placeholder(R.drawable.m2_p_video_holder).centerCrop() }
|
||||
.load(imgPath).into(it)
|
||||
}
|
||||
}
|
||||
|
||||
videoView?.setOnCompletionListener(onCompletionListener)
|
||||
fun setVideo(onCompletionListener: GSYSampleCallBack) {
|
||||
|
||||
gsyVideoOptionBuilder?.setUrl(path)
|
||||
?.setBottomProgressBarDrawable(null)
|
||||
?.build(videoViewPlayer)
|
||||
|
||||
videoViewPlayer?.setVideoAllCallBack(onCompletionListener)
|
||||
|
||||
videoViewPlayer?.startPlayLogic()
|
||||
}
|
||||
|
||||
fun setCacheImageViewGone() {
|
||||
cacheImage?.visibility = GONE
|
||||
}
|
||||
|
||||
fun setPause() {
|
||||
if (videoView != null) {
|
||||
videoView?.pause()
|
||||
if (videoViewPlayer !== null) {
|
||||
videoViewPlayer?.onVideoPause()
|
||||
}
|
||||
}
|
||||
|
||||
fun setRestart() {
|
||||
if (videoView != null) {
|
||||
videoView?.start()
|
||||
if (videoViewPlayer !== null) {
|
||||
videoViewPlayer?.startPlayLogic()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
@@ -37,6 +37,9 @@ project.android.productFlavors {
|
||||
// 构建的是否是演示(美化)模式
|
||||
buildConfigField 'boolean', 'IS_DEMO_MODE', 'false'
|
||||
|
||||
// 构建的是否要动态更换模型
|
||||
buildConfigField 'boolean', 'IS_CAR_MODEL_CHANGE', 'true'
|
||||
|
||||
// 构建 是否支持多屏异显异交互
|
||||
buildConfigField 'boolean', 'IS_MULTI_DISPLAY', 'false'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user