-Fixed popup and main video players not using different quality resolution.

This commit is contained in:
John Zhen Mo 2017-10-22 19:21:19 -07:00
parent 9068247856
commit d0e626c6ee
4 changed files with 25 additions and 16 deletions

View file

@ -47,14 +47,18 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.playlist.PlayQueueItem;
import org.schabi.newpipe.playlist.PlayQueueItemBuilder;
import org.schabi.newpipe.playlist.PlayQueueItemHolder;
import org.schabi.newpipe.util.AnimationUtils;
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ThemeHelper;
import java.util.List;
import static org.schabi.newpipe.util.AnimationUtils.animateView;
/**
@ -316,6 +320,10 @@ public final class MainVideoPlayer extends Activity {
updatePlaybackButtons();
}
/*//////////////////////////////////////////////////////////////////////////
// Player Overrides
//////////////////////////////////////////////////////////////////////////*/
@Override
public void onFullScreenButtonClicked() {
super.onFullScreenButtonClicked();
@ -434,6 +442,11 @@ public final class MainVideoPlayer extends Activity {
shutdown();
}
@Override
protected int getDefaultResolutionIndex(final List<VideoStream> sortedVideos) {
return ListHelper.getDefaultResolutionIndex(context, sortedVideos);
}
/*//////////////////////////////////////////////////////////////////////////
// States
//////////////////////////////////////////////////////////////////////////*/

View file

@ -64,6 +64,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.player.event.PlayerEventListener;
import org.schabi.newpipe.player.old.PlayVideoActivity;
import org.schabi.newpipe.playlist.PlayQueueItem;
@ -72,11 +73,12 @@ import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.Constants;
import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ThemeHelper;
import java.io.IOException;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@ -496,6 +498,11 @@ public final class PopupVideoPlayer extends Service {
updateProgress(currentProgress, duration, bufferPercent);
}
@Override
protected int getDefaultResolutionIndex(final List<VideoStream> sortedVideos) {
return ListHelper.getPopupDefaultResolutionIndex(context, sortedVideos);
}
/*//////////////////////////////////////////////////////////////////////////
// Activity Event Listener
//////////////////////////////////////////////////////////////////////////*/

View file

@ -230,6 +230,8 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
// Playback Listener
//////////////////////////////////////////////////////////////////////////*/
protected abstract int getDefaultResolutionIndex(final List<VideoStream> sortedVideos);
@Override
public void sync(@NonNull final PlayQueueItem item, @Nullable final StreamInfo info) {
super.sync(item, info);
@ -241,7 +243,7 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
availableStreams = new ArrayList<>(videos);
final int qualityIndex = item.getQualityIndex();
if (qualityIndex == PlayQueueItem.DEFAULT_QUALITY) {
selectedStreamIndex = ListHelper.getDefaultResolutionIndex(context, videos);
selectedStreamIndex = getDefaultResolutionIndex(videos);
} else {
selectedStreamIndex = qualityIndex;
}
@ -260,7 +262,7 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
final VideoStream video;
if (sortedStreamsIndex == PlayQueueItem.DEFAULT_QUALITY) {
final int index = ListHelper.getDefaultResolutionIndex(context, videos);
final int index = getDefaultResolutionIndex(videos);
video = videos.get(index);
} else {
video = videos.get(sortedStreamsIndex);