com.google.android.exoplayer2.upstream.HttpDataSource Java Examples
The following examples show how to use
com.google.android.exoplayer2.upstream.HttpDataSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomDrmCallback.java From ExoPlayer-Offline with Apache License 2.0 | 6 votes |
private byte[] executePost(String url, byte[] data, Map<String, String> requestProperties) throws IOException { HttpDataSource dataSource = dataSourceFactory.createDataSource(); if (requestProperties != null) { for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) { dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); } } DataSpec dataSpec = new DataSpec(Uri.parse(url), data, 0, 0, C.LENGTH_UNSET, null, DataSpec.FLAG_ALLOW_GZIP); DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec); try { return Util.toByteArray(inputStream); } finally { Util.closeQuietly(inputStream); } }
Example #2
Source File: HttpMediaDrmCallback.java From K-Sonic with MIT License | 6 votes |
private static byte[] executePost(HttpDataSource.Factory dataSourceFactory, String url, byte[] data, Map<String, String> requestProperties) throws IOException { HttpDataSource dataSource = dataSourceFactory.createDataSource(); if (requestProperties != null) { for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) { dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); } } DataSpec dataSpec = new DataSpec(Uri.parse(url), data, 0, 0, C.LENGTH_UNSET, null, DataSpec.FLAG_ALLOW_GZIP); DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec); try { return Util.toByteArray(inputStream); } finally { Util.closeQuietly(inputStream); } }
Example #3
Source File: ReactExoplayerView.java From react-native-video with MIT License | 6 votes |
private static boolean isBehindLiveWindow(ExoPlaybackException e) { Log.e("ExoPlayer Exception", e.toString()); if (e.type != ExoPlaybackException.TYPE_SOURCE) { return false; } Throwable cause = e.getSourceException(); while (cause != null) { if (cause instanceof BehindLiveWindowException || cause instanceof HttpDataSource.HttpDataSourceException) { return true; } cause = cause.getCause(); } return false; }
Example #4
Source File: IcyHttpDataSourceFactoryTest.java From android-exoplayer2-ext-icy with Apache License 2.0 | 6 votes |
@Test public void createDataSourceViaFactoryFromFactoryBuilder() { // Arrange OkHttpClient client = new OkHttpClient.Builder().build(); IcyHttpDataSourceFactory factory = new IcyHttpDataSourceFactory.Builder(client) .setUserAgent(Constants.TEST_USER_AGENT) .setIcyHeadersListener(TEST_ICY_HEADERS_LISTENER) .setIcyMetadataChangeListener(TEST_ICY_METADATA_LISTENER) .build(); HttpDataSource.RequestProperties requestProperties = new HttpDataSource.RequestProperties(); // Act IcyHttpDataSource source = factory.createDataSourceInternal(requestProperties); // Assert assertNotNull(source); }
Example #5
Source File: ArviHttpDataSourceFactory.java From ARVI with Apache License 2.0 | 6 votes |
@Override protected DefaultHttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties defaultRequestProperties) { final HttpDataSource.RequestProperties finalRequestProperties = new HttpDataSource.RequestProperties(); finalRequestProperties.set(this.requestProperties.getSnapshot()); finalRequestProperties.set(defaultRequestProperties.getSnapshot()); final DefaultHttpDataSource dataSource = new ArviHttpDataSource( this.userAgent, null, this.connectTimeoutMillis, this.readTimeoutMillis, this.allowCrossProtocolRedirects, finalRequestProperties ).setRequestAuthorizer(this.requestAuthorizer); if(this.listener != null) { dataSource.addTransferListener(this.listener); } return dataSource; }
Example #6
Source File: ProviderTvInputService.java From xipl with Apache License 2.0 | 5 votes |
@Override public void onPlayerError(ExoPlaybackException error) { if (error.getCause() instanceof BehindLiveWindowException) { Toast.makeText(mContext, R.string.stream_failure_retry, Toast.LENGTH_SHORT).show(); mProviderTvPlayer.restart(mContext); mProviderTvPlayer.play(); } else if (error.getCause() instanceof UnrecognizedInputFormatException) { // Channel cannot be played in case of an error in parsing the ".m3u8" file. Toast.makeText(mContext, mContext.getString(R.string.channel_stream_failure), Toast.LENGTH_SHORT).show(); } else if (error.getCause() instanceof HttpDataSource.InvalidResponseCodeException) { /* We might get errors different like 403 which indicate permission denied due to multiple connections at the same time or 502 meaning bad gateway. Restart the loading after 5 seconds. */ Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if (mContext != null && mProviderTvPlayer != null) { Toast.makeText(mContext, R.string.stream_failure_retry, Toast.LENGTH_SHORT).show(); mProviderTvPlayer.restart(mContext); mProviderTvPlayer.play(); } } }, 5000); } else if (error.getCause() instanceof HttpDataSource.HttpDataSourceException) { // Timeout, nothing we can do really... Toast.makeText(mContext, R.string.channel_stream_failure, Toast.LENGTH_SHORT).show(); } }
Example #7
Source File: DataSourceUtil.java From react-native-video with MIT License | 5 votes |
private static HttpDataSource.Factory buildHttpDataSourceFactory(ReactContext context, DefaultBandwidthMeter bandwidthMeter, Map<String, String> requestHeaders) { OkHttpClient client = OkHttpClientProvider.getOkHttpClient(); CookieJarContainer container = (CookieJarContainer) client.cookieJar(); ForwardingCookieHandler handler = new ForwardingCookieHandler(context); container.setCookieJar(new JavaNetCookieJar(handler)); OkHttpDataSourceFactory okHttpDataSourceFactory = new OkHttpDataSourceFactory(client, getUserAgent(context), bandwidthMeter); if (requestHeaders != null) okHttpDataSourceFactory.getDefaultRequestProperties().set(requestHeaders); return okHttpDataSourceFactory; }
Example #8
Source File: HttpMediaDrmCallback.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static byte[] executePost(HttpDataSource.Factory dataSourceFactory, String url, byte[] data, Map<String, String> requestProperties) throws IOException { HttpDataSource dataSource = dataSourceFactory.createDataSource(); if (requestProperties != null) { for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) { dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); } } int manualRedirectCount = 0; while (true) { DataSpec dataSpec = new DataSpec( Uri.parse(url), data, /* absoluteStreamPosition= */ 0, /* position= */ 0, /* length= */ C.LENGTH_UNSET, /* key= */ null, DataSpec.FLAG_ALLOW_GZIP); DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec); try { return Util.toByteArray(inputStream); } catch (InvalidResponseCodeException e) { // For POST requests, the underlying network stack will not normally follow 307 or 308 // redirects automatically. Do so manually here. boolean manuallyRedirect = (e.responseCode == 307 || e.responseCode == 308) && manualRedirectCount++ < MAX_MANUAL_REDIRECTS; url = manuallyRedirect ? getRedirectUrl(e) : null; if (url == null) { throw e; } } finally { Util.closeQuietly(inputStream); } } }
Example #9
Source File: GSYExoHttpDataSourceFactory.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
@Override protected GSYDefaultHttpDataSource createDataSourceInternal( HttpDataSource.RequestProperties defaultRequestProperties) { GSYDefaultHttpDataSource dataSource = new GSYDefaultHttpDataSource( userAgent, connectTimeoutMillis, readTimeoutMillis, allowCrossProtocolRedirects, defaultRequestProperties); if (listener != null) { dataSource.addTransferListener(listener); } return dataSource; }
Example #10
Source File: IcyHttpDataSourceFactory.java From android-exoplayer2-ext-icy with Apache License 2.0 | 5 votes |
@Override protected IcyHttpDataSource createDataSourceInternal(@NonNull HttpDataSource.RequestProperties defaultRequestProperties) { return new IcyHttpDataSource.Builder(callFactory) .setUserAgent(userAgent) .setContentTypePredicate(contentTypePredicate) .setCacheControl(cacheControl) .setDefaultRequestProperties(defaultRequestProperties) .setIcyHeadersListener(icyHeadersListener) .setIcyMetadataListener(icyMetadataListener) .build(); }
Example #11
Source File: ArviHttpDataSourceFactory.java From ARVI with Apache License 2.0 | 5 votes |
/** * @param userAgent The User-Agent string that should be used. * @param listener An optional listener. * @param connectTimeoutMillis The connection timeout that should be used when requesting remote * data, in milliseconds. A timeout of zero is interpreted as an infinite timeout. * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in * milliseconds. A timeout of zero is interpreted as an infinite timeout. * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP * to HTTPS and vice versa) are enabled. */ public ArviHttpDataSourceFactory(String userAgent, TransferListener listener, RequestAuthorizer requestAuthorizer, int connectTimeoutMillis, int readTimeoutMillis, boolean allowCrossProtocolRedirects) { this.userAgent = userAgent; this.listener = listener; this.requestAuthorizer = requestAuthorizer; this.connectTimeoutMillis = connectTimeoutMillis; this.readTimeoutMillis = readTimeoutMillis; this.allowCrossProtocolRedirects = allowCrossProtocolRedirects; this.requestProperties = new HttpDataSource.RequestProperties(); }
Example #12
Source File: SourceErrorMapper.java From no-player with Apache License 2.0 | 5 votes |
private static NoPlayer.PlayerError mapHttpDataSourceException(HttpDataSource.HttpDataSourceException httpDataSourceException, String message) { switch (httpDataSourceException.type) { case HttpDataSource.HttpDataSourceException.TYPE_OPEN: return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.HTTP_CANNOT_OPEN_ERROR, message); case HttpDataSource.HttpDataSourceException.TYPE_READ: return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.HTTP_CANNOT_READ_ERROR, message); case HttpDataSource.HttpDataSourceException.TYPE_CLOSE: return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.HTTP_CANNOT_CLOSE_ERROR, message); default: return new NoPlayerError(PlayerErrorType.CONNECTIVITY, DetailErrorType.UNKNOWN, message); } }
Example #13
Source File: HttpMediaDrmCallback.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static byte[] executePost(HttpDataSource.Factory dataSourceFactory, String url, byte[] data, Map<String, String> requestProperties) throws IOException { HttpDataSource dataSource = dataSourceFactory.createDataSource(); if (requestProperties != null) { for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) { dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); } } int manualRedirectCount = 0; while (true) { DataSpec dataSpec = new DataSpec( Uri.parse(url), data, /* absoluteStreamPosition= */ 0, /* position= */ 0, /* length= */ C.LENGTH_UNSET, /* key= */ null, DataSpec.FLAG_ALLOW_GZIP); DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec); try { return Util.toByteArray(inputStream); } catch (InvalidResponseCodeException e) { // For POST requests, the underlying network stack will not normally follow 307 or 308 // redirects automatically. Do so manually here. boolean manuallyRedirect = (e.responseCode == 307 || e.responseCode == 308) && manualRedirectCount++ < MAX_MANUAL_REDIRECTS; url = manuallyRedirect ? getRedirectUrl(e) : null; if (url == null) { throw e; } } finally { Util.closeQuietly(inputStream); } } }
Example #14
Source File: PlayerEventHandler.java From zapp with MIT License | 5 votes |
@Override public void onLoadError(EventTime eventTime, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException error, boolean wasCanceled) { if (wasCanceled) { return; } Timber.e(error, "exo player onLoadError"); if (error instanceof HttpDataSource.HttpDataSourceException) { errorResourceIdSource.onNext(R.string.error_stream_io); } else { errorResourceIdSource.onNext(R.string.error_stream_unknown); } }
Example #15
Source File: HttpMediaDrmCallback.java From K-Sonic with MIT License | 5 votes |
/** * @deprecated Use {@link HttpMediaDrmCallback#HttpMediaDrmCallback(String, Factory)}. Request * properties can be set by calling {@link #setKeyRequestProperty(String, String)}. * @param defaultUrl The default license URL. * @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances. * @param keyRequestProperties Request properties to set when making key requests, or null. */ @Deprecated public HttpMediaDrmCallback(String defaultUrl, HttpDataSource.Factory dataSourceFactory, Map<String, String> keyRequestProperties) { this.dataSourceFactory = dataSourceFactory; this.defaultUrl = defaultUrl; this.keyRequestProperties = new HashMap<>(); if (keyRequestProperties != null) { this.keyRequestProperties.putAll(keyRequestProperties); } }
Example #16
Source File: OfflineLicenseHelper.java From K-Sonic with MIT License | 5 votes |
/** * Downloads an offline license. * * @param dataSource The {@link HttpDataSource} to be used for download. * @param dashManifest The {@link DashManifest} of the DASH content. * @return The downloaded offline license key set id. * @throws IOException If an error occurs reading data from the stream. * @throws InterruptedException If the thread has been interrupted. * @throws DrmSessionException Thrown when there is an error during DRM session. */ public byte[] download(HttpDataSource dataSource, DashManifest dashManifest) throws IOException, InterruptedException, DrmSessionException { // Get DrmInitData // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream, // as per DASH IF Interoperability Recommendations V3.0, 7.5.3. if (dashManifest.getPeriodCount() < 1) { return null; } Period period = dashManifest.getPeriod(0); int adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_VIDEO); if (adaptationSetIndex == C.INDEX_UNSET) { adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_AUDIO); if (adaptationSetIndex == C.INDEX_UNSET) { return null; } } AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex); if (adaptationSet.representations.isEmpty()) { return null; } Representation representation = adaptationSet.representations.get(0); DrmInitData drmInitData = representation.format.drmInitData; if (drmInitData == null) { Format sampleFormat = DashUtil.loadSampleFormat(dataSource, representation); if (sampleFormat != null) { drmInitData = sampleFormat.drmInitData; } if (drmInitData == null) { return null; } } blockingKeyRequest(DefaultDrmSessionManager.MODE_DOWNLOAD, null, drmInitData); return drmSessionManager.getOfflineLicenseKeySetId(); }
Example #17
Source File: ExoPlayerErrorMapperTest.java From no-player with Apache License 2.0 | 4 votes |
@Parameterized.Parameters(name = "{0} with detail {1} is mapped from {2}") public static Collection<Object[]> parameters() { return Arrays.asList( new Object[]{SOURCE, SAMPLE_QUEUE_MAPPING_ERROR, createSource(new SampleQueueMappingException("mimetype-sample"))}, new Object[]{SOURCE, READING_LOCAL_FILE_ERROR, createSource(new FileDataSource.FileDataSourceException(new IOException()))}, new Object[]{SOURCE, UNEXPECTED_LOADING_ERROR, createSource(new Loader.UnexpectedLoaderException(new Throwable()))}, new Object[]{SOURCE, LIVE_STALE_MANIFEST_AND_NEW_MANIFEST_COULD_NOT_LOAD_ERROR, createSource(new DashManifestStaleException())}, new Object[]{SOURCE, DOWNLOAD_ERROR, createSource(new DownloadException("download-exception"))}, new Object[]{SOURCE, AD_LOAD_ERROR_THEN_WILL_SKIP, createSource(AdsMediaSource.AdLoadException.createForAd(new Exception()))}, new Object[]{SOURCE, AD_GROUP_LOAD_ERROR_THEN_WILL_SKIP, createSource(AdsMediaSource.AdLoadException.createForAdGroup(new Exception(), 0))}, new Object[]{SOURCE, ALL_ADS_LOAD_ERROR_THEN_WILL_SKIP, createSource(AdsMediaSource.AdLoadException.createForAllAds(new Exception()))}, new Object[]{SOURCE, ADS_LOAD_UNEXPECTED_ERROR_THEN_WILL_SKIP, createSource(AdsMediaSource.AdLoadException.createForUnexpected(new RuntimeException()))}, new Object[]{SOURCE, MERGING_MEDIA_SOURCE_CANNOT_MERGE_ITS_SOURCES, createSource(new MergingMediaSource.IllegalMergeException(MergingMediaSource.IllegalMergeException.REASON_PERIOD_COUNT_MISMATCH))}, new Object[]{SOURCE, CLIPPING_MEDIA_SOURCE_CANNOT_CLIP_WRAPPED_SOURCE_INVALID_PERIOD_COUNT, createSource(new ClippingMediaSource.IllegalClippingException(ClippingMediaSource.IllegalClippingException.REASON_INVALID_PERIOD_COUNT))}, new Object[]{SOURCE, CLIPPING_MEDIA_SOURCE_CANNOT_CLIP_WRAPPED_SOURCE_NOT_SEEKABLE_TO_START, createSource(new ClippingMediaSource.IllegalClippingException(ClippingMediaSource.IllegalClippingException.REASON_NOT_SEEKABLE_TO_START))}, new Object[]{SOURCE, CLIPPING_MEDIA_SOURCE_CANNOT_CLIP_WRAPPED_SOURCE_INVALID_PERIOD_COUNT, createSource(new ClippingMediaSource.IllegalClippingException(ClippingMediaSource.IllegalClippingException.REASON_INVALID_PERIOD_COUNT))}, new Object[]{SOURCE, TASK_CANNOT_PROCEED_PRIORITY_TOO_LOW, createSource(new PriorityTaskManager.PriorityTooLowException(1, 2))}, new Object[]{SOURCE, PARSING_MEDIA_DATA_OR_METADATA_ERROR, createSource(new ParserException())}, new Object[]{SOURCE, CACHE_WRITING_DATA_ERROR, createSource(new Cache.CacheException("cache-exception"))}, new Object[]{SOURCE, READ_LOCAL_ASSET_ERROR, createSource(new AssetDataSource.AssetDataSourceException(new IOException()))}, new Object[]{SOURCE, DATA_POSITION_OUT_OF_RANGE_ERROR, createSource(new DataSourceException(DataSourceException.POSITION_OUT_OF_RANGE))}, new Object[]{CONNECTIVITY, HTTP_CANNOT_OPEN_ERROR, createSource(new HttpDataSource.HttpDataSourceException(new DataSpec(Uri.EMPTY, 0), HttpDataSource.HttpDataSourceException.TYPE_OPEN))}, new Object[]{CONNECTIVITY, HTTP_CANNOT_READ_ERROR, createSource(new HttpDataSource.HttpDataSourceException(new DataSpec(Uri.EMPTY, 0), HttpDataSource.HttpDataSourceException.TYPE_READ))}, new Object[]{CONNECTIVITY, HTTP_CANNOT_CLOSE_ERROR, createSource(new HttpDataSource.HttpDataSourceException(new DataSpec(Uri.EMPTY, 0), HttpDataSource.HttpDataSourceException.TYPE_CLOSE))}, new Object[]{CONNECTIVITY, READ_CONTENT_URI_ERROR, createSource(new ContentDataSource.ContentDataSourceException(new IOException()))}, new Object[]{CONNECTIVITY, READ_FROM_UDP_ERROR, createSource(new UdpDataSource.UdpDataSourceException(new IOException()))}, new Object[]{RENDERER_DECODER, AUDIO_SINK_CONFIGURATION_ERROR, createRenderer(new AudioSink.ConfigurationException("configuration-exception"))}, new Object[]{RENDERER_DECODER, AUDIO_SINK_INITIALISATION_ERROR, createRenderer(new AudioSink.InitializationException(0, 0, 0, 0))}, new Object[]{RENDERER_DECODER, AUDIO_SINK_WRITE_ERROR, createRenderer(new AudioSink.WriteException(0))}, new Object[]{RENDERER_DECODER, AUDIO_UNHANDLED_FORMAT_ERROR, createRenderer(new AudioProcessor.UnhandledFormatException(0, 0, 0))}, new Object[]{RENDERER_DECODER, AUDIO_DECODER_ERROR, createRenderer(new AudioDecoderException("audio-decoder-exception"))}, new Object[]{RENDERER_DECODER, INITIALISATION_ERROR, createRenderer(new MediaCodecRenderer.DecoderInitializationException(Format.createSampleFormat("id", "sample-mimety[e", 0), new Throwable(), true, 0))}, new Object[]{RENDERER_DECODER, DECODING_SUBTITLE_ERROR, createRenderer(new SubtitleDecoderException("metadata-decoder-exception"))}, new Object[]{DRM, UNSUPPORTED_DRM_SCHEME_ERROR, createRenderer(new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME))}, new Object[]{DRM, DRM_INSTANTIATION_ERROR, createRenderer(new UnsupportedDrmException(UnsupportedDrmException.REASON_INSTANTIATION_ERROR))}, new Object[]{DRM, DRM_SESSION_ERROR, createRenderer(new DrmSession.DrmSessionException(new Throwable()))}, new Object[]{DRM, DRM_KEYS_EXPIRED_ERROR, createRenderer(new KeysExpiredException())}, new Object[]{DRM, MEDIA_REQUIRES_DRM_SESSION_MANAGER_ERROR, createRenderer(new IllegalStateException())}, new Object[]{CONTENT_DECRYPTION, FAIL_DECRYPT_DATA_DUE_NON_PLATFORM_COMPONENT_ERROR, createRenderer(new DecryptionException(0, "decryption-exception"))}, new Object[]{UNEXPECTED, MULTIPLE_RENDERER_MEDIA_CLOCK_ENABLED_ERROR, ExoPlaybackExceptionFactory.createForUnexpected(new IllegalStateException("Multiple renderer media clocks enabled."))}, new Object[]{PlayerErrorType.UNKNOWN, DetailErrorType.UNKNOWN, ExoPlaybackExceptionFactory.createForUnexpected(new IllegalStateException("Any other exception"))} // DefaultAudioSink.InvalidAudioTrackTimestampException is private, cannot create // EGLSurfaceTexture.GlException is private, cannot create // PlaylistStuckException constructor is private, cannot create // PlaylistResetException constructor is private, cannot create // MediaCodecUtil.DecoderQueryException constructor is private, cannot create // DefaultDrmSessionManager.MissingSchemeDataException constructor is private, cannot create // Crypto Exceptions cannot be instantiated, it throws a RuntimeException("Stub!") ); }
Example #18
Source File: VideoExoPlayer.java From TigerVideo with Apache License 2.0 | 4 votes |
private HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(Util.getUserAgent(mContext, TAG), bandwidthMeter, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true); }
Example #19
Source File: ExoMedia.java From ExoMedia with Apache License 2.0 | 4 votes |
@NonNull HttpDataSource.BaseFactory provide(@NonNull String userAgent, @Nullable TransferListener listener);
Example #20
Source File: MediaSourceCreator.java From ExoVideoView with Apache License 2.0 | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); }
Example #21
Source File: LiveVideoPlayerActivity.java From LiveVideoBroadcaster with Apache License 2.0 | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); }
Example #22
Source File: MediaSourceFactory.java From CumulusTV with MIT License | 4 votes |
private static HttpDataSource.Factory buildHttpDataSourceFactory(Context context, boolean useBandwidthMeter) { return buildHttpDataSourceFactory(context, useBandwidthMeter ? BANDWIDTH_METER : null); }
Example #23
Source File: MediaHelper.java From TubiPlayer with MIT License | 4 votes |
public static @NonNull HttpDataSource.Factory buildHttpDataSourceFactory(@NonNull Context context, @NonNull DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(Util.getUserAgent(context, "TubiExoPlayer"), bandwidthMeter); }
Example #24
Source File: MediaSourceFactory.java From CumulusTV with MIT License | 4 votes |
public static HttpDataSource.Factory buildHttpDataSourceFactory(Context context, DefaultBandwidthMeter bandwidthMeter) { String userAgent = Util.getUserAgent(context, "ExoPlayerDemo"); return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); }
Example #25
Source File: DemoApplication.java From ExoPlayer-Offline with Apache License 2.0 | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { // return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); return new OkHttpDataSourceFactory(okHttpClient,userAgent,bandwidthMeter); }
Example #26
Source File: TubiPlayerActivity.java From TubiPlayer with MIT License | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(Util.getUserAgent(this, "TubiPlayerActivity"), bandwidthMeter); }
Example #27
Source File: DemoApplication.java From TubiPlayer with MIT License | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); }
Example #28
Source File: EvercamPlayApplication.java From evercam-android with GNU Affero General Public License v3.0 | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); }
Example #29
Source File: ExplorerApplication.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) { return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter); }
Example #30
Source File: HttpMediaDrmCallback.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private static byte[] executePost( HttpDataSource.Factory dataSourceFactory, String url, byte[] data, @Nullable Map<String, String> requestProperties) throws IOException { HttpDataSource dataSource = dataSourceFactory.createDataSource(); if (requestProperties != null) { for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) { dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue()); } } int manualRedirectCount = 0; while (true) { DataSpec dataSpec = new DataSpec( Uri.parse(url), data, /* absoluteStreamPosition= */ 0, /* position= */ 0, /* length= */ C.LENGTH_UNSET, /* key= */ null, DataSpec.FLAG_ALLOW_GZIP); DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec); try { return Util.toByteArray(inputStream); } catch (InvalidResponseCodeException e) { // For POST requests, the underlying network stack will not normally follow 307 or 308 // redirects automatically. Do so manually here. boolean manuallyRedirect = (e.responseCode == 307 || e.responseCode == 308) && manualRedirectCount++ < MAX_MANUAL_REDIRECTS; String redirectUrl = manuallyRedirect ? getRedirectUrl(e) : null; if (redirectUrl == null) { throw e; } url = redirectUrl; } finally { Util.closeQuietly(inputStream); } } }