diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt
index 41165b2633..f8eb5d491c 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt
+++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt
@@ -1,32 +1,28 @@
package com.mogo.eagle.core.function.hmi.ui.notice
import android.content.Context
+import android.graphics.Bitmap
import android.text.TextUtils
+import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.function.hmi.R
-import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer
+import com.mogo.eagle.core.widget.media.video.NoticeSimpleVideoPlayer
import com.mogo.module.common.dialog.BaseFloatDialog
+import com.mogo.utils.BitmapHelper
import com.mogo.utils.glide.GlideApp
import com.mogo.utils.logger.Logger
import com.shuyu.gsyvideoplayer.GSYVideoManager
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
-import com.shuyu.gsyvideoplayer.cache.CacheFactory
-import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager
-import com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener
-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 tv.danmaku.ijk.media.player.IjkMediaPlayer
-import java.util.*
+import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack
+import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
/**
- * 点击查看对话框,需要做接口的请求
- *
+ * @brief 点击查看对话框
+ * @author lixiaopeng
*/
class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) {
@@ -35,9 +31,11 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) {
private var pushCheckTitle: TextView? = null
private var pushCheckContent: TextView? = null
private var pushImageView: ImageView? = null
- private var pushVideo: SimpleVideoPlayer? = null
+ private var pushVideo: NoticeSimpleVideoPlayer? = null
private val gsyVideoOptionBuilder = GSYVideoOptionBuilder()
-// private var mLoading: ProgressBar? = null
+ private var playImageView: ImageView? = null
+ private var thumbnailImageView: ImageView? = null
+ private var mVideoUrl: String = ""
init {
setContentView(R.layout.notice_dialog_check_with_accessory)
@@ -47,19 +45,28 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) {
pushCheckContent = findViewById(R.id.module_push_dialog_bottom_title)
pushImageView = findViewById(R.id.notice_image)
pushVideo = findViewById(R.id.notice_video_layout)
-// mLoading = findViewById(R.id.loading)
-// mLoading!!.getIndeterminateDrawable().setColorFilter(ContextCompat.getColor(context, R.color.notice_video_progressbar_loading_color), PorterDuff.Mode.MULTIPLY)
+ playImageView = findViewById(R.id.notice_video_play)
+ thumbnailImageView = findViewById(R.id.thumbnail_image)
pushCheckClose?.setOnClickListener {
+ stopLive()
dismiss()
}
+
+ playImageView!!.setOnClickListener {
+ if (pushVideo!!.currentState == GSYVideoView.CURRENT_STATE_PAUSE) { /*播放中*/
+ resume()
+ } else {
+ pause()
+ }
+ }
+
}
/**
* 展示详情页面
*/
fun showCheckDialog(noticeNormal: NoticeNormalData) {
- Logger.d("liyz", "------1--------")
if (isShowing || noticeNormal == null) {
return
}
@@ -72,18 +79,17 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) {
pushCheckContent?.text = noticeNormal.content
if (!TextUtils.isEmpty(noticeNormal.imageUrl) && noticeNormal.fileType == 1) {
- Logger.d("liyz", "------2--------")
pushVideo?.visibility = View.GONE
pushImageView?.visibility = View.VISIBLE
pushImageView?.let { GlideApp.with(context!!).load(noticeNormal.imageUrl).into(it) }
}
if (!TextUtils.isEmpty(noticeNormal.videoUrl) && noticeNormal.fileType == 2) {
- Logger.d("liyz", "------3--------")
pushImageView?.visibility = View.GONE
pushVideo?.visibility = View.VISIBLE
//加载视频播放
- playLiveVideo(noticeNormal.videoUrl)
+ playVideo(noticeNormal.videoUrl)
+ mVideoUrl = noticeNormal.videoUrl
}
show()
@@ -91,26 +97,19 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) {
/**
- * 播放直播流,且开始心跳
+ * 播放视频
*/
- private fun playLiveVideo(videoUrl: String) {
-// pushVideo?.setPlayListener(object : PlayListener {
-// override fun onPlayEvent(event: Int) {
-// Logger.d("liyz", "event ----- $event")
-// if (event == SimpleVideoPlayer.PLAY_EVT_PLAY_LOADING) {
-//// mLoading!!.visibility = View.VISIBLE
-// } else if (event == SimpleVideoPlayer.PLAY_EVT_PLAY_BEGIN) {
-//// mLoading!!.visibility = View.GONE
-// } else if (event < 0) {
-// stopLive()
-//// mLoading!!.visibility = View.GONE
-// }
-// }
-// })
-
- gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG)
- .build(pushVideo)
- pushVideo!!.startButton.performClick()
+ private fun playVideo(videoUrl: String) {
+ try {
+ gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG)
+ .build(pushVideo)
+ pushVideo!!.startButton.performClick()
+ playImageView!!.visibility = View.GONE
+ thumbnailImageView!!.visibility = View.GONE
+ startVideoCallBack(videoUrl)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
}
fun stopLive() {
@@ -121,7 +120,78 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) {
}
}
- //播放完成的回调 TODO
+ /**
+ * 暂停
+ */
+ private fun pause() {
+ playImageView!!.visibility = View.VISIBLE
+ playImageView!!.setImageResource(R.drawable.notice_video_play)
+ thumbnailImageView!!.visibility = View.GONE
+ }
+
+ /**
+ * 继续
+ */
+ private fun resume() {
+ playImageView!!.visibility = View.VISIBLE
+ playImageView!!.setImageResource(R.drawable.notice_video_pause)
+ thumbnailImageView!!.visibility = View.GONE
+ }
+
+ /**
+ * 播放结束后
+ */
+ private fun complete(firstbitmap: Bitmap, path: String) {
+ thumbnailImageView!!.visibility = View.VISIBLE
+ thumbnailImageView!!.setImageBitmap(firstbitmap)
+ playImageView!!.setImageResource(R.drawable.notice_video_play)
+ playImageView!!.visibility = View.VISIBLE
+ }
+
+ private fun startVideoCallBack(path: String) {
+ Thread(Runnable {
+ val firstBitmap = BitmapHelper.getVideoThumbnail(path) /*获取第一帧图*/
+ pushVideo!!.setVideoAllCallBack(object : VideoAllCallBack {
+ override fun onAutoComplete(url: String, vararg objects: Any) {
+ complete(firstBitmap, path)
+ }
+
+ override fun onClickResume(url: String, vararg objects: Any) {
+ thumbnailImageView!!.visibility = View.GONE
+ playImageView!!.visibility = View.GONE
+ }
+
+ override fun onClickStop(url: String, vararg objects: Any) {
+ Log.d(TAG, "onClickStop")
+ }
+
+ override fun onStartPrepared(url: String, vararg objects: Any) {
+ Log.d(TAG, "onStartPrepared")
+ }
+
+ override fun onPrepared(url: String, vararg objects: Any) {}
+ override fun onClickStartIcon(url: String, vararg objects: Any) {}
+ override fun onClickStartError(url: String, vararg objects: Any) {}
+ override fun onClickStopFullscreen(url: String, vararg objects: Any) {}
+ override fun onClickResumeFullscreen(url: String, vararg objects: Any) {}
+ override fun onClickSeekbar(url: String, vararg objects: Any) {}
+ override fun onClickSeekbarFullscreen(url: String, vararg objects: Any) {}
+ override fun onEnterFullscreen(url: String, vararg objects: Any) {}
+ override fun onQuitFullscreen(url: String, vararg objects: Any) {}
+ override fun onQuitSmallWidget(url: String, vararg objects: Any) {}
+ override fun onEnterSmallWidget(url: String, vararg objects: Any) {}
+ override fun onTouchScreenSeekVolume(url: String, vararg objects: Any) {}
+ override fun onTouchScreenSeekPosition(url: String, vararg objects: Any) {}
+ override fun onTouchScreenSeekLight(url: String, vararg objects: Any) {}
+ override fun onPlayError(url: String, vararg objects: Any) {}
+ override fun onClickStartThumb(url: String, vararg objects: Any) {}
+ override fun onClickBlank(url: String, vararg objects: Any) {}
+ override fun onClickBlankFullscreen(url: String, vararg objects: Any) {
+ Log.d(TAG, "onClickBlankFullscreen")
+ }
+ })
+ }).start()
+ }
}
\ No newline at end of file
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeTrafficDialog.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeTrafficDialog.java
index 91a1e701c0..aeb413d3f1 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeTrafficDialog.java
+++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeTrafficDialog.java
@@ -14,15 +14,11 @@ import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer;
import com.mogo.module.common.dialog.BaseFloatDialog;
-import com.mogo.module.common.view.SpacesItemDecoration;
import com.mogo.utils.BitmapHelper;
-import com.mogo.utils.ResourcesHelper;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
-import java.util.List;
-
/**
* @author liujing
* @description 描述
@@ -109,7 +105,7 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
* 继续
*/
private void resume() {
- playImageView.setImageResource(R.drawable.video_pause);
+ playImageView.setImageResource(R.drawable.notice_video_pause);
playImageView.setVisibility(View.GONE);
thumbnailImage.setVisibility(View.GONE);
}
@@ -120,7 +116,7 @@ public class NoticeTrafficDialog extends BaseFloatDialog {
private void complete(Bitmap firstbitmap, String path) {
thumbnailImage.setVisibility(View.VISIBLE);
thumbnailImage.setImageBitmap(firstbitmap);
- playImageView.setImageResource(R.drawable.video_play);
+ playImageView.setImageResource(R.drawable.notice_video_play);
playImageView.setVisibility(View.VISIBLE);
playImageView.setOnClickListener(v -> {
startLive();
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/notice_dialog_check_with_accessory.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/notice_dialog_check_with_accessory.xml
index 4e1d752dc2..53afa2df29 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/notice_dialog_check_with_accessory.xml
+++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/notice_dialog_check_with_accessory.xml
@@ -38,6 +38,7 @@
android:layout_marginLeft="@dimen/dp_150"
android:layout_marginRight="@dimen/dp_150"
android:layout_marginBottom="@dimen/dp_56"
+ android:layout_marginTop="@dimen/dp_6"
android:ellipsize="end"
android:gravity="left"
android:maxLines="2"
@@ -63,7 +64,7 @@
app:layout_constraintTop_toBottomOf="@+id/module_push_dialog_acc_title" />
-
-
+
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
+
+ android:src="@drawable/video_play"
+ android:visibility="gone" />
+ start.setImageResource(R.drawable.notice_video_pause)
+ GSYVideoView.CURRENT_STATE_ERROR ->
+ start.setImageResource(R.drawable.notice_video_pause)
+ else -> start.setImageResource(R.drawable.notice_video_play)
+ }
+ }
+
+ override fun setProgressAndTime(
+ progress: Int,
+ secProgress: Int,
+ currentTime: Int,
+ totalTime: Int,
+ forceChange: Boolean
+ ) {
+ super.setProgressAndTime(progress, secProgress, currentTime, totalTime, forceChange)
+ mBottomContainer?.visibility = View.VISIBLE
+ mProgressBar?.visibility = View.VISIBLE
+ start?.visibility = View.VISIBLE
+ fullscreen?.visibility = View.GONE
+ //时间显示
+ currentTimeTextView?.text = TimeTransformUtils.stringForTime(currentTime)
+ totalTimeTextView?.text = TimeTransformUtils.stringForTime(totalTime)
+
+ if (progress != 0) {
+ mProgressBar?.progress = progress
+ }
+ }
+
+ fun setPlayListener(listener: PlayListener) {
+ this.playListener = listener
+ }
+
+ override fun changeUiToCompleteShow() {
+ super.changeUiToCompleteShow()
+ Log.d("liyz", "changeUiToCompleteShow ------> ")
+ mBottomContainer?.visibility = View.INVISIBLE
+ mProgressBar?.visibility = View.GONE
+ }
+
+ override fun hideAllWidget() {
+ super.hideAllWidget()
+ Log.d("liyz", "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
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_player_ic_circle_nor.png b/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_player_ic_circle_nor.png
new file mode 100644
index 0000000000..e34e824da6
Binary files /dev/null and b/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_player_ic_circle_nor.png differ
diff --git a/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_video_pause.png b/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_video_pause.png
new file mode 100644
index 0000000000..dde6a5c994
Binary files /dev/null and b/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_video_pause.png differ
diff --git a/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_video_play.png b/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_video_play.png
new file mode 100644
index 0000000000..4c733621b6
Binary files /dev/null and b/core/mogo-core-res/src/main/res/drawable-xhdpi/notice_video_play.png differ
diff --git a/core/mogo-core-res/src/main/res/drawable/notice_video_pause.png b/core/mogo-core-res/src/main/res/drawable/notice_video_pause.png
new file mode 100644
index 0000000000..2bc83b4e41
Binary files /dev/null and b/core/mogo-core-res/src/main/res/drawable/notice_video_pause.png differ
diff --git a/core/mogo-core-res/src/main/res/drawable/notice_video_play.png b/core/mogo-core-res/src/main/res/drawable/notice_video_play.png
new file mode 100644
index 0000000000..4c733621b6
Binary files /dev/null and b/core/mogo-core-res/src/main/res/drawable/notice_video_play.png differ
diff --git a/core/mogo-core-res/src/main/res/drawable/seekbar_style.xml b/core/mogo-core-res/src/main/res/drawable/seekbar_style.xml
new file mode 100644
index 0000000000..5fbe3746a6
--- /dev/null
+++ b/core/mogo-core-res/src/main/res/drawable/seekbar_style.xml
@@ -0,0 +1,27 @@
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/mogo-core-res/src/main/res/layout/item_notice_video.xml b/core/mogo-core-res/src/main/res/layout/item_notice_video.xml
new file mode 100644
index 0000000000..41b1cf8ec9
--- /dev/null
+++ b/core/mogo-core-res/src/main/res/layout/item_notice_video.xml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/TimeTransformUtils.java b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/TimeTransformUtils.java
new file mode 100644
index 0000000000..6c2848c71a
--- /dev/null
+++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/TimeTransformUtils.java
@@ -0,0 +1,30 @@
+package com.mogo.eagle.core.utilcode.util;
+
+import java.util.Formatter;
+import java.util.Locale;
+
+/**
+ * author: lixiaopeng
+ * desc : 时间转换
+ */
+public final class TimeTransformUtils {
+
+ public static String stringForTime(int timeMs) {
+ if (timeMs <= 0 || timeMs >= 24 * 60 * 60 * 1000) {
+ return "00:00";
+ }
+ int totalSeconds = timeMs / 1000;
+ int seconds = totalSeconds % 60;
+ int minutes = (totalSeconds / 60) % 60;
+ int hours = totalSeconds / 3600;
+ StringBuilder stringBuilder = new StringBuilder();
+ Formatter mFormatter = new Formatter(stringBuilder, Locale.getDefault());
+ if (hours > 0) {
+ return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
+ } else {
+ return mFormatter.format("%02d:%02d", minutes, seconds).toString();
+ }
+ }
+
+
+}