Commit 0c159984 by andrewlewis Committed by Andrew Lewis

Set player on ads loader in IMA demo

Issue: #5476
PiperOrigin-RevId: 232503736
parent 85b8e1f7
...@@ -29,10 +29,6 @@ import com.google.android.exoplayer2.source.ads.AdsMediaSource; ...@@ -29,10 +29,6 @@ import com.google.android.exoplayer2.source.ads.AdsMediaSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource; import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
...@@ -56,14 +52,9 @@ import com.google.android.exoplayer2.util.Util; ...@@ -56,14 +52,9 @@ import com.google.android.exoplayer2.util.Util;
} }
public void init(Context context, PlayerView playerView) { public void init(Context context, PlayerView playerView) {
// Create a default track selector.
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
// Create a player instance. // Create a player instance.
player = ExoPlayerFactory.newSimpleInstance(context, trackSelector); player = ExoPlayerFactory.newSimpleInstance(context);
adsLoader.setPlayer(player);
// Bind the player to the view.
playerView.setPlayer(player); playerView.setPlayer(player);
// This is the MediaSource representing the content media (i.e. not the ad). // This is the MediaSource representing the content media (i.e. not the ad).
...@@ -89,6 +80,7 @@ import com.google.android.exoplayer2.util.Util; ...@@ -89,6 +80,7 @@ import com.google.android.exoplayer2.util.Util;
contentPosition = player.getContentPosition(); contentPosition = player.getContentPosition();
player.release(); player.release();
player = null; player = null;
adsLoader.setPlayer(null);
} }
} }
......
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