提交 1279f8dd 编写于 作者: S shuyu

修改对于Audio冲突时候的处理,子类可以复写方法自己自行另外处理

上级 80d982e7
...@@ -339,32 +339,61 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe ...@@ -339,32 +339,61 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
public void onAudioFocusChange(int focusChange) { public void onAudioFocusChange(int focusChange) {
switch (focusChange) { switch (focusChange) {
case AudioManager.AUDIOFOCUS_GAIN: case AudioManager.AUDIOFOCUS_GAIN:
onGankAudio();
break; break;
case AudioManager.AUDIOFOCUS_LOSS: case AudioManager.AUDIOFOCUS_LOSS:
post(new Runnable() { onLossAudio();
@Override
public void run() {
if (mReleaseWhenLossAudio) {
releaseVideos();
} else {
onVideoPause();
}
}
});
break; break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
try { onLossTransientAudio();
onVideoPause();
} catch (Exception e) {
e.printStackTrace();
}
break; break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
onLossTransientCanDuck();
break; break;
} }
} }
}; };
/**
* 获得了Audio Focus
*/
protected void onGankAudio() {
}
/**
* 失去了Audio Focus,并将会持续很长的时间
*/
protected void onLossAudio() {
this.post(new Runnable() {
public void run() {
if (GSYVideoView.this.mReleaseWhenLossAudio) {
GSYVideoView.this.releaseVideos();
} else {
GSYVideoView.this.onVideoPause();
}
}
});
}
/**
* 暂时失去Audio Focus,并会很快再次获得
*/
protected void onLossTransientAudio() {
try {
this.onVideoPause();
} catch (Exception var2) {
var2.printStackTrace();
}
}
/**
* 暂时失去AudioFocus,但是可以继续播放,不过要在降低音量
*/
protected void onLossTransientCanDuck() {
}
/** /**
* 设置播放URL * 设置播放URL
...@@ -1015,7 +1044,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe ...@@ -1015,7 +1044,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
*/ */
public void setSpeedPlaying(float speed, boolean soundTouch) { public void setSpeedPlaying(float speed, boolean soundTouch) {
setSpeed(speed, soundTouch); setSpeed(speed, soundTouch);
getGSYVideoManager().setSpeedPlaying( speed, soundTouch); getGSYVideoManager().setSpeedPlaying(speed, soundTouch);
} }
public boolean isShowPauseCover() { public boolean isShowPauseCover() {
...@@ -1038,7 +1067,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe ...@@ -1038,7 +1067,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
*/ */
public void seekTo(long position) { public void seekTo(long position) {
try { try {
if (getGSYVideoManager()!= null && position > 0) { if (getGSYVideoManager() != null && position > 0) {
getGSYVideoManager().seekTo(position); getGSYVideoManager().seekTo(position);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -1078,6 +1107,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe ...@@ -1078,6 +1107,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
/** /**
* 单独设置mapHeader * 单独设置mapHeader
*
* @param headData * @param headData
*/ */
public void setMapHeadData(Map<String, String> headData) { public void setMapHeadData(Map<String, String> headData) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册