-Added MediaSourceManager and Playlist adapters.

This commit is contained in:
John Zhen M 2017-08-28 17:38:37 -07:00 committed by John Zhen Mo
parent e70dcdc642
commit cbcd281784
13 changed files with 753 additions and 21 deletions

View file

@ -344,13 +344,15 @@ public class BackgroundPlayer extends Service {
@Override
public void onFastRewind() {
super.onFastRewind();
// super.onFastRewind();
simpleExoPlayer.seekTo(0, 0);
triggerProgressUpdate();
}
@Override
public void onFastForward() {
super.onFastForward();
// super.onFastForward();
simpleExoPlayer.seekTo(2, 0);
triggerProgressUpdate();
}

View file

@ -47,7 +47,9 @@ import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.LoopingMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.dash.DashMediaSource;
@ -248,7 +250,12 @@ public abstract class BasePlayer implements Player.EventListener, AudioManager.O
changeState(STATE_LOADING);
isPrepared = false;
mediaSource = buildMediaSource(url, format);
final MediaSource ms = buildMediaSource(url, format);
final DynamicConcatenatingMediaSource dcms = new DynamicConcatenatingMediaSource();
dcms.addMediaSource(ms);
mediaSource = dcms;
dcms.addMediaSource(new LoopingMediaSource(ms, 2));
if (simpleExoPlayer.getPlaybackState() != Player.STATE_IDLE) simpleExoPlayer.stop();
if (videoStartPos > 0) simpleExoPlayer.seekTo(videoStartPos);

View file

@ -0,0 +1,21 @@
package org.schabi.newpipe.player;
import com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import org.schabi.newpipe.playlist.Playlist;
import java.util.List;
public class MediaSourceManager {
private DynamicConcatenatingMediaSource source;
private Playlist playlist;
private List<MediaSource> sources;
public MediaSourceManager(Playlist playlist) {
this.source = new DynamicConcatenatingMediaSource();
this.playlist = playlist;
}
}