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

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

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