Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ExoPlayerExample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Required permissions for the IMA SDK -->
<uses-permission android:name="android.permission.INTERNET"/>

<!-- Required by ExoPlayer when targeting Android 13+ to be able to post notifications. -->
<!-- See https://github.com/google/ExoPlayer/issues/10884 for more info. -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.google.ads.interactivemedia.v3.samples.exoplayerexample;

// [START imports]
import static android.os.Build.VERSION.SDK_INT;

import android.annotation.SuppressLint;
Expand All @@ -22,6 +23,9 @@
import com.google.ads.interactivemedia.v3.api.ImaSdkFactory;
import com.google.ads.interactivemedia.v3.api.ImaSdkSettings;

// [END imports]

// [START main_activity]
/** Main Activity. */
@SuppressLint("UnsafeOptInUsageError")
/* @SuppressLint is needed for new media3 APIs. */
Expand All @@ -41,6 +45,9 @@ public class MyActivity extends Activity {
private ImaAdsLoader adsLoader;
private ImaSdkSettings imaSdkSettings;

// [END main_activity]

// [START on_create]
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -62,6 +69,9 @@ protected void onCreate(Bundle savedInstanceState) {
.build();
}

// [END on_create]

// [START build_ad_event_listener]
public AdEvent.AdEventListener buildAdEventListener() {
logText = findViewById(R.id.logText);
logText.setMovementMethod(new ScrollingMovementMethod());
Expand All @@ -79,6 +89,9 @@ public AdEvent.AdEventListener buildAdEventListener() {
};
}

// [END build_ad_event_listener]

// [START player_events]
@Override
public void onStart() {
super.onStart();
Expand Down Expand Up @@ -130,6 +143,9 @@ protected void onDestroy() {
super.onDestroy();
}

// [END player_events]

// [START release_and_initialize_player]
private void releasePlayer() {
adsLoader.setPlayer(null);
playerView.setPlayer(null);
Expand Down Expand Up @@ -167,11 +183,15 @@ private void initializePlayer() {
player.setPlayWhenReady(false);
}

// [END release_and_initialize_player]

// [START get_ima_settings]
private ImaSdkSettings getImaSdkSettings() {
if (imaSdkSettings == null) {
imaSdkSettings = ImaSdkFactory.getInstance().createImaSdkSettings();
// Set any IMA SDK settings here.
}
return imaSdkSettings;
}
// [END get_ima_settings]
}