迁移视频播放组件,SimpleVideoPlayer。使用方式参见V2XCrossRoadVideoView,V2XVoiceCallLiveCarWindow

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-10-25 16:48:18 +08:00
parent 0626c3d88b
commit 5025bfacc0
7 changed files with 28 additions and 19 deletions

View File

@@ -1,185 +0,0 @@
package com.mogo.module.v2x.view
import android.content.Context
import android.util.AttributeSet
import android.view.Surface
import android.view.View
import android.widget.ImageView
import com.mogo.module.v2x.R
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
/**
* @author congtaowang
* @since 2020/12/8
*
* 描述
*/
class SimpleLiveVideoPlayer : StandardGSYVideoPlayer {
companion object {
const val PLAY_EVT_PLAY_LOADING = 1000
const val PLAY_EVT_PLAY_BEGIN = 2000
const val PLAY_EVT_PLAY_ERROR = 3000
}
private var playListener: PlayListener? = null
private lateinit var start: ImageView
interface PlayListener {
fun onPlayEvent(event: Int)
}
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
override fun init(context: Context) {
super.init(context)
start = findViewById(R.id.start)
if (mThumbImageViewLayout != null
&& (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL || mCurrentState == GSYVideoView.CURRENT_STATE_ERROR)
) {
mThumbImageViewLayout.visibility = View.VISIBLE
}
}
override fun getLayoutId(): Int {
return R.layout.item_v2x_crossroad_live_video
}
override fun getGSYVideoManager(): GSYVideoViewBridge {
GSYVideoManager.instance().initContext(context.applicationContext)
return GSYVideoManager.instance()
}
override fun setProgressAndTime(
progress: Int,
secProgress: Int,
currentTime: Int,
totalTime: Int,
forceChange: Boolean
) {
super.setProgressAndTime(progress, secProgress, currentTime, totalTime, forceChange)
if (progress != 0) {
mProgressBar?.progress = progress
}
}
fun setPlayListener(listener: PlayListener) {
this.playListener = listener
}
override fun updateStartImage() {
}
override fun changeUiToCompleteShow() {
super.changeUiToCompleteShow()
mBottomContainer?.visibility = View.INVISIBLE
mProgressBar?.visibility = View.GONE
}
override fun hideAllWidget() {
super.hideAllWidget()
mBottomContainer?.visibility = View.INVISIBLE
mProgressBar?.visibility = View.GONE
}
override fun changeUiToPrepareingClear() {
super.changeUiToPrepareingClear()
mBottomContainer?.visibility = View.INVISIBLE
mProgressBar?.visibility = View.GONE
}
override fun changeUiToPlayingBufferingClear() {
super.changeUiToPlayingBufferingClear()
mBottomContainer?.visibility = View.INVISIBLE
mProgressBar?.visibility = View.GONE
}
override fun changeUiToClear() {
super.changeUiToClear()
mBottomContainer?.visibility = View.INVISIBLE
mProgressBar?.visibility = View.GONE
}
override fun changeUiToCompleteClear() {
super.changeUiToCompleteClear()
mBottomContainer?.visibility = View.INVISIBLE
mProgressBar?.visibility = View.GONE
}
override fun onAutoCompletion() {
super.onAutoCompletion()
mProgressBar?.progress = 0
}
override fun showWifiDialog() {
//直接播放不显示WIFI对话框
startPlayLogic()
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
mProgressBar?.progress = 0
mFullPauseBitmap = null
}
override fun onClick(v: View?) {
super.onClick(v)
}
override fun onCompletion() {
isPostBufferUpdate = false
}
override fun onSurfaceUpdated(surface: Surface) {
super.onSurfaceUpdated(surface)
if (mThumbImageViewLayout != null && mThumbImageViewLayout.visibility == View.VISIBLE) {
mThumbImageViewLayout.visibility = View.INVISIBLE
}
}
override fun onPrepared() {
super.onPrepared()
playListener?.onPlayEvent(PLAY_EVT_PLAY_LOADING)
}
private var isPostBufferUpdate = false
override fun onBufferingUpdate(percent: Int) {
super.onBufferingUpdate(percent)
if (!isPostBufferUpdate && percent == 0) {
isPostBufferUpdate = true
playListener?.onPlayEvent(PLAY_EVT_PLAY_BEGIN)
}
}
override fun onError(what: Int, extra: Int) {
super.onError(what, extra)
playListener?.onPlayEvent(PLAY_EVT_PLAY_ERROR)
isPostBufferUpdate = false
}
override fun setViewShowState(view: View?, visibility: Int) {
if (view === mThumbImageViewLayout && visibility != View.VISIBLE) {
return
}
super.setViewShowState(view, visibility)
}
override fun onSurfaceAvailable(surface: Surface) {
super.onSurfaceAvailable(surface)
mProgressBar?.visibility = View.GONE
if (GSYVideoType.getRenderType() != GSYVideoType.TEXTURE) {
if (mThumbImageViewLayout != null && mThumbImageViewLayout.visibility == View.VISIBLE) {
mThumbImageViewLayout.visibility = View.INVISIBLE
}
}
}
}

View File

@@ -17,6 +17,7 @@ import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.utilcode.util.Utils;
import com.mogo.eagle.core.widget.RoundLayout;
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.MarkerCarInfo;
import com.mogo.module.v2x.R;
@@ -40,8 +41,8 @@ import java.util.List;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
import static com.mogo.module.v2x.view.SimpleLiveVideoPlayer.PLAY_EVT_PLAY_BEGIN;
import static com.mogo.module.v2x.view.SimpleLiveVideoPlayer.PLAY_EVT_PLAY_LOADING;
import static com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer.PLAY_EVT_PLAY_BEGIN;
import static com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer.PLAY_EVT_PLAY_LOADING;
/**
* author : donghongyu EmArrow
@@ -54,7 +55,7 @@ public class V2XCrossRoadVideoView extends RoundLayout {
private static final String TAG = "CrossRoadVideo";
private SimpleLiveVideoPlayer mTxcVideoView;
private SimpleVideoPlayer mTxcVideoView;
private final GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
private ProgressBar mLoading;
private ConstraintLayout mClLoadError;