Update to ExoPlayer 2.13.2
This commit is contained in:
parent
00fbfb5a56
commit
83d16932a4
|
@ -100,7 +100,7 @@ ext {
|
||||||
checkstyleVersion = '8.38'
|
checkstyleVersion = '8.38'
|
||||||
stethoVersion = '1.5.1'
|
stethoVersion = '1.5.1'
|
||||||
leakCanaryVersion = '2.5'
|
leakCanaryVersion = '2.5'
|
||||||
exoPlayerVersion = '2.12.3'
|
exoPlayerVersion = '2.13.2'
|
||||||
androidxLifecycleVersion = '2.2.0'
|
androidxLifecycleVersion = '2.2.0'
|
||||||
androidxRoomVersion = '2.3.0-alpha03'
|
androidxRoomVersion = '2.3.0-alpha03'
|
||||||
groupieVersion = '2.8.1'
|
groupieVersion = '2.8.1'
|
||||||
|
|
|
@ -489,10 +489,7 @@ public final class Player implements
|
||||||
simpleExoPlayer.addTextOutput(binding.subtitleView);
|
simpleExoPlayer.addTextOutput(binding.subtitleView);
|
||||||
|
|
||||||
// Setup audio session with onboard equalizer
|
// Setup audio session with onboard equalizer
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
trackSelector.setParameters(trackSelector.buildUponParameters().setTunnelingEnabled(true));
|
||||||
trackSelector.setParameters(trackSelector.buildUponParameters()
|
|
||||||
.setTunnelingAudioSessionId(C.generateAudioSessionIdV21(context)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initListeners() {
|
private void initListeners() {
|
||||||
|
@ -624,10 +621,10 @@ public final class Player implements
|
||||||
&& newQueue.getItem().getUrl().equals(playQueue.getItem().getUrl())
|
&& newQueue.getItem().getUrl().equals(playQueue.getItem().getUrl())
|
||||||
&& newQueue.getItem().getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) {
|
&& newQueue.getItem().getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET) {
|
||||||
// Player can have state = IDLE when playback is stopped or failed
|
// Player can have state = IDLE when playback is stopped or failed
|
||||||
// and we should retry() in this case
|
// and we should retry in this case
|
||||||
if (simpleExoPlayer.getPlaybackState()
|
if (simpleExoPlayer.getPlaybackState()
|
||||||
== com.google.android.exoplayer2.Player.STATE_IDLE) {
|
== com.google.android.exoplayer2.Player.STATE_IDLE) {
|
||||||
simpleExoPlayer.retry();
|
simpleExoPlayer.prepare();
|
||||||
}
|
}
|
||||||
simpleExoPlayer.seekTo(playQueue.getIndex(), newQueue.getItem().getRecoveryPosition());
|
simpleExoPlayer.seekTo(playQueue.getIndex(), newQueue.getItem().getRecoveryPosition());
|
||||||
simpleExoPlayer.setPlayWhenReady(playWhenReady);
|
simpleExoPlayer.setPlayWhenReady(playWhenReady);
|
||||||
|
@ -638,10 +635,10 @@ public final class Player implements
|
||||||
&& !playQueue.isDisposed()) {
|
&& !playQueue.isDisposed()) {
|
||||||
// Do not re-init the same PlayQueue. Save time
|
// Do not re-init the same PlayQueue. Save time
|
||||||
// Player can have state = IDLE when playback is stopped or failed
|
// Player can have state = IDLE when playback is stopped or failed
|
||||||
// and we should retry() in this case
|
// and we should retry in this case
|
||||||
if (simpleExoPlayer.getPlaybackState()
|
if (simpleExoPlayer.getPlaybackState()
|
||||||
== com.google.android.exoplayer2.Player.STATE_IDLE) {
|
== com.google.android.exoplayer2.Player.STATE_IDLE) {
|
||||||
simpleExoPlayer.retry();
|
simpleExoPlayer.prepare();
|
||||||
}
|
}
|
||||||
simpleExoPlayer.setPlayWhenReady(playWhenReady);
|
simpleExoPlayer.setPlayWhenReady(playWhenReady);
|
||||||
|
|
||||||
|
@ -1649,7 +1646,7 @@ public final class Player implements
|
||||||
|
|
||||||
saveWasPlaying();
|
saveWasPlaying();
|
||||||
if (isPlaying()) {
|
if (isPlaying()) {
|
||||||
simpleExoPlayer.setPlayWhenReady(false);
|
simpleExoPlayer.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
showControls(0);
|
showControls(0);
|
||||||
|
@ -1665,7 +1662,7 @@ public final class Player implements
|
||||||
|
|
||||||
seekTo(seekBar.getProgress());
|
seekTo(seekBar.getProgress());
|
||||||
if (wasPlaying || simpleExoPlayer.getDuration() == seekBar.getProgress()) {
|
if (wasPlaying || simpleExoPlayer.getDuration() == seekBar.getProgress()) {
|
||||||
simpleExoPlayer.setPlayWhenReady(true);
|
simpleExoPlayer.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.playbackCurrentTime.setText(getTimeString(seekBar.getProgress()));
|
binding.playbackCurrentTime.setText(getTimeString(seekBar.getProgress()));
|
||||||
|
@ -1908,7 +1905,7 @@ public final class Player implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // exoplayer listener
|
@Override // exoplayer listener
|
||||||
public void onLoadingChanged(final boolean isLoading) {
|
public void onIsLoadingChanged(final boolean isLoading) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "ExoPlayer - onLoadingChanged() called with: "
|
Log.d(TAG, "ExoPlayer - onLoadingChanged() called with: "
|
||||||
+ "isLoading = [" + isLoading + "]");
|
+ "isLoading = [" + isLoading + "]");
|
||||||
|
@ -1952,7 +1949,8 @@ public final class Player implements
|
||||||
if (currentState == STATE_BLOCKED) {
|
if (currentState == STATE_BLOCKED) {
|
||||||
changeState(STATE_BUFFERING);
|
changeState(STATE_BUFFERING);
|
||||||
}
|
}
|
||||||
simpleExoPlayer.prepare(mediaSource);
|
simpleExoPlayer.setMediaSource(mediaSource);
|
||||||
|
simpleExoPlayer.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeState(final int state) {
|
public void changeState(final int state) {
|
||||||
|
@ -2351,6 +2349,12 @@ public final class Player implements
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DISCONTINUITY_REASON_SEEK:
|
case DISCONTINUITY_REASON_SEEK:
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "ExoPlayer - onSeekProcessed() called");
|
||||||
|
}
|
||||||
|
if (isPrepared) {
|
||||||
|
saveStreamProgressState();
|
||||||
|
}
|
||||||
case DISCONTINUITY_REASON_SEEK_ADJUSTMENT:
|
case DISCONTINUITY_REASON_SEEK_ADJUSTMENT:
|
||||||
case DISCONTINUITY_REASON_INTERNAL:
|
case DISCONTINUITY_REASON_INTERNAL:
|
||||||
if (playQueue.getIndex() != newWindowIndex) {
|
if (playQueue.getIndex() != newWindowIndex) {
|
||||||
|
@ -2415,10 +2419,8 @@ public final class Player implements
|
||||||
setRecovery();
|
setRecovery();
|
||||||
reloadPlayQueueManager();
|
reloadPlayQueueManager();
|
||||||
break;
|
break;
|
||||||
case ExoPlaybackException.TYPE_OUT_OF_MEMORY:
|
|
||||||
case ExoPlaybackException.TYPE_REMOTE:
|
case ExoPlaybackException.TYPE_REMOTE:
|
||||||
case ExoPlaybackException.TYPE_RENDERER:
|
case ExoPlaybackException.TYPE_RENDERER:
|
||||||
case ExoPlaybackException.TYPE_TIMEOUT:
|
|
||||||
default:
|
default:
|
||||||
showUnrecoverableError(error);
|
showUnrecoverableError(error);
|
||||||
onPlaybackShutdown();
|
onPlaybackShutdown();
|
||||||
|
@ -2623,16 +2625,6 @@ public final class Player implements
|
||||||
simpleExoPlayer.seekToDefaultPosition();
|
simpleExoPlayer.seekToDefaultPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // exoplayer override
|
|
||||||
public void onSeekProcessed() {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "ExoPlayer - onSeekProcessed() called");
|
|
||||||
}
|
|
||||||
if (isPrepared) {
|
|
||||||
saveStreamProgressState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
@ -2660,7 +2652,7 @@ public final class Player implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleExoPlayer.setPlayWhenReady(true);
|
simpleExoPlayer.play();
|
||||||
saveStreamProgressState();
|
saveStreamProgressState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2673,7 +2665,7 @@ public final class Player implements
|
||||||
}
|
}
|
||||||
|
|
||||||
audioReactor.abandonAudioFocus();
|
audioReactor.abandonAudioFocus();
|
||||||
simpleExoPlayer.setPlayWhenReady(false);
|
simpleExoPlayer.pause();
|
||||||
saveStreamProgressState();
|
saveStreamProgressState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,13 +103,13 @@ public class AudioReactor implements AudioManager.OnAudioFocusChangeListener, An
|
||||||
animateAudio(DUCK_AUDIO_TO, 1.0f);
|
animateAudio(DUCK_AUDIO_TO, 1.0f);
|
||||||
|
|
||||||
if (PlayerHelper.isResumeAfterAudioFocusGain(context)) {
|
if (PlayerHelper.isResumeAfterAudioFocusGain(context)) {
|
||||||
player.setPlayWhenReady(true);
|
player.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAudioFocusLoss() {
|
private void onAudioFocusLoss() {
|
||||||
Log.d(TAG, "onAudioFocusLoss() called");
|
Log.d(TAG, "onAudioFocusLoss() called");
|
||||||
player.setPlayWhenReady(false);
|
player.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAudioFocusLossCanDuck() {
|
private void onAudioFocusLossCanDuck() {
|
||||||
|
@ -148,7 +148,7 @@ public class AudioReactor implements AudioManager.OnAudioFocusChangeListener, An
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAudioSessionId(final EventTime eventTime, final int audioSessionId) {
|
public void onAudioSessionIdChanged(final EventTime eventTime, final int audioSessionId) {
|
||||||
if (!PlayerHelper.isUsingDSP()) {
|
if (!PlayerHelper.isUsingDSP()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.google.android.exoplayer2.DefaultLoadControl;
|
||||||
import com.google.android.exoplayer2.LoadControl;
|
import com.google.android.exoplayer2.LoadControl;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
|
|
||||||
public class LoadController implements LoadControl {
|
public class LoadController implements LoadControl {
|
||||||
|
@ -33,7 +33,7 @@ public class LoadController implements LoadControl {
|
||||||
final DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder();
|
final DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder();
|
||||||
builder.setBufferDurationsMs(minimumPlaybackBufferMs, optimalPlaybackBufferMs,
|
builder.setBufferDurationsMs(minimumPlaybackBufferMs, optimalPlaybackBufferMs,
|
||||||
initialPlaybackBufferMs, initialPlaybackBufferMs);
|
initialPlaybackBufferMs, initialPlaybackBufferMs);
|
||||||
internalLoadControl = builder.createDefaultLoadControl();
|
internalLoadControl = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -47,9 +47,9 @@ public class LoadController implements LoadControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTracksSelected(final Renderer[] renderers, final TrackGroupArray trackGroupArray,
|
public void onTracksSelected(final Renderer[] renderers, final TrackGroupArray trackGroups,
|
||||||
final TrackSelectionArray trackSelectionArray) {
|
final ExoTrackSelection[] trackSelections) {
|
||||||
internalLoadControl.onTracksSelected(renderers, trackGroupArray, trackSelectionArray);
|
internalLoadControl.onTracksSelected(renderers, trackGroups, trackSelections);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,11 +92,12 @@ public class LoadController implements LoadControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldStartPlayback(final long bufferedDurationUs, final float playbackSpeed,
|
public boolean shouldStartPlayback(final long bufferedDurationUs, final float playbackSpeed,
|
||||||
final boolean rebuffering) {
|
final boolean rebuffering, final long targetLiveOffsetUs) {
|
||||||
final boolean isInitialPlaybackBufferFilled
|
final boolean isInitialPlaybackBufferFilled
|
||||||
= bufferedDurationUs >= this.initialPlaybackBufferUs * playbackSpeed;
|
= bufferedDurationUs >= this.initialPlaybackBufferUs * playbackSpeed;
|
||||||
final boolean isInternalStartingPlayback = internalLoadControl
|
final boolean isInternalStartingPlayback = internalLoadControl
|
||||||
.shouldStartPlayback(bufferedDurationUs, playbackSpeed, rebuffering);
|
.shouldStartPlayback(bufferedDurationUs, playbackSpeed, rebuffering,
|
||||||
|
targetLiveOffsetUs);
|
||||||
return isInitialPlaybackBufferFilled || isInternalStartingPlayback;
|
return isInitialPlaybackBufferFilled || isInternalStartingPlayback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,6 @@ public class MediaSessionManager {
|
||||||
@NonNull final Player player,
|
@NonNull final Player player,
|
||||||
@NonNull final MediaSessionCallback callback) {
|
@NonNull final MediaSessionCallback callback) {
|
||||||
mediaSession = new MediaSessionCompat(context, TAG);
|
mediaSession = new MediaSessionCompat(context, TAG);
|
||||||
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS
|
|
||||||
| MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
|
|
||||||
mediaSession.setActive(true);
|
mediaSession.setActive(true);
|
||||||
|
|
||||||
mediaSession.setPlaybackState(new PlaybackStateCompat.Builder()
|
mediaSession.setPlaybackState(new PlaybackStateCompat.Builder()
|
||||||
|
|
|
@ -23,7 +23,7 @@ import com.google.android.exoplayer2.Player.RepeatMode;
|
||||||
import com.google.android.exoplayer2.SeekParameters;
|
import com.google.android.exoplayer2.SeekParameters;
|
||||||
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
import com.google.android.exoplayer2.text.CaptionStyleCompat;
|
||||||
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout.ResizeMode;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
|
@ -323,7 +323,7 @@ public final class PlayerHelper {
|
||||||
return 60000;
|
return 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrackSelection.Factory getQualitySelector() {
|
public static ExoTrackSelection.Factory getQualitySelector() {
|
||||||
return new AdaptiveTrackSelection.Factory(
|
return new AdaptiveTrackSelection.Factory(
|
||||||
1000,
|
1000,
|
||||||
AdaptiveTrackSelection.DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS,
|
AdaptiveTrackSelection.DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ public class CustomTrackSelector extends DefaultTrackSelector {
|
||||||
private String preferredTextLanguage;
|
private String preferredTextLanguage;
|
||||||
|
|
||||||
public CustomTrackSelector(final Context context,
|
public CustomTrackSelector(final Context context,
|
||||||
final TrackSelection.Factory adaptiveTrackSelectionFactory) {
|
final ExoTrackSelection.Factory adaptiveTrackSelectionFactory) {
|
||||||
super(context, adaptiveTrackSelectionFactory);
|
super(context, adaptiveTrackSelectionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class CustomTrackSelector extends DefaultTrackSelector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Pair<TrackSelection.Definition, TextTrackScore> selectTextTrack(
|
protected Pair<ExoTrackSelection.Definition, TextTrackScore> selectTextTrack(
|
||||||
final TrackGroupArray groups,
|
final TrackGroupArray groups,
|
||||||
@NonNull final int[][] formatSupport,
|
@NonNull final int[][] formatSupport,
|
||||||
@NonNull final Parameters params,
|
@NonNull final Parameters params,
|
||||||
|
@ -86,7 +86,7 @@ public class CustomTrackSelector extends DefaultTrackSelector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectedGroup == null ? null
|
return selectedGroup == null ? null
|
||||||
: Pair.create(new TrackSelection.Definition(selectedGroup, selectedTrackIndex),
|
: Pair.create(new ExoTrackSelection.Definition(selectedGroup, selectedTrackIndex),
|
||||||
Assertions.checkNotNull(selectedTrackScore));
|
Assertions.checkNotNull(selectedTrackScore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
||||||
|
@ -43,13 +44,13 @@ public interface PlaybackResolver extends Resolver<StreamInfo, MediaSource> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case C.TYPE_SS:
|
case C.TYPE_SS:
|
||||||
return dataSource.getLiveSsMediaSourceFactory().setTag(metadata)
|
return dataSource.getLiveSsMediaSourceFactory().setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
case C.TYPE_DASH:
|
case C.TYPE_DASH:
|
||||||
return dataSource.getLiveDashMediaSourceFactory().setTag(metadata)
|
return dataSource.getLiveDashMediaSourceFactory().setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
case C.TYPE_HLS:
|
case C.TYPE_HLS:
|
||||||
return dataSource.getLiveHlsMediaSourceFactory().setTag(metadata)
|
return dataSource.getLiveHlsMediaSourceFactory().setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unsupported type: " + type);
|
throw new IllegalStateException("Unsupported type: " + type);
|
||||||
}
|
}
|
||||||
|
@ -68,16 +69,16 @@ public interface PlaybackResolver extends Resolver<StreamInfo, MediaSource> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case C.TYPE_SS:
|
case C.TYPE_SS:
|
||||||
return dataSource.getLiveSsMediaSourceFactory().setTag(metadata)
|
return dataSource.getLiveSsMediaSourceFactory().setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
case C.TYPE_DASH:
|
case C.TYPE_DASH:
|
||||||
return dataSource.getDashMediaSourceFactory().setTag(metadata)
|
return dataSource.getDashMediaSourceFactory().setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
case C.TYPE_HLS:
|
case C.TYPE_HLS:
|
||||||
return dataSource.getHlsMediaSourceFactory().setTag(metadata)
|
return dataSource.getHlsMediaSourceFactory().setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
case C.TYPE_OTHER:
|
case C.TYPE_OTHER:
|
||||||
return dataSource.getExtractorMediaSourceFactory(cacheKey).setTag(metadata)
|
return dataSource.getExtractorMediaSourceFactory(cacheKey).setTag(metadata)
|
||||||
.createMediaSource(uri);
|
.createMediaSource(MediaItem.fromUri(uri));
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unsupported type: " + type);
|
throw new IllegalStateException("Unsupported type: " + type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import android.net.Uri;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.MergingMediaSource;
|
import com.google.android.exoplayer2.source.MergingMediaSource;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import org.schabi.newpipe.util.ListHelper;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.C.SELECTION_FLAG_AUTOSELECT;
|
|
||||||
import static com.google.android.exoplayer2.C.TIME_UNSET;
|
import static com.google.android.exoplayer2.C.TIME_UNSET;
|
||||||
|
|
||||||
public class VideoPlaybackResolver implements PlaybackResolver {
|
public class VideoPlaybackResolver implements PlaybackResolver {
|
||||||
|
@ -101,12 +100,12 @@ public class VideoPlaybackResolver implements PlaybackResolver {
|
||||||
if (mimeType == null) {
|
if (mimeType == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Format textFormat = Format.createTextSampleFormat(null, mimeType,
|
|
||||||
SELECTION_FLAG_AUTOSELECT,
|
|
||||||
PlayerHelper.captionLanguageOf(context, subtitle));
|
|
||||||
final MediaSource textSource = dataSource.getSampleMediaSourceFactory()
|
final MediaSource textSource = dataSource.getSampleMediaSourceFactory()
|
||||||
.createMediaSource(Uri.parse(subtitle.getUrl()), textFormat, TIME_UNSET);
|
.createMediaSource(
|
||||||
|
new MediaItem.Subtitle(Uri.parse(subtitle.getUrl()),
|
||||||
|
mimeType,
|
||||||
|
PlayerHelper.captionLanguageOf(context, subtitle)),
|
||||||
|
TIME_UNSET);
|
||||||
mediaSources.add(textSource);
|
mediaSources.add(textSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue