react-native-theoplayer 8.2.1 → 8.3.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 CHANGED
@@ -5,6 +5,16 @@ 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
+ ## [8.3.0] - 24-09-30
9
+
10
+ ### Added
11
+
12
+ - Added the option to specify the AVAudioSession mode for iOS (moviePlayback versus spokenAudio).
13
+
14
+ ## [8.2.2] - 24-09-28
15
+
16
+ - Fixed a build issue on iOS for applications that run without the GOOGLE_IMA feature flag
17
+
8
18
  ## [8.2.1] - 24-09-27
9
19
 
10
20
  ### Fixed
@@ -106,6 +106,10 @@ repositories {
106
106
  maven { url "https://maven.theoplayer.com/releases" }
107
107
  }
108
108
 
109
+ // The minimum supported THEOplayer version is 8.1.0
110
+ def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[8.1.0, 9.0.0)')
111
+ def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', '[8.1.0, 9.0.0)')
112
+
109
113
  dependencies {
110
114
  //noinspection GradleDynamicVersion
111
115
  implementation "com.facebook.react:react-native:+" // From node_modules
@@ -114,10 +118,6 @@ dependencies {
114
118
  implementation "androidx.core:core-ktx:${safeExtGet('corektxVersion', '1.10.1')}"
115
119
  implementation "com.google.code.gson:gson:2.11.0"
116
120
 
117
- // The minimum supported THEOplayer version is 8.1.0
118
- def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[8.1.0, 9.0.0)')
119
- def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', '[8.1.0, 9.0.0)')
120
-
121
121
  println("Using THEOplayer (${versionString(theoplayer_sdk_version)})")
122
122
  implementation "com.theoplayer.theoplayer-sdk-android:core:${theoplayer_sdk_version}"
123
123
  implementation "com.theoplayer.theoplayer-sdk-android:ads-wrapper:8.0.0"
@@ -151,3 +151,13 @@ dependencies {
151
151
  compileOnly "com.theoplayer.theoplayer-sdk-android:integration-cast:${theoplayer_sdk_version}"
152
152
  }
153
153
  }
154
+
155
+ // Make sure to align all ads extension versions
156
+ configurations.configureEach {
157
+ resolutionStrategy {
158
+ force "com.theoplayer.theoplayer-sdk-android:integration-ads:${theoplayer_sdk_version}"
159
+ force "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:${theoplayer_sdk_version}"
160
+ force "com.theoplayer.theoplayer-sdk-android:integration-ads-dai:${theoplayer_sdk_version}"
161
+ }
162
+ }
163
+
@@ -224,6 +224,9 @@ class THEOplayerRCTPlayerAPI: NSObject, RCTBridgeModule {
224
224
  var backgroundAudio = BackgroundAudioConfig()
225
225
  backgroundAudio.enabled = configDict["enabled"] as? Bool ?? false
226
226
  backgroundAudio.shouldResumeAfterInterruption = configDict["shouldResumeAfterInterruption"] as? Bool ?? false
227
+ if let audioSessionModeString = configDict["audioSessionMode"] as? String {
228
+ backgroundAudio.audioSessionMode = THEOplayerRCTTypeUtils.audioSessionModeFromString(audioSessionModeString)
229
+ }
227
230
  return backgroundAudio
228
231
  }
229
232
 
@@ -1,6 +1,7 @@
1
1
  // THEOplayerRCTTypeUtils.swift
2
2
 
3
3
  import Foundation
4
+ import AVKit
4
5
  import THEOplayerSDK
5
6
 
6
7
  let NAN_VALUE: Double = -1.0
@@ -111,6 +112,17 @@ class THEOplayerRCTTypeUtils {
111
112
  return AdIntegrationKind.custom
112
113
  }
113
114
  }
115
+
116
+ class func audioSessionModeFromString(_ audioSessionModeString: String) -> AVAudioSession.Mode {
117
+ switch audioSessionModeString {
118
+ case "moviePlayback":
119
+ return .moviePlayback
120
+ case "spokenAudio":
121
+ return .spokenAudio
122
+ default:
123
+ return .moviePlayback
124
+ }
125
+ }
114
126
 
115
127
  #if os(iOS)
116
128
  class func cacheStatusToString(_ status: CacheStatus) -> String {
@@ -36,6 +36,7 @@ public class THEOplayerRCTView: UIView {
36
36
  var backgroundAudioConfig = BackgroundAudioConfig() {
37
37
  didSet {
38
38
  self.updateInterruptionNotifications()
39
+ self.updateAVAudioSessionMode()
39
40
  }
40
41
  }
41
42
 
@@ -9,7 +9,7 @@ import GoogleInteractiveMediaAds
9
9
 
10
10
  struct AdsConfig {
11
11
  var adSUIEnabled: Bool = true
12
- var adsImaConfig = AdsImaConfig()
12
+ var adsImaConfig = AdsImaConfig(maxRedirects: 4, enableDebugMode: false)
13
13
  var allowedMimeTypes: [String]?
14
14
  }
15
15
 
@@ -20,7 +20,21 @@ struct AdsImaConfig {
20
20
  var featureFlags: [String:String]?
21
21
  var autoPlayAdBreaks: Bool?
22
22
  var sessionID: String?
23
- var bitrate: Int = kIMAAutodetectBitrate
23
+ var bitrate: Int
24
+
25
+ init(maxRedirects: UInt, enableDebugMode: Bool, ppid: String? = nil, featureFlags: [String : String]? = nil, autoPlayAdBreaks: Bool? = nil, sessionID: String? = nil, bitrate: Int? = -1) {
26
+ self.maxRedirects = maxRedirects
27
+ self.enableDebugMode = enableDebugMode
28
+ self.ppid = ppid
29
+ self.featureFlags = featureFlags
30
+ self.autoPlayAdBreaks = autoPlayAdBreaks
31
+ self.sessionID = sessionID
32
+ #if canImport(THEOplayerGoogleIMAIntegration)
33
+ self.bitrate = bitrate ?? kIMAAutodetectBitrate
34
+ #else
35
+ self.bitrate = bitrate ?? -1
36
+ #endif
37
+ }
24
38
  }
25
39
 
26
40
  #if os(iOS)
@@ -50,7 +64,9 @@ extension THEOplayerRCTView {
50
64
  if let enableDebugMode = adsImaConfig["enableDebugMode"] as? Bool {
51
65
  self.adsConfig.adsImaConfig.enableDebugMode = enableDebugMode
52
66
  }
53
- self.adsConfig.adsImaConfig.bitrate = adsImaConfig["bitrate"] as? Int ?? kIMAAutodetectBitrate
67
+ if let bitrate = adsImaConfig["bitrate"] as? Int {
68
+ self.adsConfig.adsImaConfig.bitrate = bitrate
69
+ }
54
70
  }
55
71
  }
56
72
  }
@@ -3,10 +3,12 @@
3
3
  import Foundation
4
4
  import THEOplayerSDK
5
5
  import AVFAudio
6
+ import AVKit
6
7
 
7
8
  struct BackgroundAudioConfig {
8
9
  var enabled: Bool = false
9
10
  var shouldResumeAfterInterruption: Bool = false
11
+ var audioSessionMode: AVAudioSession.Mode = .moviePlayback
10
12
  }
11
13
 
12
14
  extension THEOplayerRCTView: BackgroundPlaybackDelegate {
@@ -46,6 +48,17 @@ extension THEOplayerRCTView: BackgroundPlaybackDelegate {
46
48
  }
47
49
  }
48
50
 
51
+ func updateAVAudioSessionMode() {
52
+ do {
53
+ THEOplayer.automaticallyManageAudioSession = (self.backgroundAudioConfig.audioSessionMode == .moviePlayback)
54
+ try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: self.backgroundAudioConfig.audioSessionMode)
55
+ if self.backgroundAudioConfig.audioSessionMode != .moviePlayback {
56
+ print("[NATIVE] AVAudioSession mode updated to \(self.backgroundAudioConfig.audioSessionMode.rawValue)")
57
+ }
58
+ } catch {
59
+ print("[NATIVE] Unable to update AVAudioSession mode to \(self.backgroundAudioConfig.audioSessionMode.rawValue): ", error)
60
+ }
61
+ }
49
62
 
50
63
  @objc func handleInterruption(notification: Notification) {
51
64
  guard let userInfo = notification.userInfo,
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AudioSessionMode = void 0;
7
+ /**
8
+ * Describes the configuration of the background audio feature.
9
+ *
10
+ * @public
11
+ */
12
+ let AudioSessionMode = exports.AudioSessionMode = /*#__PURE__*/function (AudioSessionMode) {
13
+ AudioSessionMode["MOVIE_PLAYBACK"] = "moviePlayback";
14
+ AudioSessionMode["SPOKEN_AUDIO"] = "spokenAudio";
15
+ return AudioSessionMode;
16
+ }({});
2
17
  //# sourceMappingURL=BackgroundAudioConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["api/backgroundAudio/BackgroundAudioConfiguration.ts"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":["AudioSessionMode","exports"],"sourceRoot":"../../../../src","sources":["api/backgroundAudio/BackgroundAudioConfiguration.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAJA,IA8BYA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA","ignoreList":[]}
@@ -1,2 +1,12 @@
1
+ /**
2
+ * Describes the configuration of the background audio feature.
3
+ *
4
+ * @public
5
+ */
1
6
 
7
+ export let AudioSessionMode = /*#__PURE__*/function (AudioSessionMode) {
8
+ AudioSessionMode["MOVIE_PLAYBACK"] = "moviePlayback";
9
+ AudioSessionMode["SPOKEN_AUDIO"] = "spokenAudio";
10
+ return AudioSessionMode;
11
+ }({});
2
12
  //# sourceMappingURL=BackgroundAudioConfiguration.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["api/backgroundAudio/BackgroundAudioConfiguration.ts"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":["AudioSessionMode"],"sourceRoot":"../../../../src","sources":["api/backgroundAudio/BackgroundAudioConfiguration.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AA0BA,WAAYA,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA","ignoreList":[]}
@@ -11,11 +11,22 @@ export interface BackgroundAudioConfiguration {
11
11
  */
12
12
  readonly enabled?: boolean;
13
13
  /**
14
- * Whether background audio should be resumed after an interruption (e.g. incoming call ended).
14
+ * Whether background audio should be resumed after an interruption on iOS (e.g. incoming call).
15
15
  *
16
16
  * @defaultValue `false`
17
- * @remark Applies to iOS only, impacting behaviour for handling interruptions while on the lockscreen.
17
+ * @remark Applies to iOS only, impacting behaviour for handling interruptions.
18
18
  */
19
19
  readonly shouldResumeAfterInterruption?: boolean;
20
+ /**
21
+ * Specify the mode for the native iOS AVAudioSession.
22
+ *
23
+ * @defaultValue `AudioSessionMode.MOVIE_PLAYBACK`
24
+ * @remark Applies to iOS only, impacting behaviour for handling interruptions.
25
+ */
26
+ readonly audioSessionMode?: AudioSessionMode;
27
+ }
28
+ export declare enum AudioSessionMode {
29
+ MOVIE_PLAYBACK = "moviePlayback",
30
+ SPOKEN_AUDIO = "spokenAudio"
20
31
  }
21
32
  //# sourceMappingURL=BackgroundAudioConfiguration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BackgroundAudioConfiguration.d.ts","sourceRoot":"","sources":["../../../../src/api/backgroundAudio/BackgroundAudioConfiguration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,QAAQ,CAAC,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAClD"}
1
+ {"version":3,"file":"BackgroundAudioConfiguration.d.ts","sourceRoot":"","sources":["../../../../src/api/backgroundAudio/BackgroundAudioConfiguration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,QAAQ,CAAC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CAC9C;AAED,oBAAY,gBAAgB;IAC1B,cAAc,kBAAkB;IAChC,YAAY,gBAAgB;CAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-theoplayer",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "description": "A THEOplayer video component for react-native.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -12,10 +12,23 @@ export interface BackgroundAudioConfiguration {
12
12
  readonly enabled?: boolean;
13
13
 
14
14
  /**
15
- * Whether background audio should be resumed after an interruption (e.g. incoming call ended).
15
+ * Whether background audio should be resumed after an interruption on iOS (e.g. incoming call).
16
16
  *
17
17
  * @defaultValue `false`
18
- * @remark Applies to iOS only, impacting behaviour for handling interruptions while on the lockscreen.
18
+ * @remark Applies to iOS only, impacting behaviour for handling interruptions.
19
19
  */
20
20
  readonly shouldResumeAfterInterruption?: boolean;
21
+
22
+ /**
23
+ * Specify the mode for the native iOS AVAudioSession.
24
+ *
25
+ * @defaultValue `AudioSessionMode.MOVIE_PLAYBACK`
26
+ * @remark Applies to iOS only, impacting behaviour for handling interruptions.
27
+ */
28
+ readonly audioSessionMode?: AudioSessionMode;
29
+ }
30
+
31
+ export enum AudioSessionMode {
32
+ MOVIE_PLAYBACK = 'moviePlayback',
33
+ SPOKEN_AUDIO = 'spokenAudio'
21
34
  }