Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: support Media Controls #532

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

## [Unreleased]

### Added

- `LockScreenControlConfig` to configure the lock screen information for the application. When `isEnabled` is `true`, the current media information will be shown on the lock-screen and within the control center

### Changed

- Update Bitmovin's native Android SDK version to `3.84.0`

### Deprecated

- `TweaksConfig.updatesNowPlayingInfoCenter` in favor of `LockScreenControlConfig.isEnabled`

## [0.29.0] - 2024-09-09

### Added
Expand Down
14 changes: 14 additions & 0 deletions ios/RCTConvert+BitmovinPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ extension RCTConvert {
if let networkConfig = RCTConvert.networkConfig(json["networkConfig"]) {
playerConfig.networkConfig = networkConfig
}
if let nowPlayingConfig = RCTConvert.lockScreenControlConfig(json["lockScreenControlConfig"]) {
playerConfig.nowPlayingConfig = nowPlayingConfig
}
#if os(iOS)
if let remoteControlConfig = RCTConvert.remoteControlConfig(json["remoteControlConfig"]) {
playerConfig.remoteControlConfig = remoteControlConfig
Expand Down Expand Up @@ -1328,6 +1331,17 @@ extension RCTConvert {
"body": toJson(data: httpResponse.body)
]
}

static func lockScreenControlConfig(_ json: Any?) -> NowPlayingConfig? {
guard let json = json as? [String: Any?] else {
return nil
}
let nowPlayingConfig = NowPlayingConfig()
if let isEnabled = json["isEnabled"] as? Bool {
nowPlayingConfig.isNowPlayingInfoEnabled = isEnabled
}
return nowPlayingConfig
}
}
/**
* React native specific PlayerViewConfig.
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export * from './playerConfig';
export * from './liveConfig';
export * from './bufferApi';
export * from './network';
export * from './lockScreenControlConfig';
50 changes: 50 additions & 0 deletions src/lockScreenControlConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Configures the lock screen information for the application. This information will be displayed
* wherever current media information typically appears, such as the lock screen
* and inside the control center.
*/
export interface LockScreenControlConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this will be most likely only for iOS, would it make sense to use NowPlayingConfig as a name to match what we have in iOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the config will also be available for Android, I would keep the naming as LockScreenControlConfig

/**
* Enable the default behavior of displaying media information
* on the lock screen and within the control center.
* Default is `false`.
*
* For a detailed list of the supported features in the **default behavior**,
* check the **Default Supported Features** section.
*
* @note Enabling this flag will automatically treat {@link TweaksConfig.updatesNowPlayingInfoCenter} as `false`.
*
* ## Limitations
* ---
* - At the moment, the current media information is disabled during casting.
*
* ## Known Issues
* ---
* **iOS**:
* - There is unexpected behavior when using the IMA SDK. The Google IMA SDK adds its own commands
* for play/pause as soon as the ad starts loading (not when it starts playing). Within this window
* (approximately around 10 seconds), it is possible that both the ad and the main content are playing
* at the same time when a user interacts with the lock-screen control feature.
*
* ## Default Supported Features
* ---
* Here is the list of features supported by the default behavior.
*
* ### Populated Metadata
* - asset URL (to visualize the correct kind of data — _e.g. a waveform for audio files_)
* - title
* - artwork
* - live or VOD status
* - playback rate
* - default playback rate
* - elapsed time
* - duration
*
* ### Registered Commands
* - toggle play/pause
* - change playback position
* - skip forward
* - skip backward
*/
isEnabled?: boolean;
}
7 changes: 7 additions & 0 deletions src/playerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NativeInstanceConfig } from './nativeInstance';
import { PlaybackConfig } from './playbackConfig';
import { LiveConfig } from './liveConfig';
import { NetworkConfig } from './network/networkConfig';
import { LockScreenControlConfig } from './lockScreenControlConfig';

/**
* Object used to configure a new `Player` instance.
Expand Down Expand Up @@ -73,4 +74,10 @@ export interface PlayerConfig extends NativeInstanceConfig {
* Configures network request manipulation functionality. A default {@link NetworkConfig} is set initially.
*/
networkConfig?: NetworkConfig;
/**
* Configures the lock screen information for the application. This information will be displayed
* wherever current media information typically appears, such as the lock screen
* and inside the control center.
*/
lockScreenControlConfig?: LockScreenControlConfig;
}
1 change: 1 addition & 0 deletions src/tweaksConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export interface TweaksConfig {
*
* Default is `true`.
*
* @deprecated To enable the Now Playing information use {@link LockScreenControlConfig.isEnabled}
* @platform iOS
*/
updatesNowPlayingInfoCenter?: boolean;
Expand Down
Loading