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;
}
Aggregations