Do not save playback position when watch history is disabled

This commit is contained in:
TobiGr 2019-08-13 14:39:46 +02:00
parent 8de5c53485
commit 5053d470f6
1 changed files with 23 additions and 17 deletions

View File

@ -1049,6 +1049,8 @@ public abstract class BasePlayer implements
private void savePlaybackState(final StreamInfo info, final long progress) {
if (info == null) return;
if (DEBUG) Log.d(TAG, "savePlaybackState() called");
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
final Disposable stateSaver = recordManager.saveStreamState(info, progress)
.observeOn(AndroidSchedulers.mainThread())
.doOnError((e) -> {
@ -1058,9 +1060,12 @@ public abstract class BasePlayer implements
.subscribe();
databaseUpdateReactor.add(stateSaver);
}
}
private void resetPlaybackState(final PlayQueueItem queueItem) {
if (queueItem == null) return;
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
final Disposable stateSaver = queueItem.getStream()
.flatMapCompletable(info -> recordManager.saveStreamState(info, 0))
.observeOn(AndroidSchedulers.mainThread())
@ -1071,6 +1076,7 @@ public abstract class BasePlayer implements
.subscribe();
databaseUpdateReactor.add(stateSaver);
}
}
public void resetPlaybackState(final StreamInfo info) {
savePlaybackState(info, 0);