diff --git a/android/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java b/android/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java index 907d72e6..70a75356 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java +++ b/android/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java @@ -87,11 +87,16 @@ public class DataSourceUtil { ForwardingCookieHandler handler = new ForwardingCookieHandler(context); container.setCookieJar(new JavaNetCookieJar(handler)); OkHttpDataSource.Factory okHttpDataSourceFactory = new OkHttpDataSource.Factory((Call.Factory) client) - .setUserAgent(getUserAgent(context)) .setTransferListener(bandwidthMeter); - if (requestHeaders != null) + if (requestHeaders != null) { okHttpDataSourceFactory.setDefaultRequestProperties(requestHeaders); + if (!requestHeaders.containsKey("User-Agent")) { + okHttpDataSourceFactory.setUserAgent(getUserAgent(context)); + } + } else { + okHttpDataSourceFactory.setUserAgent(getUserAgent(context)); + } return okHttpDataSourceFactory; }