Skip to content
Snippets Groups Projects
Commit f224cd1c authored by Kelvin's avatar Kelvin
Browse files

Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay

parents d433d6e7 90de54ac
No related branches found
No related tags found
No related merge requests found
...@@ -150,7 +150,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout { ...@@ -150,7 +150,7 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
Logger.v(TAG, "Attached onConnectionAvailable listener."); Logger.v(TAG, "Attached onConnectionAvailable listener.");
StateApp.instance.onConnectionAvailable.subscribe(_referenceObject) { StateApp.instance.onConnectionAvailable.subscribe(_referenceObject) {
Logger.v(TAG, "onConnectionAvailable"); Logger.v(TAG, "onConnectionAvailable connectivityLossTime = $_connectivityLossTime_ms, position = $position, duration = $duration");
val pos = position; val pos = position;
val dur = duration; val dur = duration;
...@@ -158,25 +158,37 @@ abstract class FutoVideoPlayerBase : RelativeLayout { ...@@ -158,25 +158,37 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
if (_shouldPlaybackRestartOnConnectivity && abs(pos - dur) > 2000) { if (_shouldPlaybackRestartOnConnectivity && abs(pos - dur) > 2000) {
if (Settings.instance.playback.restartPlaybackAfterConnectivityLoss == 1) { if (Settings.instance.playback.restartPlaybackAfterConnectivityLoss == 1) {
val lossTime_ms = _connectivityLossTime_ms val lossTime_ms = _connectivityLossTime_ms
if (lossTime_ms != null && System.currentTimeMillis() - lossTime_ms < 1000 * 30) { if (lossTime_ms != null) {
shouldRestartPlayback = true val lossDuration_ms = System.currentTimeMillis() - lossTime_ms
Logger.v(TAG, "onConnectionAvailable lossDuration=$lossDuration_ms")
if (lossDuration_ms < 1000 * 10) {
shouldRestartPlayback = true
}
} }
} else if (Settings.instance.playback.restartPlaybackAfterConnectivityLoss == 2) { } else if (Settings.instance.playback.restartPlaybackAfterConnectivityLoss == 2) {
val lossTime_ms = _connectivityLossTime_ms val lossTime_ms = _connectivityLossTime_ms
if (lossTime_ms != null && System.currentTimeMillis() - lossTime_ms < 1000 * 10) { if (lossTime_ms != null) {
shouldRestartPlayback = true val lossDuration_ms = System.currentTimeMillis() - lossTime_ms
Logger.v(TAG, "onConnectionAvailable lossDuration=$lossDuration_ms")
if (lossDuration_ms < 1000 * 30) {
shouldRestartPlayback = true
}
} }
} else if (Settings.instance.playback.restartPlaybackAfterConnectivityLoss == 3) { } else if (Settings.instance.playback.restartPlaybackAfterConnectivityLoss == 3) {
shouldRestartPlayback = true shouldRestartPlayback = true
} }
} }
Logger.v(TAG, "onConnectionAvailable shouldRestartPlayback = $shouldRestartPlayback");
if (shouldRestartPlayback) { if (shouldRestartPlayback) {
Logger.i(TAG, "Playback ended due to connection loss, resuming playback since connection is restored."); Logger.i(TAG, "Playback ended due to connection loss, resuming playback since connection is restored.");
exoPlayer?.player?.playWhenReady = true; exoPlayer?.player?.playWhenReady = true;
exoPlayer?.player?.prepare(); exoPlayer?.player?.prepare();
exoPlayer?.player?.play(); exoPlayer?.player?.play();
} }
_connectivityLossTime_ms = null;
}; };
} }
...@@ -524,6 +536,8 @@ abstract class FutoVideoPlayerBase : RelativeLayout { ...@@ -524,6 +536,8 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
} }
protected open fun onPlayerError(error: PlaybackException) { protected open fun onPlayerError(error: PlaybackException) {
Logger.i(TAG, "onPlayerError error=$error error.errorCode=${error.errorCode} connectivityLoss");
when (error.errorCode) { when (error.errorCode) {
PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS -> { PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS -> {
onDatasourceError.emit(error); onDatasourceError.emit(error);
...@@ -536,9 +550,9 @@ abstract class FutoVideoPlayerBase : RelativeLayout { ...@@ -536,9 +550,9 @@ abstract class FutoVideoPlayerBase : RelativeLayout {
//PlaybackException.ERROR_CODE_IO_NO_PERMISSION, //PlaybackException.ERROR_CODE_IO_NO_PERMISSION,
//PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE, //PlaybackException.ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE,
PlaybackException.ERROR_CODE_IO_UNSPECIFIED -> { PlaybackException.ERROR_CODE_IO_UNSPECIFIED -> {
Logger.i(TAG, "IO error, set _shouldPlaybackRestartOnConnectivity=true");
_shouldPlaybackRestartOnConnectivity = true; _shouldPlaybackRestartOnConnectivity = true;
_connectivityLossTime_ms = System.currentTimeMillis() _connectivityLossTime_ms = System.currentTimeMillis()
Logger.i(TAG, "IO error, set _shouldPlaybackRestartOnConnectivity=true _connectivityLossTime_ms=$_connectivityLossTime_ms");
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment