[650]refactor: 调试路侧视频流拉流及事件弹框 UI 样式;

This commit is contained in:
aibingbing
2024-06-17 18:50:01 +08:00
parent dbf223c997
commit b962ea9ffd
14 changed files with 194 additions and 42 deletions

View File

@@ -205,7 +205,7 @@
android:layout_marginEnd="@dimen/dp_52"
app:layout_constraintBottom_toTopOf="@+id/aciv_xiaozhi_normal"
app:layout_constraintRight_toRightOf="parent"
android:visibility="gone"/>
android:visibility="visible"/>
<!--气泡态消息盒子-->
<com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView

View File

@@ -5,9 +5,13 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.containerLivePlay
import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.ivPassengerV2XImage
import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.tvPassengerV2XContent
import kotlinx.android.synthetic.main.hmi_view_passenger_v2n_event.view.tvPassengerV2XTime
/**
* V2N通用事件弹框乘客屏
@@ -22,12 +26,22 @@ class PassengerV2NEventView @JvmOverloads constructor(
const val TAG = "PassengerV2NEventView"
}
private val isPassengerScreen by lazy {
AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)
}
init {
LayoutInflater.from(context).inflate(R.layout.hmi_view_passenger_v2n_event, this, true)
initView()
}
private fun initView() {
background = if (isPassengerScreen) ContextCompat.getDrawable(
context,
R.drawable.hmi_v2n_event_bg_passenger
)
else ContextCompat.getDrawable(context, R.drawable.bg_v2n_event_driver)
//TODO
ivPassengerV2XImage.setImageDrawable(
ContextCompat.getDrawable(
@@ -35,7 +49,9 @@ class PassengerV2NEventView @JvmOverloads constructor(
R.drawable.v2x_icon_shigong_zhandao
)
)
tvPassengerV2XContent.text = "前方150米 道路施工"
tvPassengerV2XContent.text = "前方150米 道路施工 前方150米 道路施工 前方150米 道路施工"
tvPassengerV2XTime.text = "更新时间10:38:20"
containerLivePlay.startPlay("https://video.zhidaozhixing.com/hy/LI_008_070.flv?txSecret=28ece9ad0bd67d06a7d391ed42264a99&txTime=66922502")
}
override fun onAttachedToWindow() {

View File

@@ -1,21 +1,33 @@
package com.mogo.eagle.core.function.hmi.ui.v2n
import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.animation.AnimationUtils
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.model.VideoOptionModel
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
import com.shuyu.gsyvideoplayer.player.PlayerFactory
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
import kotlinx.android.synthetic.main.hmi_view_v2n_event_live_play.view.ivLoading
import kotlinx.android.synthetic.main.hmi_view_v2n_event_live_play.view.ivTipLogo
import kotlinx.android.synthetic.main.hmi_view_v2n_event_live_play.view.svpPlayer
import kotlinx.android.synthetic.main.hmi_view_v2n_event_live_play.view.tvTipContent
import tv.danmaku.ijk.media.player.IjkMediaPlayer
class V2NEventLivePlayView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
companion object {
@@ -26,60 +38,153 @@ class V2NEventLivePlayView @JvmOverloads constructor(
GSYVideoOptionBuilder()
}
// 是否播放成功
private var isPlaySuccess = false
// 拉流的url
private var flvUrl: String? = null
private val videoLoadingAnimation by lazy {
AnimationUtils.loadAnimation(context, R.anim.loading_rotate_animation);
}
private val isPassengerScreen by lazy {
AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)
}
init {
LayoutInflater.from(context).inflate(R.layout.hmi_view_v2n_event_live_play, this, true)
initView()
}
private fun initView() {
showLoading()
//TODO
UiThreadHandler.postDelayed({
showLivePlay("https://video.zhidaozhixing.com/hy/LI_008_070.flv?txSecret=28ece9ad0bd67d06a7d391ed42264a99&txTime=66922502")
}, 2000L)
//初始化播放器
val list: MutableList<VideoOptionModel> = ArrayList()
list.add(VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "reconnect", 3))
GSYVideoManager.instance().optionModelList = list
GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL)
PlayerFactory.setPlayManager(IjkPlayerManager::class.java)
svpPlayer.setPlayListener(object : SimpleVideoPlayer.PlayListener {
override fun onPlayEvent(event: Int) {
CallerLogger.d("${SceneConstant.M_HMI}$TAG", "onPlayEvent: event is:$event")
when (event) {
SimpleVideoPlayer.PLAY_EVT_PLAY_LOADING -> {
// 会出现临时中断后又可以继续播放,需要停掉倒计时
if (videoLoadingAnimation.hasStarted()) {
videoLoadingAnimation.cancel()
}
}
SimpleVideoPlayer.PLAY_EVT_PLAY_BEGIN -> {
CallerLogger.w(
"${SceneConstant.M_HMI}$TAG",
"播放视频成功, event is:$event"
)
showVideoAfterLoad()
isPlaySuccess = true
}
else -> {
CallerLogger.w(
"${SceneConstant.M_HMI}$TAG",
"播放视频异常, event is:$event"
)
stopLoading()
showPlayFail()
}
}
}
})
}
fun startPlay(flvUrl: String) {
this.flvUrl = flvUrl
if (TextUtils.isEmpty(flvUrl)) {
CallerLogger.e(
"${SceneConstant.M_HMI}$TAG",
"播放视频异常, flvUrl=$flvUrl"
)
showPlayFail()
return
}
CallerLogger.w(
"${SceneConstant.M_HMI}$TAG",
"开始播放视频, flvUrl=$flvUrl"
)
startLoading()
this.flvUrl?.also {
startLoadVideo(it)
}
}
/**
* 展示加载中
* 展示 加载中
*/
fun showLoading() {
private fun startLoading() {
tvTipContent.visibility = View.GONE
ivTipLogo.visibility = View.GONE
svpPlayer.visibility = View.GONE
ivLoading.setImageDrawable(
ContextCompat.getDrawable(
context, R.drawable.hmi_v2n_event_video_play_loading_passenger
)
)
ivLoading.startAnimation(videoLoadingAnimation)
ivLoading.visibility = View.VISIBLE
}
/**
* 停止 加载中
*/
private fun stopLoading() {
videoLoadingAnimation?.cancel()
ivLoading.visibility = View.GONE
}
/**
* 展示 加载失败
*/
private fun showPlayFail() {
tvTipContent.visibility = View.GONE
ivTipLogo.visibility = View.VISIBLE
svpPlayer.visibility = View.GONE
ivLoading.visibility = View.GONE
}
/**
* 展示请求视频流地址失败
* 加载完后 展示播放画面
*/
fun showLoadFail() {
tvTipContent.visibility = View.VISIBLE
ivTipLogo.visibility = View.GONE
svpPlayer.visibility = View.GONE
}
/**
* 开始视频流播放
*/
fun showLivePlay(flvUrl: String) {
gsyVideoOptionBuilder.setUrl(flvUrl)
private fun startLoadVideo(flvUrl: String) {
gsyVideoOptionBuilder
.setUrl(flvUrl)
.setCacheWithPlay(false)
.setAutoFullWithSize(false)
.setIsTouchWigetFull(false)
.setIsTouchWiget(false)
.setPlayTag(TAG).build(svpPlayer)
.setPlayTag(TAG)
.build(svpPlayer)
svpPlayer.startButton.performClick()
}
/**
* 加载完后 展示播放画面
*/
private fun showVideoAfterLoad() {
tvTipContent.visibility = View.GONE
ivTipLogo.visibility = View.GONE
svpPlayer.visibility = View.VISIBLE
ivLoading.visibility = View.GONE
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
startLoading()
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
stopLoading()
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="1000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
</set>

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="146"
android:endColor="#DDE6F5"
android:startColor="#E9F1FF"
android:angle="45"
android:endColor="#080C15"
android:startColor="#16316C"
android:type="linear" />
<corners android:radius="@dimen/dp_20" />
</shape>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#B2BED9" />
</shape>

View File

@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dp_600"
android:layout_height="wrap_content"
android:background="@drawable/bg_passenger_v2n_event"
app:roundLayoutRadius="@dimen/dp_36">
android:background="@drawable/bg_v2n_event_driver">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/containerEvent"
@@ -49,7 +48,7 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_default="wrap"
app:layout_goneMarginStart="0dp"
tools:text="前方150米 道路施工" />
tools:text="前方150米 道路施工 前方150米 道路施工 前方150米 道路施工" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -60,15 +59,17 @@
android:layout_marginStart="@dimen/dp_51"
android:layout_marginTop="@dimen/dp_24"
android:layout_marginEnd="@dimen/dp_51"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/containerEvent" />
app:layout_constraintTop_toBottomOf="@id/containerEvent" />
<TextView
android:id="@+id/tvPassengerV2XTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_51"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginEnd="@dimen/dp_51"
android:layout_marginBottom="@dimen/dp_33"
android:ellipsize="end"
@@ -76,9 +77,10 @@
android:maxLines="1"
android:textColor="#131415"
android:textSize="@dimen/dp_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/containerLivePlay"
app:layout_constraintTop_toBottomOf="@id/containerLivePlay"
tools:text="更新时间10:38:20" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_v2n_event_live_play"
android:background="@drawable/bg_v2n_event_live_play_passenger"
app:roundLayoutRadius="@dimen/dp_36">
<TextView
@@ -27,7 +27,20 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:src="@drawable/hmi_v2n_event_mogo_logo"
android:src="@drawable/hmi_v2n_event_mogo_logo_passenger"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="gone" />
<ImageView
android:id="@+id/ivLoading"
android:layout_width="@dimen/dp_49"
android:layout_height="@dimen/dp_49"
android:gravity="center"
android:src="@drawable/hmi_v2n_event_video_play_loading_passenger"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@@ -44,4 +57,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -80,7 +80,7 @@
style="?android:attr/progressBarStyleSmall"
android:layout_width="36dp"
android:layout_height="36dp"
android:visibility="gone"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"