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,27 +1049,33 @@ public abstract class BasePlayer implements
private void savePlaybackState(final StreamInfo info, final long progress) { private void savePlaybackState(final StreamInfo info, final long progress) {
if (info == null) return; if (info == null) return;
if (DEBUG) Log.d(TAG, "savePlaybackState() called"); if (DEBUG) Log.d(TAG, "savePlaybackState() called");
final Disposable stateSaver = recordManager.saveStreamState(info, progress) final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
.observeOn(AndroidSchedulers.mainThread()) if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
.doOnError((e) -> { final Disposable stateSaver = recordManager.saveStreamState(info, progress)
if (DEBUG) e.printStackTrace(); .observeOn(AndroidSchedulers.mainThread())
}) .doOnError((e) -> {
.onErrorComplete() if (DEBUG) e.printStackTrace();
.subscribe(); })
databaseUpdateReactor.add(stateSaver); .onErrorComplete()
.subscribe();
databaseUpdateReactor.add(stateSaver);
}
} }
private void resetPlaybackState(final PlayQueueItem queueItem) { private void resetPlaybackState(final PlayQueueItem queueItem) {
if (queueItem == null) return; if (queueItem == null) return;
final Disposable stateSaver = queueItem.getStream() final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
.flatMapCompletable(info -> recordManager.saveStreamState(info, 0)) if (prefs.getBoolean(context.getString(R.string.enable_watch_history_key), true)) {
.observeOn(AndroidSchedulers.mainThread()) final Disposable stateSaver = queueItem.getStream()
.doOnError((e) -> { .flatMapCompletable(info -> recordManager.saveStreamState(info, 0))
if (DEBUG) e.printStackTrace(); .observeOn(AndroidSchedulers.mainThread())
}) .doOnError((e) -> {
.onErrorComplete() if (DEBUG) e.printStackTrace();
.subscribe(); })
databaseUpdateReactor.add(stateSaver); .onErrorComplete()
.subscribe();
databaseUpdateReactor.add(stateSaver);
}
} }
public void resetPlaybackState(final StreamInfo info) { public void resetPlaybackState(final StreamInfo info) {