EarhornCastOptionsProvider.kt
Each line, with the release that last changed it.
| 0.5.0 | 1 | package dev.stave.cast |
| 2 | ||
| 3 | import android.content.Context | |
| 4 | import com.google.android.gms.cast.CastMediaControlIntent | |
| 5 | import com.google.android.gms.cast.framework.CastOptions | |
| 6 | import com.google.android.gms.cast.framework.OptionsProvider | |
| 7 | import com.google.android.gms.cast.framework.SessionProvider | |
| 8 | ||
| 9 | /** | |
| 10 | * Registered in the play-flavor manifest. Uses Google's Default Media | |
| 11 | * Receiver, so no Cast Developer Console registration is needed. | |
| 12 | */ | |
| 13 | class EarhornCastOptionsProvider : OptionsProvider { | |
| 14 | override fun getCastOptions(context: Context): CastOptions = | |
| 15 | CastOptions.Builder() | |
| 16 | .setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID) | |
| 17 | // Don't try to resume saved sessions or reconnect to | |
| 18 | // previously-connected devices. Stale session resume | |
| 19 | // fails silently — the user taps a speaker, nothing | |
| 20 | // happens, but other (never-before-connected) speakers | |
| 21 | // work fine. Fresh connection every time. | |
| 22 | .setResumeSavedSession(false) | |
| 23 | .setEnableReconnectionService(false) | |
| 24 | .setCastMediaOptions( | |
| 25 | com.google.android.gms.cast.framework.media.CastMediaOptions.Builder() | |
| 26 | .setNotificationOptions(null) | |
| 27 | .build() | |
| 28 | ) | |
| 29 | .build() | |
| 30 | ||
| 31 | override fun getAdditionalSessionProviders(context: Context): MutableList<SessionProvider>? = null | |
| 32 | } |


