Skip to content

Commit

Permalink
Merge commit 'c965354c328fbed58b55dae8702fd6c1955a4da9' into bufferap…
Browse files Browse the repository at this point in the history
…i-namespace
  • Loading branch information
123mpozzi committed Oct 25, 2023
2 parents 18ecdcb + c965354 commit 539e8e8
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- `LiveConfig.minTimeshiftBufferDepth` to control the minimum buffer depth of a stream needed to enable time shifting.
- `Player.buffer` to control buffer preferences and to query the current buffer state

## [0.13.0] (2023-10-20)
Expand All @@ -13,11 +14,11 @@
- API Reference now can be found [here](https://cdn.bitmovin.com/player/reactnative/0/docs/index.html)
- `PlayerViewConfig` with a `UiConfig` to the `PlayerView` to enable configuration of the visual presentation and behaviour
- `PictureInPictureConfig` to `PlayerViewConfig` to allow configuring the Picture in Picture behavior
- `PictureInPictureConfig.isEnabled` to enable configing if Picture in Picture is enabled
- `PictureInPictureConfig.isEnabled` to enable configuring if Picture in Picture is enabled
- `PictureInPictureConfig.shouldEnterOnBackground` to start Picture in Picture automatically when the app transitions to background
- `onPictureInPictureAvailabilityChanged` event is now emitted on iOS and tvOS in addition to Android
- `BufferConfig` to configure player buffer depth
- `PlayerView.isPictureInPictureRequested` to programatically create a Picture in Picture request
- `PlayerView.isPictureInPictureRequested` to programmatically create a Picture in Picture request
- `PlayerView.scalingMode` to allow changing the video scaling mode

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.bitmovin.player.api.event.PlayerEvent
import com.bitmovin.player.api.event.SourceEvent
import com.bitmovin.player.api.event.data.CastPayload
import com.bitmovin.player.api.event.data.SeekPosition
import com.bitmovin.player.api.live.LiveConfig
import com.bitmovin.player.api.media.AdaptationConfig
import com.bitmovin.player.api.media.MediaType
import com.bitmovin.player.api.media.audio.AudioTrack
Expand Down Expand Up @@ -117,6 +118,11 @@ class JsonConverter {
playerConfig.bufferConfig = it
}
}
if (json.hasKey("liveConfig")) {
toLiveConfig(json.getMap("liveConfig"))?.let {
playerConfig.liveConfig = it
}
}
return playerConfig
}

Expand Down Expand Up @@ -1171,6 +1177,23 @@ class JsonConverter {
pictureInPictureConfig = toPictureInPictureConfig(json.getMap("pictureInPictureConfig")),
)

/**
* Converts any JS object into a [LiveConfig] object.
* @param json JS object representing the [LiveConfig].
* @return The generated [LiveConfig] if successful, `null` otherwise.
*/
@JvmStatic
fun toLiveConfig(json: ReadableMap?): LiveConfig? {
if (json == null) {
return null
}
val liveConfig = LiveConfig()
if (json.hasKey("minTimeshiftBufferDepth")) {
liveConfig.minTimeShiftBufferDepth = json.getDouble("minTimeshiftBufferDepth")
}
return liveConfig
}

/**
* Converts any [MediaType] value into its json representation.
* @param mediaType [MediaType] value.
Expand Down
19 changes: 19 additions & 0 deletions ios/RCTConvert+BitmovinPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ extension RCTConvert {
if let bufferConfig = RCTConvert.bufferConfig(json["bufferConfig"]) {
playerConfig.bufferConfig = bufferConfig
}
if let liveConfig = RCTConvert.liveConfig(json["liveConfig"]) {
playerConfig.liveConfig = liveConfig
}
#if os(iOS)
if let remoteControlConfig = RCTConvert.remoteControlConfig(json["remoteControlConfig"]) {
playerConfig.remoteControlConfig = remoteControlConfig
Expand Down Expand Up @@ -191,6 +194,22 @@ extension RCTConvert {
return bufferConfig
}

/**
Utility method to instantiate a `LiveConfig` from a JS object.
- Parameter json: JS object.
- Returns: The produced `LiveConfig` object, or `nil` if `json` is not valid.
*/
static func liveConfig(_ json: Any?) -> LiveConfig? {
guard let json = json as? [String: Any?] else {
return nil
}
let liveConfig = LiveConfig()
if let minTimeshiftBufferDepth = json["minTimeshiftBufferDepth"] as? NSNumber {
liveConfig.minTimeshiftBufferDepth = minTimeshiftBufferDepth.doubleValue
}
return liveConfig
}

/**
Utility method to instantiate an `AdvertisingConfig` from a JS object.
- Parameter json: JS object.
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export * from './tweaksConfig';
export * from './bufferConfig';
export * from './playbackConfig';
export * from './playerConfig';
export * from './liveConfig';
export * from './bufferApi';
12 changes: 12 additions & 0 deletions src/liveConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Contains config values regarding the behaviour when playing live streams.
*/
export interface LiveConfig {
/**
* The minimum buffer depth of a stream needed to enable time shifting.
* When the internal value for the maximal possible timeshift is lower than this value,
* timeshifting should be disabled. That means `Player.maxTimeShift` returns `0` in that case.
* This value should always be non-positive value, default value is `-40`.
*/
minTimeshiftBufferDepth?: number;
}
5 changes: 5 additions & 0 deletions src/playerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { RemoteControlConfig } from './remoteControlConfig';
import { BufferConfig } from './bufferConfig';
import { NativeInstanceConfig } from './nativeInstance';
import { PlaybackConfig } from './playbackConfig';
import { LiveConfig } from './liveConfig';

/**
* Object used to configure a new `Player` instance.
Expand Down Expand Up @@ -63,4 +64,8 @@ export interface PlayerConfig extends NativeInstanceConfig {
* Configures buffer settings. A default {@link BufferConfig} is set initially.
*/
bufferConfig?: BufferConfig;
/**
* Configures behaviour when playing live content. A default {@link LiveConfig} is set initially.
*/
liveConfig?: LiveConfig;
}

0 comments on commit 539e8e8

Please sign in to comment.