Skip to content

Commit

Permalink
Expose Android SurfaceType
Browse files Browse the repository at this point in the history
untracked
  • Loading branch information
krocard committed Dec 20, 2024
1 parent 048d296 commit 011f180
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Update Bitmovin's native iOS SDK version to `3.80.0`

### Added

- Android: `PlayerViewConfig.surfaceType` that allows to render video on a `TextureView`

## [0.35.0] - 2024-12-10

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import com.bitmovin.player.api.source.TimelineReferencePoint
import com.bitmovin.player.api.ui.PlayerViewConfig
import com.bitmovin.player.api.ui.ScalingMode
import com.bitmovin.player.api.ui.StyleConfig
import com.bitmovin.player.api.ui.SurfaceType
import com.bitmovin.player.api.ui.UiConfig
import com.bitmovin.player.reactnative.BitmovinCastManagerOptions
import com.bitmovin.player.reactnative.PictureInPictureConfig
Expand Down Expand Up @@ -772,8 +773,15 @@ fun ReadableMap.toPictureInPictureConfig(): PictureInPictureConfig = PictureInPi
fun ReadableMap.toPlayerViewConfig(): PlayerViewConfig = PlayerViewConfig(
uiConfig = getMap("uiConfig")?.toUiConfig() ?: UiConfig.WebUi(),
hideFirstFrame = getBooleanOrNull("hideFirstFrame") ?: false,
surfaceType = getString("surfaceType")?.toSurfaceType() ?: SurfaceType.SurfaceView,
)

private fun String.toSurfaceType(): SurfaceType? = when (this) {
"SurfaceView" -> SurfaceType.SurfaceView
"TextureView" -> SurfaceType.TextureView
else -> null
}

private fun ReadableMap.toUiConfig(): UiConfig {
val variant = toVariant() ?: UiConfig.WebUi.Variant.SmallScreenUi
val focusUiOnInitialization = getBooleanOrNull("focusUiOnInitialization")
Expand Down
28 changes: 28 additions & 0 deletions src/components/PlayerView/playerViewConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ export interface PlayerViewConfig {
* To reliably hide the first frame before a pre-roll ad, please ensure that you are using the {@link AdvertisingConfig} to schedule ads and not the {@link Player.scheduleAd} API call.
*/
hideFirstFrame?: boolean;

/**
* Specify on which surface type the video should be rendered.
*
* See {@link https://developer.android.com/guide/topics/media/ui/playerview#surfacetype|Choosing a surface type}
* for more information.
*
* Default is {@link SurfaceType.SurfaceView}.
*
* @platform Android
*/
surfaceType?: SurfaceType;
}

/**
Expand Down Expand Up @@ -97,3 +109,19 @@ export class CustomUi extends Variant {
super(uiManagerFactoryFunction);
}
}

/**
* The type of surface on which to render video.
*
* See {@link https://developer.android.com/guide/topics/media/ui/playerview#surfacetype|Choosing a surface type}
* for more information.
*/
export enum SurfaceType {
/**
* SurfaceView generally causes lower battery consumption,
* and has better handling for HDR and secure content.
*/
SurfaceView,
/** TextureView is sometime needed for smooth animations. */
TextureView,
}

0 comments on commit 011f180

Please sign in to comment.