Search in sources :

Example 1 with SsMediaSource

use of com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource in project ExoPlayer by google.

the class SsMediaSource method prepareSourceInternal.

@Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
    this.mediaTransferListener = mediaTransferListener;
    drmSessionManager.prepare();
    drmSessionManager.setPlayer(/* playbackLooper= */
    Looper.myLooper(), getPlayerId());
    if (sideloadedManifest) {
        manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();
        processManifest();
    } else {
        manifestDataSource = manifestDataSourceFactory.createDataSource();
        manifestLoader = new Loader("SsMediaSource");
        manifestLoaderErrorThrower = manifestLoader;
        manifestRefreshHandler = Util.createHandlerForCurrentLooper();
        startLoadingManifest();
    }
}
Also used : LoaderErrorThrower(com.google.android.exoplayer2.upstream.LoaderErrorThrower) SequenceableLoader(com.google.android.exoplayer2.source.SequenceableLoader) Loader(com.google.android.exoplayer2.upstream.Loader)

Example 2 with SsMediaSource

use of com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource in project react-native-track-player by react-native-kit.

the class ExoPlayback method load.

@Override
public void load(Track track, Promise callback) {
    loadCallback = callback;
    Uri url = track.url;
    String userAgent = Util.getUserAgent(context, "react-native-track-player");
    DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent, null, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true);
    DataSource.Factory factory = new DefaultDataSourceFactory(context, null, httpDataSourceFactory);
    MediaSource source;
    if (cacheMaxSize > 0 && !track.urlLocal) {
        File cacheDir = new File(context.getCacheDir(), "TrackPlayer");
        Cache cache = new SimpleCache(cacheDir, new LeastRecentlyUsedCacheEvictor(cacheMaxSize));
        factory = new CacheDataSourceFactory(cache, factory, 0, cacheMaxSize);
    }
    if (track.type == TrackType.DASH) {
        source = new DashMediaSource(url, factory, new DefaultDashChunkSource.Factory(factory), null, null);
    } else if (track.type == TrackType.HLS) {
        source = new HlsMediaSource(url, factory, null, null);
    } else if (track.type == TrackType.SMOOTH_STREAMING) {
        source = new SsMediaSource(url, factory, new DefaultSsChunkSource.Factory(factory), null, null);
    } else {
        source = new ExtractorMediaSource(url, factory, new DefaultExtractorsFactory(), null, null);
    }
    player.prepare(source);
}
Also used : DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) LeastRecentlyUsedCacheEvictor(com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor) DashMediaSource(com.google.android.exoplayer2.source.dash.DashMediaSource) CacheDataSourceFactory(com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory) DefaultHttpDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) DefaultExtractorsFactory(com.google.android.exoplayer2.extractor.DefaultExtractorsFactory) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) SsMediaSource(com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource) Uri(android.net.Uri) DataSource(com.google.android.exoplayer2.upstream.DataSource) DefaultHttpDataSource(com.google.android.exoplayer2.upstream.DefaultHttpDataSource) HlsMediaSource(com.google.android.exoplayer2.source.hls.HlsMediaSource) HlsMediaSource(com.google.android.exoplayer2.source.hls.HlsMediaSource) DashMediaSource(com.google.android.exoplayer2.source.dash.DashMediaSource) ExtractorMediaSource(com.google.android.exoplayer2.source.ExtractorMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) SsMediaSource(com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) CacheDataSourceFactory(com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory) DefaultHttpDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) File(java.io.File) Cache(com.google.android.exoplayer2.upstream.cache.Cache) SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache)

Aggregations

Uri (android.net.Uri)1 DefaultExtractorsFactory (com.google.android.exoplayer2.extractor.DefaultExtractorsFactory)1 ExtractorMediaSource (com.google.android.exoplayer2.source.ExtractorMediaSource)1 MediaSource (com.google.android.exoplayer2.source.MediaSource)1 SequenceableLoader (com.google.android.exoplayer2.source.SequenceableLoader)1 DashMediaSource (com.google.android.exoplayer2.source.dash.DashMediaSource)1 HlsMediaSource (com.google.android.exoplayer2.source.hls.HlsMediaSource)1 SsMediaSource (com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource)1 DataSource (com.google.android.exoplayer2.upstream.DataSource)1 DefaultDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultDataSourceFactory)1 DefaultHttpDataSource (com.google.android.exoplayer2.upstream.DefaultHttpDataSource)1 DefaultHttpDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory)1 Loader (com.google.android.exoplayer2.upstream.Loader)1 LoaderErrorThrower (com.google.android.exoplayer2.upstream.LoaderErrorThrower)1 Cache (com.google.android.exoplayer2.upstream.cache.Cache)1 CacheDataSourceFactory (com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory)1 LeastRecentlyUsedCacheEvictor (com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor)1 SimpleCache (com.google.android.exoplayer2.upstream.cache.SimpleCache)1 File (java.io.File)1