Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Added Android support for `ABRConfiguration.preferredMaximumResolution`, mirroring the existing iOS behaviour. Set to `(0,0)` to remove the cap.
- Added basic support for CMCD event mode reporting of DRM and ad events.
- Added bridging of the `hlsDateRange` property from `PlayerConfiguration` to Android's `THEOplayerConfig`.

Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ repositories {
mavenLocal()
}

// The minimum supported THEOplayer version is 11.4.0
def theoVersion = safeExtGet('THEOplayer_sdk', '[11.4.0, 12.0.0)')
// The minimum supported THEOplayer version is 11.5.0
def theoVersion = safeExtGet('THEOplayer_sdk', '[11.5.0, 12.0.0)')
def theoMediaSessionVersion = safeExtGet('THEOplayer_mediasession', '[11.0.0, 12.0.0)')
def theoAdsWrapperVersion = "11.0.0"
def coroutinesVersion = safeExtGet('coroutinesVersion', '1.10.2')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.theoplayer.abr

import android.util.Size
import com.facebook.react.bridge.ReadableMap
import com.theoplayer.android.api.abr.AbrStrategyConfiguration
import com.theoplayer.android.api.abr.AbrStrategyMetadata
Expand All @@ -12,6 +13,9 @@ object ABRConfigurationAdapter {
private const val PROP_METADATA = "metadata"
private const val PROP_TYPE = "type"
private const val PROP_BITRATE = "bitrate"
private const val PROP_PREFERRED_MAXIMUM_RESOLUTION = "preferredMaximumResolution"
private const val PROP_WIDTH = "width"
private const val PROP_HEIGHT = "height"

fun applyABRConfigurationFromProps(player: Player?, abrProps: ReadableMap?) {
if (abrProps == null || player == null) {
Expand All @@ -20,6 +24,11 @@ object ABRConfigurationAdapter {
if (abrProps.hasKey(PROP_TARGET_BUFFER)) {
player.abr.targetBuffer = abrProps.getInt(PROP_TARGET_BUFFER)
}
// (0,0) is the documented sentinel for "no cap" and maps to a null Size on the native SDK.
val preferredMaximumResolutionProps = abrProps.getMap(PROP_PREFERRED_MAXIMUM_RESOLUTION)
if (preferredMaximumResolutionProps != null) {
player.abr.preferredMaximumResolution = preferredMaximumResolutionFromProps(preferredMaximumResolutionProps)
}
// Strategy can be either a string or an object
try {
val abrStrategyPropsString = abrProps.getString(PROP_STRATEGY)
Expand Down Expand Up @@ -50,6 +59,18 @@ object ABRConfigurationAdapter {
}
}

private fun preferredMaximumResolutionFromProps(props: ReadableMap?): Size? {
if (props == null || !props.hasKey(PROP_WIDTH) || !props.hasKey(PROP_HEIGHT)) {
return null
}
val width = props.getDouble(PROP_WIDTH).toInt()
val height = props.getDouble(PROP_HEIGHT).toInt()
if (width <= 0 || height <= 0) {
return null
}
return Size(width, height)
}

private fun abrMetadataFromProps(props: ReadableMap?): AbrStrategyMetadata? {
if (props == null) {
return null
Expand Down
8 changes: 8 additions & 0 deletions doc/abr.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ on the chosen strategy, as well as various parameters of the playback buffer.
| `targetBuffer` | The amount that the player should buffer ahead of the current playback position, in seconds. Default is **20**s. | Android & Web |
| `bufferLookbackWindow` | The amount of data which the player should keep in its buffer before the current playback position, in seconds. Default is **30**s. | Web |
| `maxBufferLength` | The maximum length of the player's buffer, in seconds. | Web | |
| `preferredMaximumResolution` | A preferred upper limit on the resolution of the video to be downloaded. `(0,0)` (the default) removes the cap. | Android & iOS |
Comment thread
Yousif-CS marked this conversation as resolved.

When specifying the strategy, apart from the values `'performance'`, `'quality'`, `'bandwidth'`,
an `ABRStrategyConfiguration`
Expand All @@ -54,6 +55,13 @@ const strategyConfig: ABRStrategyConfiguration = {
player.abr.strategy = strategyConfig;
```

To cap the resolution of the variant the player downloads, set `preferredMaximumResolution` to a `Resolution` (`{width, height}`).
Pass `(0, 0)` to remove the cap.

```typescript
player.abr.preferredMaximumResolution = { width: 1280, height: 720 };
```

## Setting Target Video Quality

By default, the ABR algorithm will choose, depending on the available bandwidth,
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ hermesEnabled=true
edgeToEdgeEnabled=false

# Version of the THEOplayer SDK, if not specified, the latest available version within bounds is set.
#THEOplayer_sdk=[11.4.0, 12.0.0)
#THEOplayer_sdk=[11.5.0, 12.0.0)

# Override Android sdk versions
#THEOplayer_compileSdkVersion = 36
Expand Down
4 changes: 2 additions & 2 deletions src/api/abr/ABRConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ export interface ABRConfiguration {
* A preferred upper limit on the resolution of the video to be downloaded (or otherwise transferred) and rendered by the player.
*
* The default value is (0,0), which indicates that the client enforces no limit on video resolution. Other values indicate a preferred maximum video resolution.
* It only applies to HTTP Live Streaming asset.
* It only applies to Live Streaming asset.
*
* @platform ios
* @platform ios,android
*/
preferredMaximumResolution?: Resolution;
}
Loading