Skip to content

Commit

Permalink
Updates the samples for IMA v3.33.0.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 621544981
  • Loading branch information
google-ima-devrel-bot authored and IMA Developer Relations committed Apr 3, 2024
1 parent e76eca1 commit 7402952
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 26 deletions.
4 changes: 2 additions & 2 deletions AdvancedExample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.mediarouter:mediarouter:1.6.0'
implementation 'androidx.mediarouter:mediarouter:1.7.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.31.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0'
}
2 changes: 1 addition & 1 deletion AdvancedExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}
2 changes: 1 addition & 1 deletion ExoPlayerExample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repositories {
}

dependencies {
def media3_version = "1.1.1"
def media3_version = "1.3.0"
implementation "androidx.media3:media3-ui:$media3_version"
implementation "androidx.media3:media3-exoplayer:$media3_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.util.Log;
import android.widget.TextView;
import androidx.media3.common.MediaItem;
import androidx.media3.common.util.Util;
import androidx.media3.datasource.DataSource;
import androidx.media3.datasource.DefaultDataSource;
import androidx.media3.exoplayer.ExoPlayer;
Expand Down Expand Up @@ -35,6 +34,7 @@ public class MyActivity extends Activity {
private ImaAdsLoader adsLoader;

@Override
@androidx.media3.common.util.UnstableApi
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
Expand Down Expand Up @@ -70,9 +70,10 @@ public AdEvent.AdEventListener buildAdEventListener() {
}

@Override
@androidx.media3.common.util.UnstableApi
public void onStart() {
super.onStart();
if (Util.SDK_INT > 23) {
if (VERSION.SDK_INT > 23) {
initializePlayer();
if (playerView != null) {
playerView.onResume();
Expand All @@ -81,9 +82,10 @@ public void onStart() {
}

@Override
@androidx.media3.common.util.UnstableApi
public void onResume() {
super.onResume();
if (Util.SDK_INT <= 23 || player == null) {
if (VERSION.SDK_INT <= 23 || player == null) {
initializePlayer();
if (playerView != null) {
playerView.onResume();
Expand All @@ -94,7 +96,7 @@ public void onResume() {
@Override
public void onPause() {
super.onPause();
if (Util.SDK_INT <= 23) {
if (VERSION.SDK_INT <= 23) {
if (playerView != null) {
playerView.onPause();
}
Expand All @@ -105,7 +107,7 @@ public void onPause() {
@Override
public void onStop() {
super.onStop();
if (Util.SDK_INT > 23) {
if (VERSION.SDK_INT > 23) {
if (playerView != null) {
playerView.onPause();
}
Expand All @@ -127,6 +129,7 @@ private void releasePlayer() {
player = null;
}

@androidx.media3.common.util.UnstableApi
private void initializePlayer() {
// Set up the factory for media sources, passing the ads loader and ad view providers.
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(this);
Expand Down
2 changes: 1 addition & 1 deletion ExoPlayerExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.android.tools.build:gradle:8.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
8 changes: 4 additions & 4 deletions audioplayerexample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
}
defaultConfig {
applicationId "com.google.ads.interactivemedia.v3.samples.audioplayerexample"
minSdkVersion 21
minSdkVersion 29
targetSdkVersion 34
versionCode 1
versionName "1.0"
Expand All @@ -43,12 +43,12 @@ repositories {
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.media:media:1.6.0'
def media3_version = "1.1.1"
implementation 'androidx.media:media:1.7.0'
def media3_version = "1.3.0"
implementation "androidx.media3:media3-ui:$media3_version"
implementation "androidx.media3:media3-exoplayer:$media3_version"
implementation "androidx.media3:media3-session:$media3_version"

implementation 'com.google.guava:guava:28.1-android'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.31.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0'
}
4 changes: 3 additions & 1 deletion audioplayerexample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<!-- Required for background audio playback. -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>

<!-- Required by ExoPlayer when targeting Android 13+ to be able to post notifications. -->
<!-- See https://github.com/google/ExoPlayer/issues/10884 for more info. -->
Expand All @@ -38,6 +39,7 @@
</intent-filter>
</activity>
<service android:name=".AudioPlayerService"
android:exported="false"/>
android:exported="false"
android:foregroundServiceType="mediaPlayback"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.graphics.Bitmap;
import android.os.Binder;
import android.os.IBinder;
Expand Down Expand Up @@ -127,7 +128,10 @@ public void onNotificationStarted(
int notificationId, Notification notification, boolean ongoing) {
// This must be called within 5 seconds of the notification being displayed and
// before the main app has been killed.
startForeground(notificationId, notification);
startForeground(
notificationId,
notification,
ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion audioplayerexample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}
6 changes: 3 additions & 3 deletions basicexample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repositories {
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.browser:browser:1.6.0'
implementation 'androidx.media:media:1.6.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.31.0'
implementation 'androidx.browser:browser:1.8.0'
implementation 'androidx.media:media:1.7.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0'
}
2 changes: 1 addition & 1 deletion basicexample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.android.tools.build:gradle:8.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
8 changes: 4 additions & 4 deletions umpexample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ repositories {
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.browser:browser:1.6.0'
implementation 'androidx.media:media:1.6.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.31.0'
implementation 'com.google.android.ump:user-messaging-platform:2.1.0'
implementation 'androidx.browser:browser:1.8.0'
implementation 'androidx.media:media:1.7.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0'
implementation 'com.google.android.ump:user-messaging-platform:2.2.0'
}
2 changes: 1 addition & 1 deletion umpexample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.android.tools.build:gradle:8.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 7402952

Please sign in to comment.