-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
222 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application> | ||
<meta-data | ||
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" | ||
android:value="com.profusion.androidenhancedvideoplayer.CastOptionsProvider"/> | ||
</application> | ||
|
||
</manifest> |
25 changes: 25 additions & 0 deletions
25
...videoplayer/src/main/java/com/profusion/androidenhancedvideoplayer/CastOptionsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.profusion.androidenhancedvideoplayer | ||
|
||
import android.content.Context | ||
import com.google.android.gms.cast.CastMediaControlIntent | ||
import com.google.android.gms.cast.LaunchOptions | ||
import com.google.android.gms.cast.framework.CastOptions | ||
import com.google.android.gms.cast.framework.OptionsProvider | ||
import com.google.android.gms.cast.framework.SessionProvider | ||
|
||
class CastOptionsProvider : OptionsProvider { | ||
override fun getCastOptions(context: Context): CastOptions { | ||
val launchOptions = LaunchOptions.Builder() | ||
.setAndroidReceiverCompatible(true) | ||
.build() | ||
return CastOptions.Builder() | ||
.setLaunchOptions(launchOptions) | ||
.setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID) | ||
.setStopReceiverApplicationWhenEndingSession(true) | ||
.build() | ||
} | ||
|
||
override fun getAdditionalSessionProviders(p0: Context): MutableList<SessionProvider>? { | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
.../main/java/com/profusion/androidenhancedvideoplayer/components/mediaRouter/MediaRouter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.profusion.androidenhancedvideoplayer.components.mediaRouter | ||
|
||
import android.content.Context | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.viewinterop.AndroidView | ||
import com.google.android.gms.cast.framework.CastContext | ||
import com.profusion.androidenhancedvideoplayer.styling.Dimensions | ||
|
||
@Composable | ||
fun MediaRouter(context: Context, modifier: Modifier = Modifier) { | ||
val viewModel = MediaRouterViewModel(context) | ||
val castContext = CastContext.getSharedInstance() | ||
|
||
if (castContext != null) { | ||
Box(modifier = modifier) { | ||
AndroidView( | ||
factory = { viewModel.mediaRouteButton() }, | ||
modifier = Modifier.size(Dimensions.xlarge) | ||
) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...a/com/profusion/androidenhancedvideoplayer/components/mediaRouter/MediaRouterViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.profusion.androidenhancedvideoplayer.components.mediaRouter | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import androidx.lifecycle.ViewModel | ||
import androidx.mediarouter.app.MediaRouteActionProvider | ||
import androidx.mediarouter.media.MediaControlIntent | ||
import androidx.mediarouter.media.MediaRouteSelector | ||
|
||
class MediaRouterViewModel(context: Context) : ViewModel() { | ||
private val mediaRouteActionProvider = MediaRouteActionProvider(context) | ||
|
||
init { | ||
mediaRouteActionProvider.onCreateMediaRouteButton() | ||
mediaRouteActionProvider.routeSelector = MediaRouteSelector.Builder() | ||
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK) | ||
.build() | ||
} | ||
|
||
fun mediaRouteButton(): View { | ||
return mediaRouteActionProvider.onCreateActionView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.