Disabled preloading when switching streams
This commit is contained in:
parent
a801d0994f
commit
31814b70da
|
@ -958,6 +958,9 @@ public class VideoDetailFragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setInitialData(sid, videoUrl, title, queue);
|
setInitialData(sid, videoUrl, title, queue);
|
||||||
|
if (player != null) {
|
||||||
|
player.disablePreloadingOfCurrentTrack();
|
||||||
|
}
|
||||||
startLoading(false, true);
|
startLoading(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1410,6 +1410,11 @@ public abstract class BasePlayer implements
|
||||||
return currentMetadata;
|
return currentMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public LoadController getLoadController() {
|
||||||
|
return (LoadController) loadControl;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public String getVideoUrl() {
|
public String getVideoUrl() {
|
||||||
return currentMetadata == null
|
return currentMetadata == null
|
||||||
|
|
|
@ -1484,6 +1484,10 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disablePreloadingOfCurrentTrack() {
|
||||||
|
getLoadController().disablePreloadingOfCurrentTrack();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Measures width and height of controls visible on screen.
|
* Measures width and height of controls visible on screen.
|
||||||
* It ensures that controls will be side-by-side with NavigationBar and notches
|
* It ensures that controls will be side-by-side with NavigationBar and notches
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class LoadController implements LoadControl {
|
||||||
|
|
||||||
private final long initialPlaybackBufferUs;
|
private final long initialPlaybackBufferUs;
|
||||||
private final LoadControl internalLoadControl;
|
private final LoadControl internalLoadControl;
|
||||||
|
private boolean preloadingEnabled = true;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Default Load Control
|
// Default Load Control
|
||||||
|
@ -41,6 +42,7 @@ public class LoadController implements LoadControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepared() {
|
public void onPrepared() {
|
||||||
|
preloadingEnabled = true;
|
||||||
internalLoadControl.onPrepared();
|
internalLoadControl.onPrepared();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +54,13 @@ public class LoadController implements LoadControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopped() {
|
public void onStopped() {
|
||||||
|
preloadingEnabled = true;
|
||||||
internalLoadControl.onStopped();
|
internalLoadControl.onStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReleased() {
|
public void onReleased() {
|
||||||
|
preloadingEnabled = true;
|
||||||
internalLoadControl.onReleased();
|
internalLoadControl.onReleased();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +82,9 @@ public class LoadController implements LoadControl {
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldContinueLoading(final long bufferedDurationUs,
|
public boolean shouldContinueLoading(final long bufferedDurationUs,
|
||||||
final float playbackSpeed) {
|
final float playbackSpeed) {
|
||||||
|
if (!preloadingEnabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return internalLoadControl.shouldContinueLoading(bufferedDurationUs, playbackSpeed);
|
return internalLoadControl.shouldContinueLoading(bufferedDurationUs, playbackSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,4 +97,8 @@ public class LoadController implements LoadControl {
|
||||||
.shouldStartPlayback(bufferedDurationUs, playbackSpeed, rebuffering);
|
.shouldStartPlayback(bufferedDurationUs, playbackSpeed, rebuffering);
|
||||||
return isInitialPlaybackBufferFilled || isInternalStartingPlayback;
|
return isInitialPlaybackBufferFilled || isInternalStartingPlayback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disablePreloadingOfCurrentTrack() {
|
||||||
|
preloadingEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue