[6.8.4]
[fix] [道路事件和广告视频冲突]
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
package com.mogo.och.common.module.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoBaseManager;
|
||||
import com.shuyu.gsyvideoplayer.player.IPlayerManager;
|
||||
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager;
|
||||
import com.shuyu.gsyvideoplayer.utils.CommonUtil;
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer;
|
||||
import com.mogo.och.common.module.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.shuyu.gsyvideoplayer.utils.CommonUtil.hideNavKey;
|
||||
|
||||
/**
|
||||
* 多个播放的管理器
|
||||
* Created by guoshuyu on 2018/1/31.
|
||||
*/
|
||||
|
||||
public class CustomManager extends GSYVideoBaseManager {
|
||||
|
||||
public static final int SMALL_ID = R.id.custom_small_id;
|
||||
|
||||
public static final int FULLSCREEN_ID = R.id.custom_full_id;
|
||||
|
||||
public static String TAG = "GSYVideoManager";
|
||||
|
||||
private static Map<String, CustomManager> sMap = new HashMap<>();
|
||||
|
||||
|
||||
public CustomManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPlayerManager getPlayManager() {
|
||||
return new IjkPlayerManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出全屏,主要用于返回键
|
||||
*
|
||||
* @return 返回是否全屏
|
||||
*/
|
||||
@SuppressWarnings("ResourceType")
|
||||
public static boolean backFromWindowFull(Context context, String key) {
|
||||
boolean backFrom = false;
|
||||
ViewGroup vp = (ViewGroup) (CommonUtil.scanForActivity(context)).findViewById(Window.ID_ANDROID_CONTENT);
|
||||
View oldF = vp.findViewById(FULLSCREEN_ID);
|
||||
if (oldF != null) {
|
||||
backFrom = true;
|
||||
hideNavKey(context);
|
||||
if (getCustomManager(key).lastListener() != null) {
|
||||
getCustomManager(key).lastListener().onBackFullscreen();
|
||||
}
|
||||
}
|
||||
return backFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面销毁了记得调用是否所有的video
|
||||
*/
|
||||
public static void releaseAllVideos(String key) {
|
||||
if (getCustomManager(key).listener() != null) {
|
||||
getCustomManager(key).listener().onCompletion();
|
||||
}
|
||||
getCustomManager(key).releaseMediaPlayer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂停播放
|
||||
*/
|
||||
public void onPause(String key) {
|
||||
if (getCustomManager(key).listener() != null) {
|
||||
getCustomManager(key).listener().onVideoPause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复播放
|
||||
*/
|
||||
public void onResume(String key) {
|
||||
if (getCustomManager(key).listener() != null) {
|
||||
getCustomManager(key).listener().onVideoResume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 恢复暂停状态
|
||||
*
|
||||
* @param seek 是否产生seek动作,直播设置为false
|
||||
*/
|
||||
public void onResume(String key, boolean seek) {
|
||||
if (getCustomManager(key).listener() != null) {
|
||||
getCustomManager(key).listener().onVideoResume(seek);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 单例管理器
|
||||
*/
|
||||
public static synchronized Map<String, CustomManager> instance() {
|
||||
return sMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单例管理器
|
||||
*/
|
||||
public static synchronized CustomManager getCustomManager(String key) {
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
throw new IllegalStateException("key not be empty");
|
||||
}
|
||||
CustomManager customManager = sMap.get(key);
|
||||
if (customManager == null) {
|
||||
customManager = new CustomManager();
|
||||
sMap.put(key, customManager);
|
||||
}
|
||||
return customManager;
|
||||
}
|
||||
|
||||
public static void onPauseAll() {
|
||||
if (sMap.size() > 0) {
|
||||
for (Map.Entry<String, CustomManager> header : sMap.entrySet()) {
|
||||
header.getValue().onPause(header.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void onResumeAll() {
|
||||
if (sMap.size() > 0) {
|
||||
for (Map.Entry<String, CustomManager> header : sMap.entrySet()) {
|
||||
header.getValue().onResume(header.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复暂停状态
|
||||
*
|
||||
* @param seek 是否产生seek动作
|
||||
*/
|
||||
public static void onResumeAll(boolean seek) {
|
||||
if (sMap.size() > 0) {
|
||||
for (Map.Entry<String, CustomManager> header : sMap.entrySet()) {
|
||||
header.getValue().onResume(header.getKey(), seek);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAllVideo() {
|
||||
if (sMap.size() > 0) {
|
||||
for (Map.Entry<String, CustomManager> header : sMap.entrySet()) {
|
||||
CustomManager.releaseAllVideos(header.getKey());
|
||||
}
|
||||
}
|
||||
sMap.clear();
|
||||
}
|
||||
|
||||
public static void removeManager(String key) {
|
||||
sMap.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前是否全屏状态
|
||||
*
|
||||
* @return 当前是否全屏状态, true代表是。
|
||||
*/
|
||||
@SuppressWarnings("ResourceType")
|
||||
public static boolean isFullState(Activity activity) {
|
||||
ViewGroup vp = (ViewGroup) (CommonUtil.scanForActivity(activity)).findViewById(Window.ID_ANDROID_CONTENT);
|
||||
final View full = vp.findViewById(FULLSCREEN_ID);
|
||||
GSYVideoPlayer gsyVideoPlayer = null;
|
||||
if (full != null) {
|
||||
gsyVideoPlayer = (GSYVideoPlayer) full;
|
||||
}
|
||||
return gsyVideoPlayer != null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import android.content.Context
|
||||
import android.media.AudioManager
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
@@ -13,6 +14,7 @@ import com.mogo.eagle.core.utilcode.util.FileUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import com.mogo.och.common.module.utils.CustomManager
|
||||
import com.mogo.och.common.module.R
|
||||
import com.mogo.och.common.module.wigets.media.MediaFileCacheManager
|
||||
import com.mogo.och.common.module.wigets.media.MediaItem
|
||||
@@ -22,8 +24,10 @@ import com.mogo.skin.utils.SkinResources
|
||||
import com.mogo.skin.widget.SkinImageView
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
|
||||
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
|
||||
import com.shuyu.gsyvideoplayer.utils.Debuger
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import java.io.File
|
||||
|
||||
@@ -250,6 +254,49 @@ class AdvanceGSYVideoPlayer : StandardGSYVideoPlayer {
|
||||
GSYVideoType.setRenderType(GSYVideoType.GLSURFACE)
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
onAudioFocusChangeListener =
|
||||
AudioManager.OnAudioFocusChangeListener { focusChange ->
|
||||
when (focusChange) {
|
||||
AudioManager.AUDIOFOCUS_GAIN -> {}
|
||||
AudioManager.AUDIOFOCUS_LOSS -> {
|
||||
//todo 判断如果不是外界造成的就不处理
|
||||
}
|
||||
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
|
||||
//todo 判断如果不是外界造成的就不处理
|
||||
}
|
||||
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getGSYVideoManager(): GSYVideoViewBridge {
|
||||
CustomManager.getCustomManager(getKey()).initContext(getContext().getApplicationContext());
|
||||
return CustomManager.getCustomManager(getKey());
|
||||
}
|
||||
|
||||
override fun releaseVideos() {
|
||||
CustomManager.releaseAllVideos(getKey())
|
||||
}
|
||||
|
||||
override fun backFromFull(context: Context?): Boolean {
|
||||
return CustomManager.backFromWindowFull(context, getKey())
|
||||
}
|
||||
|
||||
fun getKey(): String {
|
||||
if (mPlayPosition == -22) {
|
||||
Debuger.printfError(javaClass.simpleName + " used getKey() " + "******* PlayPosition never set. ********")
|
||||
}
|
||||
if (TextUtils.isEmpty(mPlayTag)) {
|
||||
Debuger.printfError(javaClass.simpleName + " used getKey() " + "******* PlayTag never set. ********")
|
||||
}
|
||||
Logger.d("MediaLoopPlayView", "key ${(MediaLoopPlayView.TAG + mPlayPosition).toString() + mPlayTag}")
|
||||
return (MediaLoopPlayView.TAG + mPlayPosition).toString() + mPlayTag
|
||||
}
|
||||
|
||||
override fun hideAllWidget() {
|
||||
Logger.d(MediaLoopPlayView.TAG, "AdvanceGSYVideoPlayer,hideAllWidget")
|
||||
}
|
||||
|
||||
5
OCH/common/common/src/main/res/values/ids.xml
Normal file
5
OCH/common/common/src/main/res/values/ids.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="custom_full_id" type="id" />
|
||||
<item name="custom_small_id" type="id" />
|
||||
</resources>
|
||||
Reference in New Issue
Block a user