mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-25 09:30:32 +00:00
-Fixed view not registered when playback is started on external players.
This commit is contained in:
parent
7fb9345344
commit
b338d9dbcf
@ -56,12 +56,14 @@ import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
|||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||||
|
import org.schabi.newpipe.extractor.stream.Stream;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import org.schabi.newpipe.fragments.BackPressable;
|
import org.schabi.newpipe.fragments.BackPressable;
|
||||||
import org.schabi.newpipe.fragments.BaseStateFragment;
|
import org.schabi.newpipe.fragments.BaseStateFragment;
|
||||||
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
import org.schabi.newpipe.util.StreamItemAdapter;
|
import org.schabi.newpipe.util.StreamItemAdapter;
|
||||||
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
|
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
|
||||||
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
|
||||||
@ -128,7 +130,7 @@ public class VideoDetailFragment
|
|||||||
|
|
||||||
private StreamInfo currentInfo;
|
private StreamInfo currentInfo;
|
||||||
private Disposable currentWorker;
|
private Disposable currentWorker;
|
||||||
private CompositeDisposable disposables = new CompositeDisposable();
|
@NonNull private CompositeDisposable disposables = new CompositeDisposable();
|
||||||
|
|
||||||
private List<VideoStream> sortedVideoStreams;
|
private List<VideoStream> sortedVideoStreams;
|
||||||
private int selectedVideoStreamIndex = -1;
|
private int selectedVideoStreamIndex = -1;
|
||||||
@ -872,10 +874,7 @@ public class VideoDetailFragment
|
|||||||
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
|
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 16) {
|
||||||
openNormalBackgroundPlayer(append);
|
openNormalBackgroundPlayer(append);
|
||||||
} else {
|
} else {
|
||||||
NavigationHelper.playOnExternalPlayer(activity,
|
startOnExternalPlayer(activity, currentInfo, audioStream);
|
||||||
currentInfo.getName(),
|
|
||||||
currentInfo.getUploaderName(),
|
|
||||||
audioStream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,10 +901,7 @@ public class VideoDetailFragment
|
|||||||
|
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(activity)
|
if (PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
|
||||||
NavigationHelper.playOnExternalPlayer(activity,
|
startOnExternalPlayer(activity, currentInfo, selectedVideoStream);
|
||||||
currentInfo.getName(),
|
|
||||||
currentInfo.getUploaderName(),
|
|
||||||
selectedVideoStream);
|
|
||||||
} else {
|
} else {
|
||||||
openNormalPlayer(selectedVideoStream);
|
openNormalPlayer(selectedVideoStream);
|
||||||
}
|
}
|
||||||
@ -949,6 +945,20 @@ public class VideoDetailFragment
|
|||||||
this.autoPlayEnabled = autoplay;
|
this.autoPlayEnabled = autoplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startOnExternalPlayer(@NonNull final Context context,
|
||||||
|
@NonNull final StreamInfo info,
|
||||||
|
@NonNull final Stream selectedStream) {
|
||||||
|
NavigationHelper.playOnExternalPlayer(context, currentInfo.getName(),
|
||||||
|
currentInfo.getUploaderName(), selectedStream);
|
||||||
|
|
||||||
|
final HistoryRecordManager recordManager = new HistoryRecordManager(requireContext());
|
||||||
|
disposables.add(recordManager.onViewed(info).onErrorComplete()
|
||||||
|
.subscribe(
|
||||||
|
ignored -> {/* successful */},
|
||||||
|
error -> Log.e(TAG, "Register view failure: ", error)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private VideoStream getSelectedVideoStream() {
|
private VideoStream getSelectedVideoStream() {
|
||||||
return sortedVideoStreams != null ? sortedVideoStreams.get(selectedVideoStreamIndex) : null;
|
return sortedVideoStreams != null ? sortedVideoStreams.get(selectedVideoStreamIndex) : null;
|
||||||
|
Loading…
Reference in New Issue
Block a user