Skip to content

Commit

Permalink
Merge pull request #532 from bitmovin/feature/enable-lock-screen-cont…
Browse files Browse the repository at this point in the history
…rols

iOS: support Media Controls
  • Loading branch information
123mpozzi authored Nov 7, 2024
2 parents f1118f0 + a0db607 commit 1c7cfe2
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
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 {
/**
* 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

0 comments on commit 1c7cfe2

Please sign in to comment.