react-native-theoplayer 2.14.0 → 2.15.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,18 @@ 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
+ ## [2.15.0] - 23-09-26
9
+
10
+ ### Changed
11
+
12
+ - Upgraded the iOS side-loaded text track connector.
13
+
14
+ ### Fixed
15
+
16
+ - Fixed an issue where the Android mediaSession connector would still process media button events when the app was in the background, and `enableBackgroundPlayback` was false.
17
+ - Fixed an issue on Android where play-out would still start when the app was put to the background during initial buffering, and `enableBackgroundPlayback` was false.
18
+ - Fixed an issue on Android where the MediaButtonReceiver would crash the app when it did not find a registered MediaBrowserService instance, when setting `enableBackgroundPlayback` to false while backgrounding the app.
19
+
8
20
  ## [2.14.0] - 23-09-25
9
21
 
10
22
  ### Fixed
@@ -109,7 +109,7 @@ dependencies {
109
109
  def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[5.10,6.0)')
110
110
 
111
111
  // def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', theoplayer_sdk_version)
112
- def theoplayer_mediasession_version = "5.2.0-local"
112
+ def theoplayer_mediasession_version = "5.11.0-local"
113
113
  def enabledV4 = theoplayer_sdk_version.toString().startsWith("4.")
114
114
  def core_prefix = enabledV4 ? 'unified' : 'core'
115
115
  def integration_prefix = enabledV4 ? 'unified' : 'integration'
@@ -3,7 +3,7 @@
3
3
  <modelVersion>4.0.0</modelVersion>
4
4
  <groupId>com.theoplayer.android-connector</groupId>
5
5
  <artifactId>mediasession</artifactId>
6
- <version>5.2.0-local</version>
6
+ <version>5.11.0-local</version>
7
7
  <packaging>aar</packaging>
8
8
  <dependencies>
9
9
  <dependency>
@@ -3,11 +3,11 @@
3
3
  <groupId>com.theoplayer.android-connector</groupId>
4
4
  <artifactId>mediasession</artifactId>
5
5
  <versioning>
6
- <latest>5.2.0-local</latest>
7
- <release>5.2.0-local</release>
6
+ <latest>5.11.0-local</latest>
7
+ <release>5.11.0-local</release>
8
8
  <versions>
9
- <version>5.2.0-local</version>
9
+ <version>5.11.0-local</version>
10
10
  </versions>
11
- <lastUpdated>20230531125422</lastUpdated>
11
+ <lastUpdated>20230926085823</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -76,6 +76,7 @@ class ReactTHEOplayerContext private constructor(
76
76
  var imaIntegration: GoogleImaIntegration? = null
77
77
  var castIntegration: CastIntegration? = null
78
78
  var wasPlayingOnHostPause: Boolean = false
79
+ var isHostPaused: Boolean = false
79
80
 
80
81
  private val isBackgroundAudioEnabled: Boolean
81
82
  get() = backgroundAudioConfig.enabled
@@ -148,15 +149,25 @@ class ReactTHEOplayerContext private constructor(
148
149
 
149
150
  if (BuildConfig.USE_PLAYBACK_SERVICE) {
150
151
  if (prevConfig?.enabled != true && config.enabled) {
151
- // Enabling background playback
152
+ // Enable & bind background playback
152
153
  setPlaybackServiceEnabled(true)
153
154
  bindMediaPlaybackService()
154
155
  } else if (prevConfig?.enabled == true) {
155
- // Disabling background playback
156
+ // First disable the MediaPlaybackService and MediaButtonReceiver so that no more media
157
+ // button events can be captured.
158
+ setPlaybackServiceEnabled(false)
159
+
160
+ // Stop & unbind MediaPlaybackService.
156
161
  binder?.stopForegroundService()
157
162
  unbindMediaPlaybackService()
158
- setPlaybackServiceEnabled(false)
163
+
164
+ // Create a new media session.
159
165
  initDefaultMediaSession()
166
+
167
+ // If the app is currently backgrounded, apply state changes.
168
+ if (isHostPaused) {
169
+ applyHostPaused()
170
+ }
160
171
  }
161
172
  }
162
173
  }
@@ -251,8 +262,9 @@ class ReactTHEOplayerContext private constructor(
251
262
  debug = BuildConfig.LOG_MEDIASESSION_EVENTS
252
263
  player = this@ReactTHEOplayerContext.player
253
264
 
254
- // Set mediaSession active
255
- setActive(true)
265
+ // Set mediaSession active and ready to receive media button events, but not if the player
266
+ // is backgrounded.
267
+ setActive(!isHostPaused)
256
268
  }
257
269
  }
258
270
 
@@ -344,11 +356,19 @@ class ReactTHEOplayerContext private constructor(
344
356
  * The host activity is paused.
345
357
  */
346
358
  fun onHostPause() {
359
+ isHostPaused = true
360
+ applyHostPaused()
361
+ }
362
+
363
+ private fun applyHostPaused() {
347
364
  // Keep current playing state when going to background
348
365
  wasPlayingOnHostPause = !player.isPaused
349
366
  playerView.onPause()
350
367
  if (!isBackgroundAudioEnabled) {
351
368
  mediaSessionConnector?.setActive(false)
369
+
370
+ // The player pauses and goes to the background, we can abandon audio focus.
371
+ audioFocusManager?.abandonAudioFocus()
352
372
  }
353
373
  }
354
374
 
@@ -356,6 +376,7 @@ class ReactTHEOplayerContext private constructor(
356
376
  * The host activity is resumed.
357
377
  */
358
378
  fun onHostResume() {
379
+ isHostPaused = false
359
380
  mediaSessionConnector?.setActive(true)
360
381
  playerView.onResume()
361
382
  audioFocusManager?.retrieveAudioFocus()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-theoplayer",
3
- "version": "2.14.0",
3
+ "version": "2.15.0",
4
4
  "description": "A THEOplayer video component for react-native.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -47,7 +47,7 @@ Pod::Spec.new do |s|
47
47
  end
48
48
  if theofeatures.include?("SIDELOADED_TEXTTRACKS")
49
49
  puts "Adding THEOplayer-Connector-SideloadedSubtitle"
50
- s.dependency "THEOplayer-Connector-SideloadedSubtitle", "~> 5.11"
50
+ s.dependency "THEOplayer-Connector-SideloadedSubtitle", "6.0"
51
51
  end
52
52
  end
53
53