Skip to content

Commit 9f75728

Browse files
fix: Lint issues
1 parent ad70563 commit 9f75728

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

NRExoPlayerTracker/src/main/java/com/newrelic/videoagent/exoplayer/tracker/NRTrackerExoPlayer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import android.os.Looper;
66

77
import androidx.annotation.NonNull;
8+
import androidx.annotation.OptIn;
9+
import androidx.media3.common.util.UnstableApi;
810
import androidx.media3.common.C;
911
import androidx.media3.common.MediaLibraryInfo;
1012
import androidx.media3.common.MediaMetadata;
@@ -37,7 +39,12 @@
3739

3840
/**
3941
* New Relic Video tracker for ExoPlayer.
42+
* <p>
43+
* @OptIn is required for Media3 APIs which are marked as @UnstableApi.
44+
* This is by design as per Google's Media3 documentation.
45+
* @see <a href="https://developer.android.com/media/media3/exoplayer/customization#unstable-api">Media3 Unstable API Documentation</a>
4046
*/
47+
@OptIn(markerClass = UnstableApi.class)
4148
public class NRTrackerExoPlayer extends NRVideoTracker implements Player.Listener, AnalyticsListener {
4249

4350
protected ExoPlayer player;

app/src/main/java/com/newrelic/nrvideoproject/VideoPlayerAds.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,28 @@
88
import com.newrelic.videoagent.core.NRVideoPlayerConfiguration;
99
import androidx.appcompat.app.AppCompatActivity;
1010
import androidx.media3.common.MediaItem;
11-
import androidx.media3.common.util.Util;
1211
import androidx.media3.datasource.DataSource;
13-
import androidx.media3.datasource.DefaultDataSourceFactory;
14-
import androidx.media3.exoplayer.SimpleExoPlayer;
12+
import androidx.media3.datasource.DefaultDataSource;
13+
import androidx.media3.exoplayer.ExoPlayer;
1514
import androidx.media3.exoplayer.ima.ImaAdsLoader;
1615
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory;
1716
import androidx.media3.ui.PlayerView;
17+
import androidx.annotation.OptIn;
18+
import androidx.media3.common.util.UnstableApi;
1819

1920
import android.util.Log;
2021
import com.newrelic.videoagent.core.NewRelicVideoAgent;
2122
import com.newrelic.videoagent.ima.tracker.NRTrackerIMA;
2223

24+
/**
25+
* @OptIn is required for Media3 IMA ads integration APIs which are marked as @UnstableApi.
26+
* This is by design as per Google's Media3 documentation.
27+
* @see <a href="https://developer.android.com/media/media3/exoplayer/customization#unstable-api">Media3 Unstable API Documentation</a>
28+
*/
29+
@OptIn(markerClass = UnstableApi.class)
2330
public class VideoPlayerAds extends AppCompatActivity implements AdErrorEvent.AdErrorListener, AdEvent.AdEventListener {
2431

25-
private SimpleExoPlayer player;
32+
private ExoPlayer player;
2633
private Integer trackerId;
2734
private ImaAdsLoader adsLoader;
2835
private PlayerView playerView;
@@ -67,13 +74,12 @@ protected void onDestroy() {
6774

6875
private void playVideo(String videoUrl) {
6976
// Set up the factory for media sources, passing the ads loader and ad view providers.
70-
DataSource.Factory dataSourceFactory =
71-
new DefaultDataSourceFactory(this, Util.getUserAgent(this, getString(R.string.app_name)));
77+
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(this);
7278
DefaultMediaSourceFactory mediaSourceFactory = new DefaultMediaSourceFactory(dataSourceFactory);
7379
mediaSourceFactory.setAdsLoaderProvider(unusedAdTagUri -> adsLoader);
7480
mediaSourceFactory.setAdViewProvider(playerView);
7581

76-
player = new SimpleExoPlayer.Builder(this).setMediaSourceFactory(mediaSourceFactory).build();
82+
player = new ExoPlayer.Builder(this).setMediaSourceFactory(mediaSourceFactory).build();
7783
NRVideoPlayerConfiguration playerConfiguration = new NRVideoPlayerConfiguration("test-player-something-else", player, true, null);
7884
trackerId = NRVideo.addPlayer(playerConfiguration);
7985
adTracker = (NRTrackerIMA) NewRelicVideoAgent.getInstance().getAdTracker(trackerId);
@@ -93,7 +99,7 @@ private void playVideo(String videoUrl) {
9399
Uri contentUri = Uri.parse(videoUrl);
94100
Uri adTagUri = Uri.parse(getString(R.string.ad_tag_url));
95101
MediaItem mediaItem = new MediaItem.Builder().setUri(contentUri).setAdTagUri(adTagUri).build();
96-
// Prepare the content and ad to be played with the SimpleExoPlayer.
102+
// Prepare the content and ad to be played with the ExoPlayer.
97103
player.setMediaItem(mediaItem);
98104
// Set PlayWhenReady. If true, content and ads will autoplay.
99105
player.setPlayWhenReady(true);

0 commit comments

Comments
 (0)