diff --git a/advertising-optiview-ads/src/main/AndroidManifest.xml b/advertising-optiview-ads/src/main/AndroidManifest.xml index 0a69522..c892a03 100644 --- a/advertising-optiview-ads/src/main/AndroidManifest.xml +++ b/advertising-optiview-ads/src/main/AndroidManifest.xml @@ -1,7 +1,15 @@ + + + @@ -13,6 +21,7 @@ + + + + @@ -20,6 +28,7 @@ + diff --git a/basic-playback/src/main/AndroidManifest.xml b/basic-playback/src/main/AndroidManifest.xml index 0a69522..c892a03 100644 --- a/basic-playback/src/main/AndroidManifest.xml +++ b/basic-playback/src/main/AndroidManifest.xml @@ -1,7 +1,15 @@ + + + @@ -13,6 +21,7 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/custom-surface-rendering/src/main/AndroidManifest.xml b/custom-surface-rendering/src/main/AndroidManifest.xml index cf04f8f..12ede14 100644 --- a/custom-surface-rendering/src/main/AndroidManifest.xml +++ b/custom-surface-rendering/src/main/AndroidManifest.xml @@ -3,7 +3,15 @@ + + + @@ -15,6 +23,7 @@ + diff --git a/drm-playback/src/main/AndroidManifest.xml b/drm-playback/src/main/AndroidManifest.xml index 6ad827c..83432b0 100644 --- a/drm-playback/src/main/AndroidManifest.xml +++ b/drm-playback/src/main/AndroidManifest.xml @@ -3,7 +3,15 @@ + + + @@ -14,6 +22,7 @@ + diff --git a/full-screen-handling/src/main/AndroidManifest.xml b/full-screen-handling/src/main/AndroidManifest.xml index 4c48a4c..2c7b2f9 100644 --- a/full-screen-handling/src/main/AndroidManifest.xml +++ b/full-screen-handling/src/main/AndroidManifest.xml @@ -3,7 +3,15 @@ + + + @@ -16,6 +24,7 @@ + diff --git a/google-cast/src/main/AndroidManifest.xml b/google-cast/src/main/AndroidManifest.xml index 34134e0..6a84443 100644 --- a/google-cast/src/main/AndroidManifest.xml +++ b/google-cast/src/main/AndroidManifest.xml @@ -4,7 +4,15 @@ + + + @@ -27,6 +35,7 @@ + diff --git a/google-cast/src/main/java/com/theoplayer/sample/playback/cast/PlayerActivity.kt b/google-cast/src/main/java/com/theoplayer/sample/playback/cast/PlayerActivity.kt index 6eff3f7..622de5f 100644 --- a/google-cast/src/main/java/com/theoplayer/sample/playback/cast/PlayerActivity.kt +++ b/google-cast/src/main/java/com/theoplayer/sample/playback/cast/PlayerActivity.kt @@ -1,5 +1,6 @@ package com.theoplayer.sample.playback.cast +import android.content.Context import android.os.Bundle import android.util.Log import androidx.activity.compose.setContent @@ -15,6 +16,8 @@ import androidx.fragment.app.FragmentActivity import androidx.mediarouter.app.MediaRouteButton import com.google.android.gms.cast.framework.CastButtonFactory import com.google.android.gms.cast.framework.CastContext +import com.google.android.gms.common.ConnectionResult +import com.google.android.gms.common.GoogleApiAvailability import com.theoplayer.android.api.THEOplayerConfig import com.theoplayer.android.api.THEOplayerGlobal import com.theoplayer.android.api.THEOplayerView @@ -36,8 +39,25 @@ class PlayerActivity : FragmentActivity() { override fun onCreate(savedInstanceState: Bundle?) { + // Check if Cast API is available on the device (Google Play Services is available, CastContext can be initialized, and device is not an Android TV). + fun isCastAvailable(context: Context): Boolean { + when (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)) { + ConnectionResult.SUCCESS -> { + try { + CastContext.getSharedInstance(context) + return true + } catch (_: Exception) { + return false + } + } + else -> return false + } + } + // Initialize Chromecast immediately, for automatic receiver discovery to work correctly. - CastContext.getSharedInstance(this) + if (isCastAvailable(applicationContext)) { + CastContext.getSharedInstance(this) + } // Enable all debug logs from THEOplayer. THEOplayerGlobal.getSharedInstance(this).logger.enableAllTags() @@ -185,7 +205,9 @@ class PlayerActivity : FragmentActivity() { // CastButtonFactory.setUpMediaRouteButton() method. factory = { _ -> MediaRouteButton(context).apply { - CastButtonFactory.setUpMediaRouteButton(context, this) + if (isCastAvailable(applicationContext)) { + CastButtonFactory.setUpMediaRouteButton(context, this) + } } } ) diff --git a/google-dai/src/main/AndroidManifest.xml b/google-dai/src/main/AndroidManifest.xml index e96f5fd..a51e73b 100644 --- a/google-dai/src/main/AndroidManifest.xml +++ b/google-dai/src/main/AndroidManifest.xml @@ -3,7 +3,15 @@ + + + @@ -16,6 +24,7 @@ + diff --git a/google-ima/src/main/AndroidManifest.xml b/google-ima/src/main/AndroidManifest.xml index e96f5fd..a51e73b 100644 --- a/google-ima/src/main/AndroidManifest.xml +++ b/google-ima/src/main/AndroidManifest.xml @@ -3,7 +3,15 @@ + + + @@ -16,6 +24,7 @@ + diff --git a/localization/src/main/AndroidManifest.xml b/localization/src/main/AndroidManifest.xml index ec50aff..1dc17f7 100644 --- a/localization/src/main/AndroidManifest.xml +++ b/localization/src/main/AndroidManifest.xml @@ -1,7 +1,15 @@ + + + + + + + + diff --git a/offline-playback/src/main/AndroidManifest.xml b/offline-playback/src/main/AndroidManifest.xml index 4b93785..66661c1 100644 --- a/offline-playback/src/main/AndroidManifest.xml +++ b/offline-playback/src/main/AndroidManifest.xml @@ -9,7 +9,15 @@ + + + + diff --git a/open-video-ui/src/main/AndroidManifest.xml b/open-video-ui/src/main/AndroidManifest.xml index f025651..94e1f83 100644 --- a/open-video-ui/src/main/AndroidManifest.xml +++ b/open-video-ui/src/main/AndroidManifest.xml @@ -1,7 +1,15 @@ + + + + + + + @@ -18,6 +26,7 @@ + diff --git a/simple-ott/src/main/AndroidManifest.xml b/simple-ott/src/main/AndroidManifest.xml index a8ed247..7c56929 100644 --- a/simple-ott/src/main/AndroidManifest.xml +++ b/simple-ott/src/main/AndroidManifest.xml @@ -6,7 +6,15 @@ + + + + diff --git a/streaming-millicast/src/main/AndroidManifest.xml b/streaming-millicast/src/main/AndroidManifest.xml index 0a69522..c892a03 100644 --- a/streaming-millicast/src/main/AndroidManifest.xml +++ b/streaming-millicast/src/main/AndroidManifest.xml @@ -1,7 +1,15 @@ + + + @@ -13,6 +21,7 @@ + + + + @@ -13,6 +21,7 @@ +