diff --git a/demos/ima/README.md b/demos/ima/README.md deleted file mode 100644 index 8002b56667..0000000000 --- a/demos/ima/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# IMA demo application # - -This folder contains a demo application that showcases ExoPlayer integration -with the IMA SDK. diff --git a/demos/ima/build.gradle b/demos/ima/build.gradle deleted file mode 100644 index 289fa1dc83..0000000000 --- a/demos/ima/build.gradle +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2017 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -apply from: '../../constants.gradle' -apply plugin: 'com.android.application' - -android { - compileSdkVersion project.ext.compileSdkVersion - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - defaultConfig { - versionName project.ext.releaseVersion - versionCode project.ext.releaseVersionCode - minSdkVersion project.ext.minSdkVersion - targetSdkVersion project.ext.targetSdkVersion - } - - buildTypes { - release { - shrinkResources true - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt') - } - debug { - jniDebuggable = true - } - } - - lintOptions { - // The demo app isn't indexed and doesn't have translations. - disable 'GoogleAppIndexingWarning','MissingTranslation' - } -} - -dependencies { - implementation project(modulePrefix + 'library-core') - implementation project(modulePrefix + 'library-ui') - implementation project(modulePrefix + 'library-dash') - implementation project(modulePrefix + 'library-hls') - implementation project(modulePrefix + 'library-smoothstreaming') - implementation project(modulePrefix + 'extension-ima') - implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion -} - -apply plugin: 'com.google.android.gms.strict-version-matcher-plugin' diff --git a/demos/ima/src/main/AndroidManifest.xml b/demos/ima/src/main/AndroidManifest.xml deleted file mode 100644 index 85439018fd..0000000000 --- a/demos/ima/src/main/AndroidManifest.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/demos/ima/src/main/java/com/google/android/exoplayer2/imademo/MainActivity.java b/demos/ima/src/main/java/com/google/android/exoplayer2/imademo/MainActivity.java deleted file mode 100644 index 9988108f32..0000000000 --- a/demos/ima/src/main/java/com/google/android/exoplayer2/imademo/MainActivity.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.imademo; - -import android.app.Activity; -import android.os.Bundle; -import com.google.android.exoplayer2.ExoPlayer; -import com.google.android.exoplayer2.ui.PlayerView; - -/** - * Main Activity for the IMA plugin demo. {@link ExoPlayer} objects are created by - * {@link PlayerManager}, which this class instantiates. - */ -public final class MainActivity extends Activity { - - private PlayerView playerView; - private PlayerManager player; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main_activity); - playerView = findViewById(R.id.player_view); - player = new PlayerManager(this); - } - - @Override - public void onResume() { - super.onResume(); - player.init(this, playerView); - } - - @Override - public void onPause() { - super.onPause(); - player.reset(); - } - - @Override - public void onDestroy() { - player.release(); - super.onDestroy(); - } - -} diff --git a/demos/ima/src/main/java/com/google/android/exoplayer2/imademo/PlayerManager.java b/demos/ima/src/main/java/com/google/android/exoplayer2/imademo/PlayerManager.java deleted file mode 100644 index 3caf7f0c16..0000000000 --- a/demos/ima/src/main/java/com/google/android/exoplayer2/imademo/PlayerManager.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.imademo; - -import android.content.Context; -import android.net.Uri; -import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.C.ContentType; -import com.google.android.exoplayer2.ExoPlayer; -import com.google.android.exoplayer2.SimpleExoPlayer; -import com.google.android.exoplayer2.ext.ima.ImaAdsLoader; -import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.MediaSourceFactory; -import com.google.android.exoplayer2.source.ProgressiveMediaSource; -import com.google.android.exoplayer2.source.ads.AdsMediaSource; -import com.google.android.exoplayer2.source.dash.DashMediaSource; -import com.google.android.exoplayer2.source.hls.HlsMediaSource; -import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource; -import com.google.android.exoplayer2.ui.PlayerView; -import com.google.android.exoplayer2.upstream.DataSource; -import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; -import com.google.android.exoplayer2.util.Util; - -/** Manages the {@link ExoPlayer}, the IMA plugin and all video playback. */ -/* package */ final class PlayerManager implements MediaSourceFactory { - - private final ImaAdsLoader adsLoader; - private final DataSource.Factory dataSourceFactory; - - private SimpleExoPlayer player; - private long contentPosition; - - public PlayerManager(Context context) { - String adTag = context.getString(R.string.ad_tag_url); - adsLoader = new ImaAdsLoader(context, Uri.parse(adTag)); - dataSourceFactory = - new DefaultDataSourceFactory( - context, Util.getUserAgent(context, context.getString(R.string.application_name))); - } - - public void init(Context context, PlayerView playerView) { - // Create a player instance. - player = new SimpleExoPlayer.Builder(context).build(); - adsLoader.setPlayer(player); - playerView.setPlayer(player); - - // This is the MediaSource representing the content media (i.e. not the ad). - String contentUrl = context.getString(R.string.content_url); - MediaSource contentMediaSource = buildMediaSource(Uri.parse(contentUrl)); - - // Compose the content media source into a new AdsMediaSource with both ads and content. - MediaSource mediaSourceWithAds = - new AdsMediaSource( - contentMediaSource, /* adMediaSourceFactory= */ this, adsLoader, playerView); - - // Prepare the player with the source. - player.seekTo(contentPosition); - player.prepare(mediaSourceWithAds); - player.setPlayWhenReady(true); - } - - public void reset() { - if (player != null) { - contentPosition = player.getContentPosition(); - player.release(); - player = null; - adsLoader.setPlayer(null); - } - } - - public void release() { - if (player != null) { - player.release(); - player = null; - } - adsLoader.release(); - } - - // MediaSourceFactory implementation. - - @Override - public MediaSource createMediaSource(Uri uri) { - return buildMediaSource(uri); - } - - @Override - public int[] getSupportedTypes() { - // IMA does not support Smooth Streaming ads. - return new int[] {C.TYPE_DASH, C.TYPE_HLS, C.TYPE_OTHER}; - } - - // Internal methods. - - private MediaSource buildMediaSource(Uri uri) { - @ContentType int type = Util.inferContentType(uri); - switch (type) { - case C.TYPE_DASH: - return new DashMediaSource.Factory(dataSourceFactory).createMediaSource(uri); - case C.TYPE_SS: - return new SsMediaSource.Factory(dataSourceFactory).createMediaSource(uri); - case C.TYPE_HLS: - return new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri); - case C.TYPE_OTHER: - return new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri); - default: - throw new IllegalStateException("Unsupported type: " + type); - } - } - -} diff --git a/demos/ima/src/main/res/layout/main_activity.xml b/demos/ima/src/main/res/layout/main_activity.xml deleted file mode 100644 index f7ea5c9b88..0000000000 --- a/demos/ima/src/main/res/layout/main_activity.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - diff --git a/demos/ima/src/main/res/mipmap-hdpi/ic_launcher.png b/demos/ima/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index adaa93220e..0000000000 Binary files a/demos/ima/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/demos/ima/src/main/res/mipmap-mdpi/ic_launcher.png b/demos/ima/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 9b6f7d5e80..0000000000 Binary files a/demos/ima/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/demos/ima/src/main/res/mipmap-xhdpi/ic_launcher.png b/demos/ima/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 2101026c9f..0000000000 Binary files a/demos/ima/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/demos/ima/src/main/res/mipmap-xxhdpi/ic_launcher.png b/demos/ima/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 223ec8bd11..0000000000 Binary files a/demos/ima/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/demos/ima/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/demos/ima/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 698ed68c42..0000000000 Binary files a/demos/ima/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/demos/ima/src/main/res/values/strings.xml b/demos/ima/src/main/res/values/strings.xml deleted file mode 100644 index 2eb5700bf0..0000000000 --- a/demos/ima/src/main/res/values/strings.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Exo IMA Demo - - - - - - diff --git a/demos/ima/src/main/res/values/styles.xml b/demos/ima/src/main/res/values/styles.xml deleted file mode 100644 index 1c78ad58df..0000000000 --- a/demos/ima/src/main/res/values/styles.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/settings.gradle b/settings.gradle index 2708596a9e..3e544854ad 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,13 +20,11 @@ if (gradle.ext.has('exoplayerModulePrefix')) { include modulePrefix + 'demo' include modulePrefix + 'demo-cast' -include modulePrefix + 'demo-ima' include modulePrefix + 'demo-gvr' include modulePrefix + 'demo-surface' include modulePrefix + 'playbacktests' project(modulePrefix + 'demo').projectDir = new File(rootDir, 'demos/main') project(modulePrefix + 'demo-cast').projectDir = new File(rootDir, 'demos/cast') -project(modulePrefix + 'demo-ima').projectDir = new File(rootDir, 'demos/ima') project(modulePrefix + 'demo-gvr').projectDir = new File(rootDir, 'demos/gvr') project(modulePrefix + 'demo-surface').projectDir = new File(rootDir, 'demos/surface') project(modulePrefix + 'playbacktests').projectDir = new File(rootDir, 'playbacktests')