Skip to content

Commit

Permalink
Update exoplayer to 2.9.6
Browse files Browse the repository at this point in the history
refs #9
  • Loading branch information
drauggres committed Mar 27, 2019
1 parent 22e28e6 commit 3bf5314
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'com.android.library'

def exoPlayerVersion = '2.8.4'
def exoPlayerVersion = '2.9.6'

android {
compileSdkVersion 28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.google.android.exoplayer2.offline.DownloadManager.TaskState;
import com.google.android.exoplayer2.offline.DownloadService;
import com.google.android.exoplayer2.offline.ProgressiveDownloadHelper;
import com.google.android.exoplayer2.offline.SegmentDownloadAction;
import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.offline.TrackKey;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
Expand Down Expand Up @@ -116,16 +116,12 @@ public boolean isDownloaded(Uri uri)
}

@SuppressWarnings("unchecked")
public <K> List<K> getOfflineStreamKeys(Uri uri)
public List<StreamKey> getOfflineStreamKeys(Uri uri)
{
if (!trackedDownloadStates.containsKey(uri)) {
return Collections.emptyList();
}
DownloadAction action = trackedDownloadStates.get(uri);
if (action instanceof SegmentDownloadAction) {
return ((SegmentDownloadAction) action).keys;
}
return Collections.emptyList();
return trackedDownloadStates.get(uri).getKeys();
}

public void toggleDownload(Activity activity, String name, Uri uri, String extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ public DownloadTrackerProxy()
}

/** Returns a {@link HttpDataSource.Factory}. */
public HttpDataSource.Factory buildHttpDataSourceFactory(TransferListener<? super DataSource> listener)
public HttpDataSource.Factory buildHttpDataSourceFactory()
{
return new DefaultHttpDataSourceFactory(userAgent, listener);
return new DefaultHttpDataSourceFactory(userAgent);
}

/** Returns a {@link DataSource.Factory}. */
public DataSource.Factory buildDataSourceFactory(TransferListener<? super DataSource> listener)
public DataSource.Factory buildDataSourceFactory()
{
DefaultDataSourceFactory upstreamFactory = new DefaultDataSourceFactory(
TiApplication.getAppRootOrCurrentActivity(), listener, buildHttpDataSourceFactory(listener));
TiApplication.getAppRootOrCurrentActivity(), buildHttpDataSourceFactory());
return buildReadOnlyCacheDataSource(upstreamFactory, getDownloadCache());
}

Expand All @@ -84,12 +84,12 @@ private synchronized void initDownloadManager()
{
if (downloadManager == null) {
DownloaderConstructorHelper downloaderConstructorHelper =
new DownloaderConstructorHelper(getDownloadCache(), buildHttpDataSourceFactory(/* listener= */ null));
new DownloaderConstructorHelper(getDownloadCache(), buildHttpDataSourceFactory());
downloadManager = new DownloadManager(
downloaderConstructorHelper, maxSimultaneousDownloads, DownloadManager.DEFAULT_MIN_RETRY_COUNT,
new File(getDownloadDirectory(), downloadActionFile), DOWNLOAD_DESERIALIZERS);
downloadTracker = new DownloadTracker(
/* context= */ TiApplication.getInstance(), buildDataSourceFactory(/* listener= */ null),
/* context= */ TiApplication.getInstance(), buildDataSourceFactory(),
new File(getDownloadDirectory(), downloadTrackerActionFile), DOWNLOAD_DESERIALIZERS);
downloadManager.addListener(downloadTracker);
downloadTracker.addListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataOutput;
import com.google.android.exoplayer2.offline.FilteringManifestParser;
import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.BehindLiveWindowException;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
Expand All @@ -72,14 +73,12 @@
import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser;
import com.google.android.exoplayer2.source.dash.manifest.RepresentationKey;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistParserFactory;
import com.google.android.exoplayer2.source.hls.playlist.HlsPlaylistParser;
import com.google.android.exoplayer2.source.hls.playlist.RenditionKey;
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.StreamKey;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.FixedTrackSelection;
Expand Down Expand Up @@ -729,7 +728,7 @@ public void initializePlayer()
DefaultRenderersFactory renderersFactory =
new DefaultRenderersFactory(activity, drmSessionManager, extensionRendererMode);

player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, drmSessionManager);
player = ExoPlayerFactory.newSimpleInstance(proxy.getActivity(), renderersFactory, trackSelector, drmSessionManager);
player.addListener(this);
player.addMetadataOutput(this);
player.setVideoDebugListener(this);
Expand Down Expand Up @@ -868,7 +867,7 @@ public void updateResumePosition()
}
}

private List<?> getOfflineStreamKeys(Uri uri)
private List<StreamKey> getOfflineStreamKeys(Uri uri)
{
return TiExoplayerModule.getInstance().getDownloadTrackerProxy().getDownloadTracker().getOfflineStreamKeys(uri);
}
Expand Down Expand Up @@ -915,18 +914,18 @@ private MediaSource buildMediaSource(Uri uri, @ContentType int type)
return new DashMediaSource
.Factory(new DefaultDashChunkSource.Factory(mediaDataSourceFactory), buildDataSourceFactory(false))
.setManifestParser(new FilteringManifestParser<>(
new DashManifestParser(), (List<RepresentationKey>) getOfflineStreamKeys(uri)))
new DashManifestParser(), getOfflineStreamKeys(uri)))
.createMediaSource(uri);
case C.TYPE_SS:
return new SsMediaSource
.Factory(new DefaultSsChunkSource.Factory(mediaDataSourceFactory), buildDataSourceFactory(false))
.setManifestParser(new FilteringManifestParser<>(new SsManifestParser(),
(List<StreamKey>) getOfflineStreamKeys(uri)))
getOfflineStreamKeys(uri)))
.createMediaSource(uri);
case C.TYPE_HLS:
return new HlsMediaSource.Factory(mediaDataSourceFactory)
.setPlaylistParser(new FilteringManifestParser<>(new HlsPlaylistParser(),
(List<RenditionKey>) getOfflineStreamKeys(uri)))
.setPlaylistParserFactory(
new DefaultHlsPlaylistParserFactory(getOfflineStreamKeys(uri)))
.createMediaSource(uri);
case C.TYPE_OTHER:
return new ExtractorMediaSource.Factory(mediaDataSourceFactory).createMediaSource(uri);
Expand Down Expand Up @@ -977,7 +976,7 @@ public int[] getSupportedTypes()
return new int[] { C.TYPE_DASH, C.TYPE_SS, C.TYPE_HLS, C.TYPE_OTHER };
}
};
return new AdsMediaSource(mediaSource, adMediaSourceFactory, adsLoader, adUiViewGroup);
return new AdsMediaSource(mediaSource, adMediaSourceFactory, adsLoader, videoView);
}

/**
Expand All @@ -989,8 +988,7 @@ public int[] getSupportedTypes()
*/
private DataSource.Factory buildDataSourceFactory(boolean useBandwidthMeter)
{
return TiExoplayerModule.getInstance().getDownloadTrackerProxy().buildDataSourceFactory(
useBandwidthMeter ? BANDWIDTH_METER : null);
return TiExoplayerModule.getInstance().getDownloadTrackerProxy().buildDataSourceFactory();
}

private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason)
Expand Down

0 comments on commit 3bf5314

Please sign in to comment.