Commit b6b6a3cb by eguven Committed by Oliver Woodman

Merge build*DataSourceFactory methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131291816
parent 8b3f489b
...@@ -136,7 +136,7 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi ...@@ -136,7 +136,7 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
userAgent = Util.getUserAgent(this, "ExoPlayerDemo"); userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
mediaDataSourceFactory = buildMediaDataSourceFactory(); mediaDataSourceFactory = buildDataSourceFactory(true);
mainHandler = new Handler(); mainHandler = new Handler();
if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) { if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER); CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
...@@ -339,10 +339,10 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi ...@@ -339,10 +339,10 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi
: uri.getLastPathSegment()); : uri.getLastPathSegment());
switch (type) { switch (type) {
case Util.TYPE_SS: case Util.TYPE_SS:
return new SsMediaSource(uri, buildManifestDataSourceFactory(), return new SsMediaSource(uri, buildDataSourceFactory(false),
new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger); new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
case Util.TYPE_DASH: case Util.TYPE_DASH:
return new DashMediaSource(uri, buildManifestDataSourceFactory(), return new DashMediaSource(uri, buildDataSourceFactory(false),
new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger); new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
case Util.TYPE_HLS: case Util.TYPE_HLS:
return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger); return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
...@@ -393,14 +393,15 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi ...@@ -393,14 +393,15 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi
} }
} }
/** Build a DataSource factory for manifest data, that does not affect the bandwidth estimate. */ /**
private DataSource.Factory buildManifestDataSourceFactory() { * Build a DataSource factory.
return new DefaultDataSourceFactory(this, userAgent); *
} * @param useBandwidthMeter Whether to set {@link #BANDWIDTH_METER} as a listener to the new
* DataSource factory.
/** Build a DataSource factory for media data, that does affect the bandwidth estimate. */ */
private DataSource.Factory buildMediaDataSourceFactory() { private DataSource.Factory buildDataSourceFactory(boolean useBandwidthMeter) {
return new DefaultDataSourceFactory(this, userAgent, BANDWIDTH_METER); return new DefaultDataSourceFactory(this, userAgent,
useBandwidthMeter ? BANDWIDTH_METER : null);
} }
// ExoPlayer.EventListener implementation // ExoPlayer.EventListener implementation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment