Search in sources :

Example 11 with BandwidthMeter

use of com.google.android.exoplayer2.upstream.BandwidthMeter in project android by owncloud.

the class PrepareVideoPlayerAsyncTask method doInBackground.

@Override
protected MediaSource doInBackground(Object... params) {
    MediaSource mediaSource = null;
    Uri uri;
    try {
        // If the file is already downloaded, reproduce it locally, if not, do streaming
        uri = mFile.isDown() ? mFile.getStorageUri() : Uri.parse(AccountUtils.getWebDavUrlForAccount(mContext, mAccount) + Uri.encode(mFile.getRemotePath(), "/"));
        boolean useBandwidthMeter = true;
        DefaultBandwidthMeter bandwidthMeter = useBandwidthMeter ? BANDWIDTH_METER : null;
        HttpDataSource.Factory httpDataSourceFactory = buildHttpDataSourceFactory(bandwidthMeter, mFile, mAccount);
        // Produces DataSource instances through which media data is loaded.
        DataSource.Factory mediaDataSourceFactory = new DefaultDataSourceFactory(mContext, bandwidthMeter, httpDataSourceFactory);
        // This represents the media to be played.
        mediaSource = buildMediaSource(mediaDataSourceFactory, uri);
    } catch (AccountUtils.AccountNotFoundException e) {
        Timber.e(e);
    }
    return mediaSource;
}
Also used : ProgressiveMediaSource(com.google.android.exoplayer2.source.ProgressiveMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultBandwidthMeter(com.google.android.exoplayer2.upstream.DefaultBandwidthMeter) DefaultDataSourceFactory(com.google.android.exoplayer2.upstream.DefaultDataSourceFactory) AccountUtils(com.owncloud.android.lib.common.accounts.AccountUtils) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource) Uri(android.net.Uri) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource) DataSource(com.google.android.exoplayer2.upstream.DataSource)

Aggregations

MediaSource (com.google.android.exoplayer2.source.MediaSource)4 BandwidthMeter (com.google.android.exoplayer2.upstream.BandwidthMeter)4 DefaultBandwidthMeter (com.google.android.exoplayer2.upstream.DefaultBandwidthMeter)4 Test (org.junit.Test)4 ExoPlayerFactory (com.google.android.exoplayer2.ExoPlayerFactory)2 Format (com.google.android.exoplayer2.Format)2 LoadControl (com.google.android.exoplayer2.LoadControl)2 RenderersFactory (com.google.android.exoplayer2.RenderersFactory)2 Timeline (com.google.android.exoplayer2.Timeline)2 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)2 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)2 AdaptiveTrackSelection (com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection)2 AdaptationCheckpoint (com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection.AdaptationCheckpoint)2 Definition (com.google.android.exoplayer2.trackselection.ExoTrackSelection.Definition)2 DefaultDataSourceFactory (com.google.android.exoplayer2.upstream.DefaultDataSourceFactory)2 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AuthenticatorException (android.accounts.AuthenticatorException)1 OperationCanceledException (android.accounts.OperationCanceledException)1