[Update]调整全览模式摄像头直播显示

This commit is contained in:
chenfufeng
2022-07-25 20:51:37 +08:00
parent 7c75757ab0
commit 0c861fd499
41 changed files with 1493 additions and 109 deletions

View File

@@ -32,6 +32,7 @@ import com.mogo.eagle.core.data.constants.MoGoFragmentPaths
import com.mogo.eagle.core.data.enums.SidePattern
import com.mogo.eagle.core.data.enums.SidePattern.*
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.map.Infrastructure
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData
import com.mogo.eagle.core.data.report.ReportEntity
@@ -170,10 +171,10 @@ import java.util.*
}
}
ivCameraIcon?.setOnLongClickListener {
showSmallFragment()
/*ivCameraIcon?.setOnLongClickListener {
activity?.let { it1 -> CarcorderPreviewView.show(it1) }
true
}
}*/
ivToolsIcon?.setOnClickListener {
if (toolsViewFloat == null) {
@@ -310,12 +311,12 @@ import java.util.*
mViewNotificationProvider = provider
}
override fun showVideoDialog(url: String, isFlvUrl: Boolean) {
override fun showVideoDialog(infList: List<Infrastructure>) {
context?.let {
if (roadVideoDialog == null) {
roadVideoDialog = RoadVideoDialog(it)
}
roadVideoDialog?.show(url, isFlvUrl)
roadVideoDialog?.show(infList)
}
}

View File

@@ -1,16 +1,21 @@
package com.mogo.eagle.core.function.hmi.ui.camera
import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.view.View
import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleObserver
import com.mogo.eagle.core.data.map.Infrastructure
import com.mogo.eagle.core.function.call.monitor.CallerMonitorManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.widget.indicator.enums.IndicatorOrientation
import com.mogo.eagle.core.widget.indicator.enums.IndicatorSlideMode
import com.mogo.eagle.core.widget.indicator.enums.IndicatorStyle
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
import com.mogo.module.common.dialog.BaseFloatDialog
import com.shuyu.gsyvideoplayer.GSYVideoManager
@@ -38,6 +43,12 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs
GSYVideoOptionBuilder()
}
private val infList by lazy {
ArrayList<Infrastructure>()
}
private var curPlayIndex = 0
init {
setContentView(R.layout.road_video_dialog)
roadVideoPB.indeterminateDrawable.colorFilter = PorterDuffColorFilter(
@@ -45,7 +56,25 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs
PorterDuff.Mode.MULTIPLY
)
setCanceledOnTouchOutside(false)
roundLayout.setScrollListener { is2Left ->
/**
* 如果画面向左滚动
*/
val calIndex = if (is2Left) {
curPlayIndex - 1
} else {
curPlayIndex + 1
}
// 检查数组越界
if (calIndex >= 0 && calIndex < infList.size) {
curPlayIndex = calIndex
infList[curPlayIndex].ip?.let {
playVideo(it)
}
indicatorView.onPageScrolled(calIndex, 0f, 0)
indicatorView.onPageSelected(calIndex)
}
}
roadVideoClose.setOnClickListener {
dismiss()
}
@@ -53,19 +82,24 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs
initVideoPlayer()
}
fun show(url: String, isFlvUrl: Boolean) {
fun show(data: List<Infrastructure>) {
show()
infList.clear()
infList.addAll(data)
initIndicatorView()
// 打开指定ip的摄像头直播流
infList[0].ip?.let {
playVideo(it)
}
}
private fun playVideo(ip: String) {
roadVideoPB.visibility = View.VISIBLE
if (!isFlvUrl) {
// 打开指定ip的摄像头直播流
CallerMonitorManager.openCameraStream(url, { flvUrl ->
gsyVideoPlay(flvUrl)
}) {
ToastUtils.showShort(it.message)
dismiss()
}
} else {
gsyVideoPlay(url)
CallerMonitorManager.openCameraStream(ip, { flvUrl ->
gsyVideoPlay(flvUrl)
}) {
roadVideoPB.visibility = View.GONE
ToastUtils.showShort(it.message)
}
}
@@ -74,6 +108,20 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs
stopLive()
}
private fun initIndicatorView() {
indicatorView.notifyDataChanged(infList.size)
indicatorView.setSlideMode(IndicatorSlideMode.SCALE)
indicatorView.setOrientation(IndicatorOrientation.INDICATOR_HORIZONTAL)
indicatorView.setIndicatorStyle(IndicatorStyle.ROUND_RECT)
indicatorView.setSliderColor(
Color.parseColor("#FFFFFF"), Color.parseColor("#26C5FD"),
Color.parseColor("#26C5FD")
)
indicatorView.setSliderWidth(9f, 54f)
indicatorView.setSliderHeight(9f)
indicatorView.setSliderGap(36f)
}
private fun initVideoPlayer() {
val list: MutableList<VideoOptionModel> = ArrayList()
list.add(VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "reconnect", 3))

View File

@@ -1,22 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.eagle.core.widget.RoundConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
android:layout_height="wrap_content"
android:minWidth="1736px"
android:minHeight="974px"
app:roundLayoutRadius="30px"
android:background="@drawable/road_video_bg"
tools:ignore="MissingDefaultResource">
android:minHeight="1043px"
tools:ignore="MissingDefaultResource"
>
<com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
android:id="@+id/roadVideoPlayer"
android:layout_width="1736px"
android:layout_height="974px"
android:visibility="visible"
<com.mogo.eagle.core.widget.RoundConstraintLayout
android:id="@+id/roundLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:roundLayoutRadius="30px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/road_video_bg"
android:minWidth="1736px"
android:minHeight="974px"
>
<com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
android:id="@+id/roadVideoPlayer"
android:layout_width="1736px"
android:layout_height="974px"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</com.mogo.eagle.core.widget.RoundConstraintLayout>
<com.mogo.eagle.core.widget.indicator.IndicatorView
android:id="@+id/indicatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:vpi_orientation="horizontal"
app:vpi_slide_mode="scale"
app:vpi_slider_checked_color="@color/hmi_traffic_light_red_color_up"
app:vpi_slider_normal_color="@color/hmi_check_keyboard_input_field"
app:vpi_slider_radius="@dimen/dp_20"
app:vpi_style="round_rect"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/roundLayout"
android:layout_marginTop="60px"
/>
<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/roadVideoPB"
@@ -41,4 +68,4 @@
app:layout_constraintTop_toTopOf="parent"
/>
</com.mogo.eagle.core.widget.RoundConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -7,4 +7,5 @@
<color name="notice_traffic_line">#555C7E</color>
<color name="notice_dialog_back">#3B4577</color>
<color name="acc_default_txt_color">#FF343C63</color>
<color name="hmi_check_keyboard_input_field">#FF282F62</color>
</resources>

View File

@@ -65,4 +65,5 @@
<color name="p_default_txt_color">#FF6E8EC9</color>
<color name="dark_mode_select_txt_color">#FFFFFFFF</color>
<color name="hmi_check_keyboard_input_field">#FF282F62</color>
</resources>