mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
[ui-compose] Add default value to PlayerSurface
's surfaceType
PlayerView's default surface type was also SURFACE_VIEW. This allows for a simple `PlayerSurface(player)` usage by most developers. The order of the arguments needs to be changed, because `modifier` should be the first default argument (https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-component-api-guidelines.md#parameter) PiperOrigin-RevId: 731294658
This commit is contained in:
parent
ac1cf206c8
commit
afea6962c2
@ -17,8 +17,6 @@
|
||||
package androidx.media3.ui.compose
|
||||
|
||||
import android.view.Surface
|
||||
import android.view.SurfaceView
|
||||
import android.view.TextureView
|
||||
import androidx.annotation.IntDef
|
||||
import androidx.compose.foundation.AndroidEmbeddedExternalSurface
|
||||
import androidx.compose.foundation.AndroidExternalSurface
|
||||
@ -33,8 +31,9 @@ import androidx.media3.common.util.UnstableApi
|
||||
/**
|
||||
* Provides a dedicated drawing [Surface] for media playbacks using a [Player].
|
||||
*
|
||||
* The player's video output is displayed with either a [SurfaceView]/[AndroidExternalSurface] or a
|
||||
* [TextureView]/[AndroidEmbeddedExternalSurface].
|
||||
* The player's video output is displayed with either a
|
||||
* [android.view.SurfaceView]/[AndroidExternalSurface] or a
|
||||
* [android.view.TextureView]/[AndroidEmbeddedExternalSurface].
|
||||
*
|
||||
* [Player] takes care of attaching the rendered output to the [Surface] and clearing it, when it is
|
||||
* destroyed.
|
||||
@ -45,7 +44,11 @@ import androidx.media3.common.util.UnstableApi
|
||||
*/
|
||||
@UnstableApi
|
||||
@Composable
|
||||
fun PlayerSurface(player: Player, surfaceType: @SurfaceType Int, modifier: Modifier = Modifier) {
|
||||
fun PlayerSurface(
|
||||
player: Player,
|
||||
modifier: Modifier = Modifier,
|
||||
surfaceType: @SurfaceType Int = SURFACE_TYPE_SURFACE_VIEW,
|
||||
) {
|
||||
// Player might change between compositions,
|
||||
// we need long-lived surface-related lambdas to always use the latest value
|
||||
val currentPlayer by rememberUpdatedState(player)
|
||||
@ -83,7 +86,7 @@ fun PlayerSurface(player: Player, surfaceType: @SurfaceType Int, modifier: Modif
|
||||
@IntDef(SURFACE_TYPE_SURFACE_VIEW, SURFACE_TYPE_TEXTURE_VIEW)
|
||||
annotation class SurfaceType
|
||||
|
||||
/** Surface type equivalent to [SurfaceView] . */
|
||||
/** Surface type equivalent to [android.view.SurfaceView]. */
|
||||
@UnstableApi const val SURFACE_TYPE_SURFACE_VIEW = 1
|
||||
/** Surface type equivalent to [TextureView]. */
|
||||
/** Surface type equivalent to [android.view.TextureView]. */
|
||||
@UnstableApi const val SURFACE_TYPE_TEXTURE_VIEW = 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user