react-native-theoplayer 11.5.0 → 11.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -1
- package/README.md +70 -0
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +6 -0
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +11 -2
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt +95 -93
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.kt +6 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.kt +51 -3
- package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt +4 -0
- package/android/src/main/java/com/theoplayer/ads/AdsModule.kt +6 -6
- package/android/src/main/java/com/theoplayer/integration/Integration.kt +72 -0
- package/android/src/main/java/com/theoplayer/integration/IntegrationRegistration.kt +68 -0
- package/android/src/main/java/com/theoplayer/integration/PlayerFacade.kt +187 -0
- package/android/src/main/java/com/theoplayer/integration/PlayerFacadeAdState.kt +19 -0
- package/android/src/main/java/com/theoplayer/integration/PlayerFacadeAds.kt +73 -0
- package/android/src/main/java/com/theoplayer/integration/PlayerFacadeAdsBridge.kt +112 -0
- package/android/src/main/java/com/theoplayer/integration/PlayerFacadeEventSubscription.kt +11 -0
- package/android/src/main/java/com/theoplayer/integration/PlayerFacadeEvents.kt +139 -0
- package/android/src/main/java/com/theoplayer/media/MediaControlModule.kt +102 -0
- package/android/src/main/java/com/theoplayer/media/MediaControlProxy.kt +376 -0
- package/android/src/main/java/com/theoplayer/media/MediaNotificationBuilder.kt +78 -34
- package/android/src/main/java/com/theoplayer/media/MediaPlaybackService.kt +53 -20
- package/android/src/main/java/com/theoplayer/media/MediaSessionConfig.kt +6 -6
- package/android/src/main/java/com/theoplayer/media/MediaSessionConfigAdapter.kt +23 -20
- package/android/src/main/java/com/theoplayer/metrics/MetricsModule.kt +37 -0
- package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +0 -1
- package/android/src/main/java/com/theoplayer/presentation/PipUtils.kt +98 -93
- package/android/src/main/java/com/theoplayer/theoads/THEOadsModule.kt +1 -1
- package/android/src/main/java/com/theoplayer/util/ReadableExtension.kt +14 -0
- package/android/src/main/res/drawable/ic_next.xml +9 -0
- package/android/src/main/res/drawable/ic_prev.xml +9 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/android/src/test/java/com/theoplayer/integration/PlayerFacadeAdsBridgeTest.kt +250 -0
- package/android/src/test/java/com/theoplayer/integration/PlayerFacadeConfigurationTest.kt +30 -0
- package/android/src/test/java/com/theoplayer/integration/PlayerFacadeTest.kt +507 -0
- package/android/src/test/java/com/theoplayer/integration/PlayerFacadeTestHost.kt +104 -0
- package/ios/THEOplayerRCTBridge.m +35 -0
- package/ios/THEOplayerRCTDebug.swift +3 -0
- package/ios/THEOplayerRCTMainEventHandler.swift +17 -0
- package/ios/THEOplayerRCTPlayerAPI.swift +31 -0
- package/ios/THEOplayerRCTTypeUtils.swift +30 -0
- package/ios/THEOplayerRCTView.swift +15 -5
- package/ios/Theoplayer-Bridging-Header.h +0 -1
- package/ios/backgroundAudio/THEOplayerRCTBackgroundAudioManager.swift +1 -1
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +49 -3
- package/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +151 -68
- package/ios/backgroundAudio/THEOplayerRCTView+MediaControlConfig.swift +25 -11
- package/ios/mediaControl/THEOplayerRCTMediaControlAPI.swift +79 -0
- package/ios/mediaControl/THEOplayerRCTMediaControlManager.swift +38 -0
- package/ios/metrics/THEOplayerRCTMetricsAPI.swift +31 -0
- package/ios/pip/THEOplayerRCTPipControlsManager.swift +9 -12
- package/lib/commonjs/api/barrel.js +31 -20
- package/lib/commonjs/api/barrel.js.map +1 -1
- package/lib/commonjs/api/event/PlayerEvent.js +8 -0
- package/lib/commonjs/api/event/PlayerEvent.js.map +1 -1
- package/lib/commonjs/api/media/MediaControlAPI.js +14 -0
- package/lib/commonjs/api/media/MediaControlAPI.js.map +1 -0
- package/lib/commonjs/api/media/barrel.js +11 -0
- package/lib/commonjs/api/media/barrel.js.map +1 -1
- package/lib/commonjs/api/metrics/MetricsAPI.js +2 -0
- package/lib/commonjs/api/metrics/MetricsAPI.js.map +1 -0
- package/lib/commonjs/api/metrics/barrel.js +17 -0
- package/lib/commonjs/api/metrics/barrel.js.map +1 -0
- package/lib/commonjs/api/player/Integration.js +2 -0
- package/lib/commonjs/api/player/Integration.js.map +1 -0
- package/lib/commonjs/api/player/PlayerEventMap.js +1 -0
- package/lib/commonjs/api/player/PlayerEventMap.js.map +1 -1
- package/lib/commonjs/api/player/THEOplayer.js.map +1 -1
- package/lib/commonjs/api/player/barrel.js +11 -0
- package/lib/commonjs/api/player/barrel.js.map +1 -1
- package/lib/commonjs/api/track/MediaTrack.js +16 -0
- package/lib/commonjs/api/track/MediaTrack.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.js +6 -0
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +3 -1
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js +1 -0
- package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +24 -0
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +29 -12
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js +6 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/PlayerEvents.js +7 -1
- package/lib/commonjs/internal/adapter/event/PlayerEvents.js.map +1 -1
- package/lib/commonjs/internal/adapter/media/MediaControlNativeAdapter.js +42 -0
- package/lib/commonjs/internal/adapter/media/MediaControlNativeAdapter.js.map +1 -0
- package/lib/commonjs/internal/adapter/media/MediaControlWebAdapter.js +32 -0
- package/lib/commonjs/internal/adapter/media/MediaControlWebAdapter.js.map +1 -0
- package/lib/commonjs/internal/adapter/metrics/MetricsNativeAdapter.js +18 -0
- package/lib/commonjs/internal/adapter/metrics/MetricsNativeAdapter.js.map +1 -0
- package/lib/commonjs/internal/adapter/metrics/MetricsWebAdapter.js +16 -0
- package/lib/commonjs/internal/adapter/metrics/MetricsWebAdapter.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/IntegrationRegistration.js +6 -0
- package/lib/commonjs/internal/adapter/web/IntegrationRegistration.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacade.js +258 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacade.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeAPI.js +6 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeAPI.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeAdsEvents.js +114 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeAdsEvents.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeIntegration.js +6 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeIntegration.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeTypes.js +6 -0
- package/lib/commonjs/internal/adapter/web/PlayerFacadeTypes.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js +78 -16
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/commonjs/manifest.json +1 -1
- package/lib/module/api/barrel.js +1 -0
- package/lib/module/api/barrel.js.map +1 -1
- package/lib/module/api/event/PlayerEvent.js +9 -0
- package/lib/module/api/event/PlayerEvent.js.map +1 -1
- package/lib/module/api/media/MediaControlAPI.js +10 -0
- package/lib/module/api/media/MediaControlAPI.js.map +1 -0
- package/lib/module/api/media/barrel.js +1 -0
- package/lib/module/api/media/barrel.js.map +1 -1
- package/lib/module/api/metrics/MetricsAPI.js +2 -0
- package/lib/module/api/metrics/MetricsAPI.js.map +1 -0
- package/lib/module/api/metrics/barrel.js +4 -0
- package/lib/module/api/metrics/barrel.js.map +1 -0
- package/lib/module/api/player/Integration.js +2 -0
- package/lib/module/api/player/Integration.js.map +1 -0
- package/lib/module/api/player/PlayerEventMap.js +1 -0
- package/lib/module/api/player/PlayerEventMap.js.map +1 -1
- package/lib/module/api/player/THEOplayer.js.map +1 -1
- package/lib/module/api/player/barrel.js +1 -0
- package/lib/module/api/player/barrel.js.map +1 -1
- package/lib/module/api/track/MediaTrack.js +16 -0
- package/lib/module/api/track/MediaTrack.js.map +1 -1
- package/lib/module/internal/THEOplayerView.js +7 -1
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +3 -1
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/adapter/DefaultNativePlayerState.js +1 -0
- package/lib/module/internal/adapter/DefaultNativePlayerState.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js +24 -0
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js +29 -12
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/module/internal/adapter/WebEventForwarder.js +7 -2
- package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/module/internal/adapter/event/PlayerEvents.js +5 -0
- package/lib/module/internal/adapter/event/PlayerEvents.js.map +1 -1
- package/lib/module/internal/adapter/media/MediaControlNativeAdapter.js +37 -0
- package/lib/module/internal/adapter/media/MediaControlNativeAdapter.js.map +1 -0
- package/lib/module/internal/adapter/media/MediaControlWebAdapter.js +27 -0
- package/lib/module/internal/adapter/media/MediaControlWebAdapter.js.map +1 -0
- package/lib/module/internal/adapter/metrics/MetricsNativeAdapter.js +13 -0
- package/lib/module/internal/adapter/metrics/MetricsNativeAdapter.js.map +1 -0
- package/lib/module/internal/adapter/metrics/MetricsWebAdapter.js +11 -0
- package/lib/module/internal/adapter/metrics/MetricsWebAdapter.js.map +1 -0
- package/lib/module/internal/adapter/web/IntegrationRegistration.js +4 -0
- package/lib/module/internal/adapter/web/IntegrationRegistration.js.map +1 -0
- package/lib/module/internal/adapter/web/PlayerFacade.js +253 -0
- package/lib/module/internal/adapter/web/PlayerFacade.js.map +1 -0
- package/lib/module/internal/adapter/web/PlayerFacadeAPI.js +4 -0
- package/lib/module/internal/adapter/web/PlayerFacadeAPI.js.map +1 -0
- package/lib/module/internal/adapter/web/PlayerFacadeAdsEvents.js +109 -0
- package/lib/module/internal/adapter/web/PlayerFacadeAdsEvents.js.map +1 -0
- package/lib/module/internal/adapter/web/PlayerFacadeIntegration.js +4 -0
- package/lib/module/internal/adapter/web/PlayerFacadeIntegration.js.map +1 -0
- package/lib/module/internal/adapter/web/PlayerFacadeTypes.js +4 -0
- package/lib/module/internal/adapter/web/PlayerFacadeTypes.js.map +1 -0
- package/lib/module/internal/adapter/web/WebMediaSession.js +78 -16
- package/lib/module/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/module/manifest.json +1 -1
- package/lib/typescript/__tests__/PlayerFacade.test.d.ts +2 -0
- package/lib/typescript/__tests__/PlayerFacade.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/PlayerFacadeWebAdapter.test.d.ts +2 -0
- package/lib/typescript/__tests__/PlayerFacadeWebAdapter.test.d.ts.map +1 -0
- package/lib/typescript/__tests__/index.test.d.ts +13 -0
- package/lib/typescript/__tests__/index.test.d.ts.map +1 -1
- package/lib/typescript/api/THEOplayerView.d.ts +4 -0
- package/lib/typescript/api/THEOplayerView.d.ts.map +1 -1
- package/lib/typescript/api/barrel.d.ts +1 -0
- package/lib/typescript/api/barrel.d.ts.map +1 -1
- package/lib/typescript/api/config/PlayerConfiguration.d.ts +15 -0
- package/lib/typescript/api/config/PlayerConfiguration.d.ts.map +1 -1
- package/lib/typescript/api/event/AdEvent.d.ts +1 -1
- package/lib/typescript/api/event/PlayerEvent.d.ts +9 -0
- package/lib/typescript/api/event/PlayerEvent.d.ts.map +1 -1
- package/lib/typescript/api/media/MediaControlAPI.d.ts +30 -0
- package/lib/typescript/api/media/MediaControlAPI.d.ts.map +1 -0
- package/lib/typescript/api/media/MediaControlConfiguration.d.ts +5 -1
- package/lib/typescript/api/media/MediaControlConfiguration.d.ts.map +1 -1
- package/lib/typescript/api/media/barrel.d.ts +1 -0
- package/lib/typescript/api/media/barrel.d.ts.map +1 -1
- package/lib/typescript/api/metrics/MetricsAPI.d.ts +21 -0
- package/lib/typescript/api/metrics/MetricsAPI.d.ts.map +1 -0
- package/lib/typescript/api/metrics/barrel.d.ts +2 -0
- package/lib/typescript/api/metrics/barrel.d.ts.map +1 -0
- package/lib/typescript/api/player/Integration.d.ts +88 -0
- package/lib/typescript/api/player/Integration.d.ts.map +1 -0
- package/lib/typescript/api/player/PlayerEventMap.d.ts +7 -2
- package/lib/typescript/api/player/PlayerEventMap.d.ts.map +1 -1
- package/lib/typescript/api/player/THEOplayer.d.ts +24 -0
- package/lib/typescript/api/player/THEOplayer.d.ts.map +1 -1
- package/lib/typescript/api/player/barrel.d.ts +1 -0
- package/lib/typescript/api/player/barrel.d.ts.map +1 -1
- package/lib/typescript/api/track/MediaTrack.d.ts +21 -4
- package/lib/typescript/api/track/MediaTrack.d.ts.map +1 -1
- package/lib/typescript/internal/THEOplayerView.d.ts +1 -0
- package/lib/typescript/internal/THEOplayerView.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts +1 -0
- package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/NativePlayerState.d.ts +1 -0
- package/lib/typescript/internal/adapter/NativePlayerState.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +8 -1
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +8 -2
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/WebEventForwarder.d.ts +1 -0
- package/lib/typescript/internal/adapter/WebEventForwarder.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/event/PlayerEvents.d.ts +4 -1
- package/lib/typescript/internal/adapter/event/PlayerEvents.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/event/native/NativePlayerEvent.d.ts +1 -0
- package/lib/typescript/internal/adapter/event/native/NativePlayerEvent.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/media/MediaControlNativeAdapter.d.ts +12 -0
- package/lib/typescript/internal/adapter/media/MediaControlNativeAdapter.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/media/MediaControlWebAdapter.d.ts +14 -0
- package/lib/typescript/internal/adapter/media/MediaControlWebAdapter.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/metrics/MetricsNativeAdapter.d.ts +7 -0
- package/lib/typescript/internal/adapter/metrics/MetricsNativeAdapter.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/metrics/MetricsWebAdapter.d.ts +8 -0
- package/lib/typescript/internal/adapter/metrics/MetricsWebAdapter.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/IntegrationRegistration.d.ts +53 -0
- package/lib/typescript/internal/adapter/web/IntegrationRegistration.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/PlayerFacade.d.ts +26 -0
- package/lib/typescript/internal/adapter/web/PlayerFacade.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeAPI.d.ts +33 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeAPI.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeAdsEvents.d.ts +21 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeAdsEvents.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeIntegration.d.ts +43 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeIntegration.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeTypes.d.ts +13 -0
- package/lib/typescript/internal/adapter/web/PlayerFacadeTypes.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/web/WebMediaSession.d.ts +10 -3
- package/lib/typescript/internal/adapter/web/WebMediaSession.d.ts.map +1 -1
- package/package.json +3 -3
- package/react-native-theoplayer.podspec +7 -7
- package/src/__tests__/PlayerFacade.test.ts +579 -0
- package/src/__tests__/PlayerFacadeWebAdapter.test.ts +193 -0
- package/src/__tests__/index.test.tsx +15 -1
- package/src/api/THEOplayerView.ts +5 -0
- package/src/api/barrel.ts +1 -0
- package/src/api/config/PlayerConfiguration.ts +16 -0
- package/src/api/event/AdEvent.ts +1 -1
- package/src/api/event/PlayerEvent.ts +10 -0
- package/src/api/media/MediaControlAPI.ts +33 -0
- package/src/api/media/MediaControlConfiguration.ts +5 -1
- package/src/api/media/barrel.ts +1 -0
- package/src/api/metrics/MetricsAPI.ts +20 -0
- package/src/api/metrics/barrel.ts +1 -0
- package/src/api/player/Integration.ts +97 -0
- package/src/api/player/PlayerEventMap.ts +7 -0
- package/src/api/player/THEOplayer.ts +27 -0
- package/src/api/player/barrel.ts +1 -0
- package/src/api/track/MediaTrack.ts +21 -4
- package/src/internal/THEOplayerView.tsx +10 -2
- package/src/internal/THEOplayerView.web.tsx +2 -2
- package/src/internal/adapter/DefaultNativePlayerState.ts +1 -0
- package/src/internal/adapter/NativePlayerState.ts +1 -0
- package/src/internal/adapter/THEOplayerAdapter.ts +33 -0
- package/src/internal/adapter/THEOplayerWebAdapter.ts +38 -12
- package/src/internal/adapter/WebEventForwarder.ts +12 -3
- package/src/internal/adapter/event/PlayerEvents.ts +10 -0
- package/src/internal/adapter/event/native/NativePlayerEvent.ts +2 -0
- package/src/internal/adapter/media/MediaControlNativeAdapter.ts +38 -0
- package/src/internal/adapter/media/MediaControlWebAdapter.ts +28 -0
- package/src/internal/adapter/metrics/MetricsNativeAdapter.ts +12 -0
- package/src/internal/adapter/metrics/MetricsWebAdapter.ts +14 -0
- package/src/internal/adapter/web/IntegrationRegistration.ts +57 -0
- package/src/internal/adapter/web/PlayerFacade.ts +281 -0
- package/src/internal/adapter/web/PlayerFacadeAPI.ts +35 -0
- package/src/internal/adapter/web/PlayerFacadeAdsEvents.ts +119 -0
- package/src/internal/adapter/web/PlayerFacadeIntegration.ts +45 -0
- package/src/internal/adapter/web/PlayerFacadeTypes.ts +14 -0
- package/src/internal/adapter/web/WebMediaSession.ts +85 -21
- package/src/manifest.json +1 -1
- package/android/src/main/java/com/theoplayer/media/MediaQueueNavigator.kt +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [11.7.0] - 18-09-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added the `Metrics` API, accessible through `player.metrics`, with `currentBandwidthEstimate` returning the player's estimated available bandwidth in bits per second. On iOS/tvOS this value is only reported for THEOlive/HESP streams.
|
|
13
|
+
- Added `THEOplayer.manageContentMatching` to let the player match the display mode (frame rate and dynamic range) of the TV to the content before playback starts on tvOS.
|
|
14
|
+
- Added a `testID` property on `THEOplayerView` to allow locating the player view from UI automation tools.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Fixed media track kind typings to accept audio descriptions and other stream- or platform-specific values without type overrides.
|
|
19
|
+
- Fixed an issue on Android where destroying the player during a pending `MediaPlaybackService` bind could cause a crash.
|
|
20
|
+
- Fixed an issue on Android where the player could remain black when its view was attached after React Native had already assigned the layout.
|
|
21
|
+
- Fixed an issue where `player.paused` remained `true` between the `play` and `playing` events.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Removed the `RCTRootContentView` import from the iOS bridging header, as it is removed in React Native 0.87.
|
|
26
|
+
- Upgraded example app to support React Native v0.87.1.
|
|
27
|
+
|
|
28
|
+
## [11.6.0]
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Added the `MediaControl` API for controlling the media session and lock screen controls with custom handlers.
|
|
33
|
+
- Added support for the `contentprotectionsuccess` event on all platforms
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Upgraded example app to support React Native v0.86.2.
|
|
38
|
+
|
|
8
39
|
## [11.5.0]
|
|
9
40
|
|
|
10
41
|
### Fixed
|
|
@@ -682,7 +713,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
682
713
|
|
|
683
714
|
### Changed
|
|
684
715
|
|
|
685
|
-
-
|
|
716
|
+
- Upgraded example app to support React Native v0.75.
|
|
686
717
|
|
|
687
718
|
## [8.5.0] - 24-10-21
|
|
688
719
|
|
package/README.md
CHANGED
|
@@ -33,6 +33,73 @@ by the `@theoplayer/react-native-ui` package.
|
|
|
33
33
|
It also gives a description of the properties of the `THEOplayerView` component, and
|
|
34
34
|
a list of features and known limitations.
|
|
35
35
|
|
|
36
|
+
### Player facade (Web and Android)
|
|
37
|
+
|
|
38
|
+
Set `usePlayerFacade: true` in the player configuration at creation to enable the facade.
|
|
39
|
+
The default is `false`; iOS and tvOS do not support this option.
|
|
40
|
+
On Web, the facade is available at `player.nativeHandle`.
|
|
41
|
+
Integrations can register through `registerIntegration`, dispatch THEOplayer player
|
|
42
|
+
and ad events (including `adclicked`), and supply a clock through `getCurrentTime()` in
|
|
43
|
+
seconds. The wrapper forwards `adclicked` to React Native's ad-event stream.
|
|
44
|
+
Close the registration before replacing an integration. Playback engines and ad
|
|
45
|
+
schedulers should use `facade.contentPlayer`, not the facade's overridden ad clock.
|
|
46
|
+
|
|
47
|
+
Integrations can provide an `ads` object implementing the Ads API and its event
|
|
48
|
+
subscriptions. The stable public `player.ads` delegates to that object, including
|
|
49
|
+
scheduling queries and controls. Existing listeners migrate when an integration
|
|
50
|
+
registers or closes; native Ads behavior returns after removal. The earlier
|
|
51
|
+
`getAdState()` and `shouldConsumeAdEvent(event)` hooks remain available for
|
|
52
|
+
integrations without an Ads object. The facade never reconstructs ad lifecycle.
|
|
53
|
+
|
|
54
|
+
`getMuted()` / `setMuted(value)` and `getVolume()` / `setVolume(value)` route audio
|
|
55
|
+
through an integration. Setters return `true` when handled; otherwise the facade
|
|
56
|
+
falls back to content. Nullish getter results also fall back to content.
|
|
57
|
+
`registration.dispatchEvent(event)` accepts typed THEOplayer player and ad events.
|
|
58
|
+
Ad events route to `player.ads` listeners; player events such as `playing`, `waiting`,
|
|
59
|
+
and `volumechange` route to `player` listeners. Dispatch does not emit on the content
|
|
60
|
+
player or pass through backing-event interceptors. Closed registrations cannot emit.
|
|
61
|
+
`registration.dispatchPlayerEvent(event)` remains a compatible player-event entry point.
|
|
62
|
+
Playback ownership and audio synchronization remain integration responsibilities.
|
|
63
|
+
|
|
64
|
+
`registration.interceptPlayerEvent(type, callback)` lets an integration inspect a
|
|
65
|
+
backing player event once before facade listeners receive it. Return `true` to
|
|
66
|
+
consume the event, or `false` to forward it. Raw player listeners are unaffected.
|
|
67
|
+
The returned disposer removes the interceptor. Existing interceptors remain until
|
|
68
|
+
disposed or the facade is destroyed, allowing an integration to drain already-queued
|
|
69
|
+
events after unregistering; a closed registration cannot install new interceptors.
|
|
70
|
+
`registration.interceptPlayerEvents(callback)` applies the same policy to every
|
|
71
|
+
subscribed backing-player event, including subscriptions added later. Type-specific
|
|
72
|
+
interceptors run first; integration-dispatched events bypass both kinds. Use a
|
|
73
|
+
type-specific interceptor when an event must be observed even without consumers.
|
|
74
|
+
An optional `isSeeking()` integration hook overrides the public seeking state;
|
|
75
|
+
nullish results fall back to the backing player.
|
|
76
|
+
Pause/seek ownership, pending transitions, lifecycle exceptions and ad lifecycle
|
|
77
|
+
decisions belong to the integration, not the facade.
|
|
78
|
+
|
|
79
|
+
On Android, implement `com.theoplayer.integration.Integration` and call
|
|
80
|
+
`ReactTHEOplayerView.registerIntegration(integration)` after the view is initialized.
|
|
81
|
+
The returned `IntegrationRegistration` supports the same dispatch and interception
|
|
82
|
+
semantics using native Android SDK events. Interceptor disposers implement `Closeable`;
|
|
83
|
+
call `close()` to remove them. Access the raw engine through
|
|
84
|
+
`(view.player as PlayerFacade).contentPlayer`. Time values are in seconds on both platforms.
|
|
85
|
+
Android's `getAdState()` returns a `PlayerFacadeAdState`; its nullable result delegates
|
|
86
|
+
to native Ads. The facade permits registration during native ads and does not infer
|
|
87
|
+
state or suppress native ad events merely because an integration is registered.
|
|
88
|
+
Native SDK extensions (`theoAds`, `ima`, `dai`) resolve against the raw player or Ads
|
|
89
|
+
object through the facade-aware extensions in `com.theoplayer.integration`.
|
|
90
|
+
|
|
91
|
+
Custom advertising must not overlap ongoing native IMA/DAI playback on Android.
|
|
92
|
+
Finish or reset native advertising before taking over. Replacing/filtering native
|
|
93
|
+
ad events can suspend the RN bridge's native DAI bookkeeping, so fresh native state
|
|
94
|
+
after hidden native playback is not guaranteed. `ReactTHEOplayerView.adsApi` remains
|
|
95
|
+
the native source-specific adapter/event sink; use `view.player.ads` for facade state.
|
|
96
|
+
React Native Ads queries and controls use a facade-aware bridge with native fallback.
|
|
97
|
+
|
|
98
|
+
Focused facade regression tests (Node 22.18+):
|
|
99
|
+
`node --test src/__tests__/PlayerFacade.test.ts`.
|
|
100
|
+
Android tests, from `example/android`:
|
|
101
|
+
`./gradlew :react-native-theoplayer:testDebugUnitTest --tests 'com.theoplayer.integration.PlayerFacade*Test' --console=plain`.
|
|
102
|
+
|
|
36
103
|
## Prerequisites
|
|
37
104
|
|
|
38
105
|
For each platform, a dependency to the corresponding THEOplayer SDK is included through a dependency manager:
|
|
@@ -183,10 +250,13 @@ This section gives an overview of features, limitations and known issues:
|
|
|
183
250
|
- [Background playback and notifications](./doc/background.md)
|
|
184
251
|
- [Casting with Chromecast and Airplay](./doc/cast.md)
|
|
185
252
|
- [Common Media Client Data (CMCD)](./doc/cmcd.md)
|
|
253
|
+
- [Content matching on tvOS](./doc/content-matching.md)
|
|
186
254
|
- [Digital Rights Management (DRM)](./doc/drm.md)
|
|
187
255
|
- [Expo](./doc/expo.md)
|
|
188
256
|
- [Fullscreen presentation](./doc/fullscreen.md)
|
|
257
|
+
- [Media Control](./doc/mediacontrol.md)
|
|
189
258
|
- [Media Caching](./doc/media-caching.md)
|
|
259
|
+
- [Metrics](./doc/metrics.md)
|
|
190
260
|
- [Migrating to THEOplayer 9.x](./doc/migrating-to-react-native-theoplayer-9.md)
|
|
191
261
|
- [Migrating to THEOplayer 10.x🔥](./doc/migrating-to-react-native-theoplayer-10.md)
|
|
192
262
|
- [Millicast](./doc/millicast.md)
|
package/android/build.gradle
CHANGED
|
@@ -167,6 +167,7 @@ dependencies {
|
|
|
167
167
|
implementation("com.theoplayer.theoplayer-sdk-android:core:$theoVersion")
|
|
168
168
|
implementation("com.theoplayer.theoplayer-sdk-android:ads-wrapper:$theoAdsWrapperVersion")
|
|
169
169
|
implementation("com.theoplayer.android-connector:mediasession:$theoMediaSessionVersion")
|
|
170
|
+
testImplementation("junit:junit:4.13.2")
|
|
170
171
|
|
|
171
172
|
addOptiViewIntegration(enabledGoogleIMA || enabledGoogleDAI || enabledTHEOads, 'integration-ads-ima')
|
|
172
173
|
addOptiViewIntegration(enabledGoogleDAI || enabledTHEOads, 'integration-ads-dai')
|
|
@@ -47,6 +47,7 @@ private const val PROP_THEOLIVE_DISCOVERY_URL = "discoveryUrl"
|
|
|
47
47
|
private const val PROP_HLS_DATERANGE = "hlsDateRange"
|
|
48
48
|
private const val PROP_MULTIMEDIA_TUNNELING_ENABLED = "tunnelingEnabled"
|
|
49
49
|
private const val PROP_DEBUG_LOGS_ENABLED = "debugLogsEnabled"
|
|
50
|
+
private const val PROP_USE_PLAYER_FACADE = "usePlayerFacade"
|
|
50
51
|
private const val PROP_SYSTEM_CAPTION_STYLE = "useSystemCaptionStyle"
|
|
51
52
|
private const val PROP_CMCD = "cmcd"
|
|
52
53
|
private const val PROP_CMCD_EXTERNAL_SESSION_ID = "externalSessionId"
|
|
@@ -57,6 +58,11 @@ private const val PROP_CMCD_ENDPOINT_URL = "url"
|
|
|
57
58
|
|
|
58
59
|
class PlayerConfigAdapter(private val configProps: ReadableMap?) {
|
|
59
60
|
|
|
61
|
+
/** Returns whether the player facade is enabled at creation. Missing or null values default to false. */
|
|
62
|
+
fun usePlayerFacade(): Boolean = configProps?.let {
|
|
63
|
+
it.hasKey(PROP_USE_PLAYER_FACADE) && !it.isNull(PROP_USE_PLAYER_FACADE) && it.getBoolean(PROP_USE_PLAYER_FACADE)
|
|
64
|
+
} ?: false
|
|
65
|
+
|
|
60
66
|
/**
|
|
61
67
|
* Whether debug logs from the native SDK should be enabled.
|
|
62
68
|
*/
|
|
@@ -12,7 +12,7 @@ import com.facebook.react.uimanager.common.UIManagerType
|
|
|
12
12
|
import com.theoplayer.ads.AdEventAdapter
|
|
13
13
|
import com.theoplayer.ads.AdEventAdapter.AdEventEmitter
|
|
14
14
|
import com.theoplayer.android.api.THEOplayerGlobal
|
|
15
|
-
import com.theoplayer.
|
|
15
|
+
import com.theoplayer.integration.theoAds
|
|
16
16
|
import com.theoplayer.android.api.error.THEOplayerException
|
|
17
17
|
import com.theoplayer.android.api.event.EventListener
|
|
18
18
|
import com.theoplayer.android.api.event.EventType
|
|
@@ -86,6 +86,7 @@ private const val EVENT_THEOADS_EVENT = "onNativeTHEOadsEvent"
|
|
|
86
86
|
private const val EVENT_PRESENTATIONMODECHANGE = "onNativePresentationModeChange"
|
|
87
87
|
private const val EVENT_VOLUMECHANGE = "onNativeVolumeChange"
|
|
88
88
|
private const val EVENT_CONTENTPROTECTIONERROR = "onNativeContentProtectionError"
|
|
89
|
+
private const val EVENT_CONTENTPROTECTIONSUCCESS = "onNativeContentProtectionSuccess"
|
|
89
90
|
private const val EVENT_DIMENSIONCHANGE = "onNativeDimensionChange"
|
|
90
91
|
private const val EVENT_VIDEORESIZE = "onNativeVideoResize"
|
|
91
92
|
|
|
@@ -134,6 +135,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
134
135
|
EVENT_PRESENTATIONMODECHANGE,
|
|
135
136
|
EVENT_VOLUMECHANGE,
|
|
136
137
|
EVENT_CONTENTPROTECTIONERROR,
|
|
138
|
+
EVENT_CONTENTPROTECTIONSUCCESS,
|
|
137
139
|
EVENT_DIMENSIONCHANGE,
|
|
138
140
|
EVENT_VIDEORESIZE
|
|
139
141
|
)
|
|
@@ -174,6 +176,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
174
176
|
EVENT_PRESENTATIONMODECHANGE,
|
|
175
177
|
EVENT_VOLUMECHANGE,
|
|
176
178
|
EVENT_CONTENTPROTECTIONERROR,
|
|
179
|
+
EVENT_CONTENTPROTECTIONSUCCESS,
|
|
177
180
|
EVENT_DIMENSIONCHANGE,
|
|
178
181
|
EVENT_VIDEORESIZE
|
|
179
182
|
)
|
|
@@ -251,6 +254,8 @@ class PlayerEventEmitter internal constructor(
|
|
|
251
254
|
EventListener { event: VolumeChangeEvent -> onVolumeChange(event) }
|
|
252
255
|
playerListeners[PlayerEventTypes.CONTENTPROTECTIONERROR] =
|
|
253
256
|
EventListener { event: ContentProtectionErrorEvent -> onContentProtectionError(event) }
|
|
257
|
+
playerListeners[PlayerEventTypes.CONTENTPROTECTIONSUCCESS] =
|
|
258
|
+
EventListener<PlayerEvent<*>> { onContentProtectionSuccess() }
|
|
254
259
|
playerListeners[PlayerEventTypes.RESIZE] =
|
|
255
260
|
EventListener { event: ResizeEvent -> onResize(event) }
|
|
256
261
|
textTrackListeners[TextTrackListEventTypes.ADDTRACK] =
|
|
@@ -407,7 +412,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
407
412
|
private fun onPause() {
|
|
408
413
|
val player = playerView.player
|
|
409
414
|
// Do not forward the pause event in case the content player is paused because the ad player starts.
|
|
410
|
-
if (player != null && (!playerView.
|
|
415
|
+
if (player != null && (!playerView.adBridge.isPlaying || player.isPaused)) {
|
|
411
416
|
receiveEvent(EVENT_PAUSE, null)
|
|
412
417
|
}
|
|
413
418
|
}
|
|
@@ -491,6 +496,10 @@ class PlayerEventEmitter internal constructor(
|
|
|
491
496
|
)
|
|
492
497
|
}
|
|
493
498
|
|
|
499
|
+
private fun onContentProtectionSuccess() {
|
|
500
|
+
receiveEvent(EVENT_CONTENTPROTECTIONSUCCESS, null)
|
|
501
|
+
}
|
|
502
|
+
|
|
494
503
|
private fun onResize(event: ResizeEvent) {
|
|
495
504
|
receiveEvent(
|
|
496
505
|
EVENT_VIDEORESIZE,
|
|
@@ -34,32 +34,17 @@ import com.theoplayer.android.api.millicast.MillicastIntegrationFactory
|
|
|
34
34
|
import com.theoplayer.android.api.player.Player
|
|
35
35
|
import com.theoplayer.android.api.player.RenderingTarget
|
|
36
36
|
import com.theoplayer.android.connector.mediasession.MediaSessionConnector
|
|
37
|
-
import com.theoplayer.android.connector.mediasession.MediaSessionListener
|
|
38
37
|
import com.theoplayer.audio.AudioBecomingNoisyManager
|
|
39
38
|
import com.theoplayer.audio.AudioFocusManager
|
|
40
39
|
import com.theoplayer.audio.BackgroundAudioConfig
|
|
40
|
+
import com.theoplayer.integration.PlayerFacade
|
|
41
|
+
import com.theoplayer.media.MediaControlProxy
|
|
41
42
|
import com.theoplayer.media.MediaPlaybackService
|
|
42
|
-
import com.theoplayer.media.MediaQueueNavigator
|
|
43
43
|
import com.theoplayer.media.MediaSessionConfig
|
|
44
44
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
45
45
|
|
|
46
46
|
private const val TAG = "ReactTHEOplayerContext"
|
|
47
47
|
|
|
48
|
-
private const val ALLOWED_PLAYBACK_ACTIONS = (
|
|
49
|
-
PlaybackStateCompat.ACTION_PLAY_PAUSE or
|
|
50
|
-
PlaybackStateCompat.ACTION_PLAY or
|
|
51
|
-
PlaybackStateCompat.ACTION_PAUSE or
|
|
52
|
-
PlaybackStateCompat.ACTION_SEEK_TO or
|
|
53
|
-
PlaybackStateCompat.ACTION_FAST_FORWARD or
|
|
54
|
-
PlaybackStateCompat.ACTION_REWIND or
|
|
55
|
-
PlaybackStateCompat.ACTION_SET_PLAYBACK_SPEED)
|
|
56
|
-
|
|
57
|
-
private const val ALLOWED_PLAY_PAUSE_ACTIONS = (
|
|
58
|
-
PlaybackStateCompat.ACTION_PLAY_PAUSE or
|
|
59
|
-
PlaybackStateCompat.ACTION_PLAY or
|
|
60
|
-
PlaybackStateCompat.ACTION_PAUSE)
|
|
61
|
-
|
|
62
|
-
@Suppress("SimplifyBooleanWithConstants", "KotlinConstantConditions")
|
|
63
48
|
class ReactTHEOplayerContext private constructor(
|
|
64
49
|
private val reactContext: ThemedReactContext,
|
|
65
50
|
private val configAdapter: PlayerConfigAdapter
|
|
@@ -67,7 +52,8 @@ class ReactTHEOplayerContext private constructor(
|
|
|
67
52
|
private val mainHandler = Handler(Looper.getMainLooper())
|
|
68
53
|
private var isBound = AtomicBoolean()
|
|
69
54
|
private var binder: MediaPlaybackService.MediaPlaybackBinder? = null
|
|
70
|
-
private var
|
|
55
|
+
private var isDestroyed = false
|
|
56
|
+
|
|
71
57
|
private var audioBecomingNoisyManager = AudioBecomingNoisyManager(reactContext) {
|
|
72
58
|
// Audio is about to become 'noisy' due to a change in audio outputs: pause the player
|
|
73
59
|
player.pause()
|
|
@@ -80,16 +66,48 @@ class ReactTHEOplayerContext private constructor(
|
|
|
80
66
|
field = value
|
|
81
67
|
}
|
|
82
68
|
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
private var mediaSessionConnector: MediaSessionConnector? = null
|
|
70
|
+
|
|
71
|
+
private var mediaSessionConfig: MediaSessionConfig = configAdapter.mediaSessionConfig()
|
|
72
|
+
var mediaControlProxy: MediaControlProxy = MediaControlProxy()
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Whether this player context currently owns the (potentially shared) media session.
|
|
76
|
+
*
|
|
77
|
+
* When multiple players run with background audio, they share a single [MediaPlaybackService]
|
|
78
|
+
* and its media session; only the player that most recently took ownership drives the lock-screen
|
|
79
|
+
* widget. Without a background service each player owns its own local session, so it always owns it.
|
|
80
|
+
*/
|
|
81
|
+
private fun ownsMediaSession(): Boolean {
|
|
82
|
+
return binder?.isActivePlayerContext(this) ?: true
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Enable or disable the media session for this player instance at runtime.
|
|
87
|
+
*
|
|
88
|
+
* When enabling, this player takes over the (potentially shared) media session: it becomes the
|
|
89
|
+
* active source for Now Playing metadata, remote commands and the foreground notification.
|
|
90
|
+
* When disabling, the shared session is only torn down if this player still owns it, so a
|
|
91
|
+
* newly-activated player is never clobbered regardless of the order in which enable/disable run.
|
|
92
|
+
*/
|
|
93
|
+
fun setMediaSessionEnabled(enabled: Boolean) {
|
|
94
|
+
mediaSessionConfig = mediaSessionConfig.copy(mediaSessionEnabled = enabled)
|
|
95
|
+
if (enabled) {
|
|
96
|
+
// Take over the (shared) foreground service/notification for this player.
|
|
97
|
+
binder?.setPlayerContext(this)
|
|
98
|
+
} else if (!ownsMediaSession()) {
|
|
99
|
+
// Only tear down when we still own the session; otherwise another player already took over.
|
|
100
|
+
return
|
|
87
101
|
}
|
|
102
|
+
applyMediaSessionConfig(mediaSessionConnector, mediaSessionConfig)
|
|
103
|
+
}
|
|
88
104
|
|
|
89
105
|
lateinit var playerView: THEOplayerView
|
|
106
|
+
lateinit var player: Player
|
|
107
|
+
private set
|
|
90
108
|
|
|
91
|
-
val
|
|
92
|
-
get() =
|
|
109
|
+
val playerFacade: PlayerFacade?
|
|
110
|
+
get() = player as? PlayerFacade
|
|
93
111
|
|
|
94
112
|
private val uiModeManager by lazy {
|
|
95
113
|
reactContext.getSystemService(Context.UI_MODE_SERVICE) as? UiModeManager
|
|
@@ -121,6 +139,17 @@ class ReactTHEOplayerContext private constructor(
|
|
|
121
139
|
|
|
122
140
|
private val connection = object : ServiceConnection {
|
|
123
141
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
|
142
|
+
// The context may have been destroyed while the bind was still pending.
|
|
143
|
+
// Do not attach the destroyed player/context to the service.
|
|
144
|
+
if (isDestroyed) {
|
|
145
|
+
try {
|
|
146
|
+
reactContext.unbindService(this)
|
|
147
|
+
} catch (e: IllegalArgumentException) {
|
|
148
|
+
// Connection was not registered or already unbound; ignore.
|
|
149
|
+
}
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
|
|
124
153
|
binder = service as MediaPlaybackService.MediaPlaybackBinder
|
|
125
154
|
|
|
126
155
|
// Get media session connector from service
|
|
@@ -130,9 +159,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
130
159
|
|
|
131
160
|
// Pass player context
|
|
132
161
|
binder?.setPlayerContext(this@ReactTHEOplayerContext)
|
|
133
|
-
|
|
134
|
-
// Apply background audio config
|
|
135
|
-
binder?.setEnablePlaybackControls(mediaSessionConfig)
|
|
136
162
|
}
|
|
137
163
|
|
|
138
164
|
override fun onServiceDisconnected(className: ComponentName?) {
|
|
@@ -140,19 +166,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
140
166
|
}
|
|
141
167
|
}
|
|
142
168
|
|
|
143
|
-
private val mediaSessionListener = object : MediaSessionListener() {
|
|
144
|
-
override fun onStop() {
|
|
145
|
-
binder?.stopForegroundService()
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
override fun onPlay() {
|
|
149
|
-
// Optionally seek to live, if configured.
|
|
150
|
-
if (mediaSessionConfig.seekToLiveOnResume && player.duration.isInfinite()) {
|
|
151
|
-
player.currentTime = Double.POSITIVE_INFINITY
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
169
|
private fun applyBackgroundPlaybackConfig(
|
|
157
170
|
config: BackgroundAudioConfig,
|
|
158
171
|
prevConfig: BackgroundAudioConfig?
|
|
@@ -184,21 +197,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
|
|
187
|
-
private fun applyAllowedMediaControls() {
|
|
188
|
-
// Reduce allowed set of remote control playback actions for ads & live streams.
|
|
189
|
-
val isLive = player.duration.isInfinite()
|
|
190
|
-
val isInAd = player.ads.isPlaying
|
|
191
|
-
mediaSessionConnector?.enabledPlaybackActions = when {
|
|
192
|
-
// Allow trick-play for live events if configured
|
|
193
|
-
isLive && mediaSessionConfig.allowLivePlayPause -> ALLOWED_PLAY_PAUSE_ACTIONS
|
|
194
|
-
isLive && !mediaSessionConfig.allowLivePlayPause -> 0
|
|
195
|
-
// Do not allow playback actions during ad play-out
|
|
196
|
-
isInAd -> 0
|
|
197
|
-
|
|
198
|
-
else -> ALLOWED_PLAYBACK_ACTIONS
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
200
|
private fun bindMediaPlaybackService() {
|
|
203
201
|
// Bind to an existing service, if available
|
|
204
202
|
// A bound service runs only as long as another application component is bound to it.
|
|
@@ -219,11 +217,13 @@ class ReactTHEOplayerContext private constructor(
|
|
|
219
217
|
}
|
|
220
218
|
|
|
221
219
|
private fun unbindMediaPlaybackService() {
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
if (
|
|
225
|
-
|
|
220
|
+
// Always unbind when isBound, regardless of whether the binder is alive yet: a pending
|
|
221
|
+
// bind must still be cancelled so a late callback cannot resurrect this.
|
|
222
|
+
if (isBound.getAndSet(false)) {
|
|
223
|
+
try {
|
|
226
224
|
reactContext.unbindService(connection)
|
|
225
|
+
} catch (e: IllegalArgumentException) {
|
|
226
|
+
// Service was not registered or already unbound; ignore.
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
binder = null
|
|
@@ -251,6 +251,7 @@ class ReactTHEOplayerContext private constructor(
|
|
|
251
251
|
mainHandler.post { measureAndLayout() }
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
+
player = PlayerFacade.create(playerView.player, configAdapter.usePlayerFacade())
|
|
254
255
|
|
|
255
256
|
// By default, choose SURFACE_CONTROL/SURFACE_VIEW rendering target, based on API level.
|
|
256
257
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
@@ -265,6 +266,9 @@ class ReactTHEOplayerContext private constructor(
|
|
|
265
266
|
addIntegrations()
|
|
266
267
|
addListeners()
|
|
267
268
|
|
|
269
|
+
// Let the proxy track which media control actions are available for this player.
|
|
270
|
+
mediaControlProxy.setPlayer(player)
|
|
271
|
+
|
|
268
272
|
audioFocusManager = AudioFocusManager(reactContext, player)
|
|
269
273
|
|
|
270
274
|
if (!BuildConfig.USE_PLAYBACK_SERVICE || !isBackgroundAudioEnabled) {
|
|
@@ -279,15 +283,8 @@ class ReactTHEOplayerContext private constructor(
|
|
|
279
283
|
// Destroy any existent media session
|
|
280
284
|
mediaSessionConnector?.destroy()
|
|
281
285
|
|
|
282
|
-
// Create and initialize the media session
|
|
283
|
-
val mediaSession = MediaSessionCompat(reactContext, TAG)
|
|
284
|
-
|
|
285
|
-
// Do not let MediaButtons restart the player when media session is not active.
|
|
286
|
-
// https://developer.android.com/media/legacy/media-buttons#restarting-inactive-mediasessions
|
|
287
|
-
mediaSession.setMediaButtonReceiver(null)
|
|
288
|
-
|
|
289
286
|
// Create a MediaSessionConnector and attach the THEOplayer instance.
|
|
290
|
-
mediaSessionConnector = MediaSessionConnector(
|
|
287
|
+
mediaSessionConnector = MediaSessionConnector(MediaSessionCompat(reactContext, TAG)).also {
|
|
291
288
|
applyMediaSessionConfig(it, mediaSessionConfig)
|
|
292
289
|
}
|
|
293
290
|
}
|
|
@@ -296,9 +293,15 @@ class ReactTHEOplayerContext private constructor(
|
|
|
296
293
|
connector: MediaSessionConnector?,
|
|
297
294
|
config: MediaSessionConfig
|
|
298
295
|
) {
|
|
299
|
-
connector
|
|
296
|
+
if (connector == null) {
|
|
297
|
+
// Keep the proxy up to date even while there is no media session to attach to, as its config
|
|
298
|
+
// also drives the PiP controls.
|
|
299
|
+
mediaControlProxy.setConfig(config)
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
connector.apply {
|
|
300
304
|
debug = BuildConfig.LOG_MEDIASESSION_EVENTS
|
|
301
|
-
removeListener(mediaSessionListener)
|
|
302
305
|
|
|
303
306
|
player = this@ReactTHEOplayerContext.player
|
|
304
307
|
|
|
@@ -306,21 +309,16 @@ class ReactTHEOplayerContext private constructor(
|
|
|
306
309
|
// is backgrounded.
|
|
307
310
|
setActive(!isHostPaused && BuildConfig.EXTENSION_MEDIASESSION && config.mediaSessionEnabled)
|
|
308
311
|
|
|
309
|
-
skipForwardInterval = config.skipForwardInterval
|
|
310
|
-
skipBackwardsInterval = config.skipBackwardInterval
|
|
311
|
-
|
|
312
312
|
// Pass metadata from source description
|
|
313
313
|
setMediaSessionMetadata(player?.source)
|
|
314
314
|
|
|
315
315
|
// Do not let MediaButtons restart the player when media session is not active.
|
|
316
316
|
// https://developer.android.com/media/legacy/media-buttons#restarting-inactive-mediasessions
|
|
317
|
-
|
|
317
|
+
mediaSession.setMediaButtonReceiver(null)
|
|
318
318
|
|
|
319
|
-
//
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
addListener(mediaSessionListener)
|
|
319
|
+
// Route all media control actions through the MediaControlProxy, which will decide whether to
|
|
320
|
+
// invoke the action or not.
|
|
321
|
+
mediaControlProxy.attach(this, binder, config)
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
324
|
|
|
@@ -390,12 +388,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
390
388
|
private val onSourceChange = EventListener<SourceChangeEvent> {
|
|
391
389
|
mediaSessionConnector?.setMediaSessionMetadata(player.source)
|
|
392
390
|
binder?.updateNotification()
|
|
393
|
-
applyAllowedMediaControls()
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
private val onLoadedMetadata = EventListener<LoadedMetadataEvent> {
|
|
397
|
-
binder?.updateNotification()
|
|
398
|
-
applyAllowedMediaControls()
|
|
399
391
|
}
|
|
400
392
|
|
|
401
393
|
private val onPlay = EventListener<PlayEvent> {
|
|
@@ -403,14 +395,12 @@ class ReactTHEOplayerContext private constructor(
|
|
|
403
395
|
bindMediaPlaybackService()
|
|
404
396
|
}
|
|
405
397
|
binder?.updateNotification(PlaybackStateCompat.STATE_PLAYING)
|
|
406
|
-
applyAllowedMediaControls()
|
|
407
398
|
audioBecomingNoisyManager.setEnabled(true)
|
|
408
399
|
audioFocusManager?.requestAudioFocus()
|
|
409
400
|
}
|
|
410
401
|
|
|
411
402
|
private val onPause = EventListener<PauseEvent> {
|
|
412
403
|
binder?.updateNotification(PlaybackStateCompat.STATE_PAUSED)
|
|
413
|
-
applyAllowedMediaControls()
|
|
414
404
|
audioBecomingNoisyManager.setEnabled(false)
|
|
415
405
|
}
|
|
416
406
|
|
|
@@ -436,7 +426,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
436
426
|
private fun addListeners() {
|
|
437
427
|
player.apply {
|
|
438
428
|
addEventListener(PlayerEventTypes.SOURCECHANGE, onSourceChange)
|
|
439
|
-
addEventListener(PlayerEventTypes.LOADEDMETADATA, onLoadedMetadata)
|
|
440
429
|
addEventListener(PlayerEventTypes.PAUSE, onPause)
|
|
441
430
|
addEventListener(PlayerEventTypes.PLAY, onPlay)
|
|
442
431
|
addEventListener(PlayerEventTypes.ENDED, onEnded)
|
|
@@ -450,7 +439,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
450
439
|
private fun removeListeners() {
|
|
451
440
|
player.apply {
|
|
452
441
|
removeEventListener(PlayerEventTypes.SOURCECHANGE, onSourceChange)
|
|
453
|
-
removeEventListener(PlayerEventTypes.LOADEDMETADATA, onLoadedMetadata)
|
|
454
442
|
removeEventListener(PlayerEventTypes.PAUSE, onPause)
|
|
455
443
|
removeEventListener(PlayerEventTypes.PLAY, onPlay)
|
|
456
444
|
removeEventListener(PlayerEventTypes.ENDED, onEnded)
|
|
@@ -492,7 +480,9 @@ class ReactTHEOplayerContext private constructor(
|
|
|
492
480
|
*/
|
|
493
481
|
fun onHostResume() {
|
|
494
482
|
isHostPaused = false
|
|
495
|
-
mediaSessionConnector?.setActive(
|
|
483
|
+
mediaSessionConnector?.setActive(
|
|
484
|
+
BuildConfig.EXTENSION_MEDIASESSION && mediaSessionConfig.mediaSessionEnabled
|
|
485
|
+
)
|
|
496
486
|
playerView.onResume()
|
|
497
487
|
if (!player.isPaused) {
|
|
498
488
|
audioFocusManager?.requestAudioFocus()
|
|
@@ -500,9 +490,14 @@ class ReactTHEOplayerContext private constructor(
|
|
|
500
490
|
}
|
|
501
491
|
|
|
502
492
|
fun destroy() {
|
|
503
|
-
|
|
504
|
-
|
|
493
|
+
isDestroyed = true
|
|
494
|
+
removeListeners()
|
|
505
495
|
|
|
496
|
+
// The media session can be shared with other player contexts through the playback service.
|
|
497
|
+
// Determine ownership before unbinding, as that clears the binder needed to check it.
|
|
498
|
+
val ownedMediaSession = ownsMediaSession()
|
|
499
|
+
|
|
500
|
+
if (BuildConfig.USE_PLAYBACK_SERVICE) {
|
|
506
501
|
// Remove service from foreground
|
|
507
502
|
binder?.stopForegroundService()
|
|
508
503
|
|
|
@@ -510,7 +505,14 @@ class ReactTHEOplayerContext private constructor(
|
|
|
510
505
|
unbindMediaPlaybackService()
|
|
511
506
|
}
|
|
512
507
|
audioFocusManager?.abandonAudioFocus()
|
|
513
|
-
|
|
514
|
-
|
|
508
|
+
mediaControlProxy.destroy()
|
|
509
|
+
if (ownedMediaSession) {
|
|
510
|
+
// Only tear down the session when another player did not take it over: a queued callback
|
|
511
|
+
// must never reach this destroyed player, but a newly-activated player must keep working.
|
|
512
|
+
mediaSessionConnector?.player = null
|
|
513
|
+
mediaSessionConnector?.destroy()
|
|
514
|
+
}
|
|
515
|
+
val facade = playerFacade
|
|
516
|
+
if (facade != null) facade.destroyContent { playerView.onDestroy() } else playerView.onDestroy()
|
|
515
517
|
}
|
|
516
518
|
}
|
|
@@ -10,6 +10,8 @@ import com.theoplayer.cache.CacheModule
|
|
|
10
10
|
import com.theoplayer.drm.ContentProtectionModule
|
|
11
11
|
import com.theoplayer.cast.CastModule
|
|
12
12
|
import com.theoplayer.broadcast.EventBroadcastModule
|
|
13
|
+
import com.theoplayer.media.MediaControlModule
|
|
14
|
+
import com.theoplayer.metrics.MetricsModule
|
|
13
15
|
import com.theoplayer.player.PlayerModule
|
|
14
16
|
import com.theoplayer.theolive.THEOliveModule
|
|
15
17
|
import com.theoplayer.theoads.THEOadsModule
|
|
@@ -26,6 +28,8 @@ class ReactTHEOplayerPackage : BaseReactPackage() {
|
|
|
26
28
|
EventBroadcastModule.NAME -> EventBroadcastModule(reactContext)
|
|
27
29
|
THEOliveModule.NAME -> THEOliveModule(reactContext)
|
|
28
30
|
THEOadsModule.NAME -> THEOadsModule(reactContext)
|
|
31
|
+
MediaControlModule.NAME -> MediaControlModule(reactContext)
|
|
32
|
+
MetricsModule.NAME -> MetricsModule(reactContext)
|
|
29
33
|
else -> null
|
|
30
34
|
}
|
|
31
35
|
}
|
|
@@ -45,6 +49,8 @@ class ReactTHEOplayerPackage : BaseReactPackage() {
|
|
|
45
49
|
EventBroadcastModule.NAME to EventBroadcastModule.INFO,
|
|
46
50
|
THEOliveModule.NAME to THEOliveModule.INFO,
|
|
47
51
|
THEOadsModule.NAME to THEOadsModule.INFO,
|
|
52
|
+
MediaControlModule.NAME to MediaControlModule.INFO,
|
|
53
|
+
MetricsModule.NAME to MetricsModule.INFO,
|
|
48
54
|
)
|
|
49
55
|
}
|
|
50
56
|
}
|