新增播放定时器,播放后10秒未播放就重新加载播放
This commit is contained in:
parent
1bbab7ac9e
commit
5d7cff6707
@ -46,8 +46,8 @@ public class LiveExoPlayerManager {
|
|||||||
150,
|
150,
|
||||||
200)
|
200)
|
||||||
.build();
|
.build();
|
||||||
player1 = new ExoPlayer.Builder(mContext).build();
|
player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
||||||
player2 = new ExoPlayer.Builder(mContext).build();
|
player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
|
||||||
player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
|
player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
|
||||||
player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
|
player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
|
||||||
|
|
||||||
@ -158,6 +158,7 @@ public class LiveExoPlayerManager {
|
|||||||
mainView.setPlayer(player1);
|
mainView.setPlayer(player1);
|
||||||
status = MODEL_PLAY1;
|
status = MODEL_PLAY1;
|
||||||
isSwitchUrl = false;
|
isSwitchUrl = false;
|
||||||
|
handler.removeCallbacks(buffRunnable);
|
||||||
if (getNextPlayer().isPlaying()) {
|
if (getNextPlayer().isPlaying()) {
|
||||||
getNextPlayer().stop();
|
getNextPlayer().stop();
|
||||||
}
|
}
|
||||||
@ -229,6 +230,7 @@ public class LiveExoPlayerManager {
|
|||||||
if (getNextPlayer().isPlaying()) {
|
if (getNextPlayer().isPlaying()) {
|
||||||
getNextPlayer().stop();
|
getNextPlayer().stop();
|
||||||
}
|
}
|
||||||
|
handler.removeCallbacks(buffRunnable);
|
||||||
isSwitchUrl = false;
|
isSwitchUrl = false;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onIsPlayingChanged(true);
|
listener.onIsPlayingChanged(true);
|
||||||
@ -268,6 +270,7 @@ public class LiveExoPlayerManager {
|
|||||||
public void startUrl(String url) {
|
public void startUrl(String url) {
|
||||||
if (url != null && url.equals(this.url)) return;
|
if (url != null && url.equals(this.url)) return;
|
||||||
Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode());
|
Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode());
|
||||||
|
handler.removeCallbacks(buffRunnable);
|
||||||
this.url = url;
|
this.url = url;
|
||||||
isSwitchUrl = true;
|
isSwitchUrl = true;
|
||||||
playBufferIndex = 0;
|
playBufferIndex = 0;
|
||||||
@ -279,6 +282,7 @@ public class LiveExoPlayerManager {
|
|||||||
getNowPlayer().setMediaItem(createMediaItem(url));
|
getNowPlayer().setMediaItem(createMediaItem(url));
|
||||||
getNowPlayer().prepare();
|
getNowPlayer().prepare();
|
||||||
getNowPlayer().play();
|
getNowPlayer().play();
|
||||||
|
handler.postDelayed(buffRunnable, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -340,6 +344,8 @@ public class LiveExoPlayerManager {
|
|||||||
|
|
||||||
public void replay() {
|
public void replay() {
|
||||||
Log.i(TAG, "replay: 重载播放");
|
Log.i(TAG, "replay: 重载播放");
|
||||||
|
getNowPlayer().stop();
|
||||||
|
getNextPlayer().stop();
|
||||||
String tmp = url;
|
String tmp = url;
|
||||||
url = null;
|
url = null;
|
||||||
startUrl(tmp);
|
startUrl(tmp);
|
||||||
@ -360,8 +366,9 @@ public class LiveExoPlayerManager {
|
|||||||
player1.release();
|
player1.release();
|
||||||
player2.release();
|
player2.release();
|
||||||
}
|
}
|
||||||
public void clearUrl(){
|
|
||||||
url="";
|
public void clearUrl() {
|
||||||
|
url = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
|
Loading…
Reference in New Issue
Block a user