Skip to content

Commit

Permalink
Merge pull request #222 from THEOplayer/release/v3.1.0
Browse files Browse the repository at this point in the history
Release/v3.1.0
  • Loading branch information
tvanlaerhoven authored Oct 27, 2023
2 parents 3b6e9b8 + dd29bbf commit eff06bc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 40 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.1.0] - 23-10-27

### Changed

- Revised audio focus protocol on Android. When resuming an app, audio focus is retrieved only if the player is not paused.
- Changed the behaviour of the Android component supporting background playback. It is stopped but not disabled when setting `backgroundAudioConfiguration.enabled = true`.

### Fixed

- Fixed an issue on Android where during play-out of a locally stored media asset the `seekable` property would not update.
- Fixed an issue on iOS where the error was not forwarded to theoplayer if a drm request fails on the iOS bridge

## [3.0.2] - 23-10-17

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:name="com.theoplayer.media.MediaPlaybackService"
android:description="@string/background_playback_service_description"
android:exported="false"
android:enabled="false"
android:enabled="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
Expand Down
33 changes: 4 additions & 29 deletions android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.os.Handler
import android.os.IBinder
Expand Down Expand Up @@ -74,7 +73,7 @@ class ReactTHEOplayerContext private constructor(
var imaIntegration: GoogleImaIntegration? = null
var castIntegration: CastIntegration? = null
var wasPlayingOnHostPause: Boolean = false
var isHostPaused: Boolean = false
private var isHostPaused: Boolean = false

private val isBackgroundAudioEnabled: Boolean
get() = backgroundAudioConfig.enabled
Expand Down Expand Up @@ -113,27 +112,6 @@ class ReactTHEOplayerContext private constructor(
}
}

private fun setPlaybackServiceEnabled(enabled: Boolean) {
// Toggle the MediaPlaybackService.
toggleComponent(enabled, ComponentName(reactContext.applicationContext, MediaPlaybackService::class.java))

// Also toggle any registered MediaButtonReceiver broadcast receiver.
// It will crash the app if it remains active and tries to find our disabled MediaBrowserService instance.
toggleComponent(enabled, ComponentName(reactContext.applicationContext, androidx.media.session.MediaButtonReceiver::class.java))
}

/**
* Enable or disable a receiver component.
*/
private fun toggleComponent(enabled: Boolean, componentName: ComponentName) {
reactContext.applicationContext.packageManager.setComponentEnabledSetting(
componentName,
if (enabled) PackageManager.COMPONENT_ENABLED_STATE_ENABLED
else PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
}

private fun applyBackgroundPlaybackConfig(
config: BackgroundAudioConfig,
prevConfig: BackgroundAudioConfig?
Expand All @@ -148,13 +126,8 @@ class ReactTHEOplayerContext private constructor(
if (BuildConfig.USE_PLAYBACK_SERVICE) {
if (prevConfig?.enabled != true && config.enabled) {
// Enable & bind background playback
setPlaybackServiceEnabled(true)
bindMediaPlaybackService()
} else if (prevConfig?.enabled == true) {
// First disable the MediaPlaybackService and MediaButtonReceiver so that no more media
// button events can be captured.
setPlaybackServiceEnabled(false)

// Stop & unbind MediaPlaybackService.
binder?.stopForegroundService()
unbindMediaPlaybackService()
Expand Down Expand Up @@ -379,7 +352,9 @@ class ReactTHEOplayerContext private constructor(
isHostPaused = false
mediaSessionConnector?.setActive(true)
playerView.onResume()
audioFocusManager?.retrieveAudioFocus()
if (!player.isPaused) {
audioFocusManager?.retrieveAudioFocus()
}
}

fun destroy() {
Expand Down
6 changes: 3 additions & 3 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion ios/THEOplayerRCTNetworkUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class THEOplayerRCTNetworkUtils: NSObject, URLSessionDataDelegate {
let task = self.defaultUrlSession.dataTask(with: request) { data, response, error in
if let error = error {
PrintUtils.printLog(logText: "request Error: \(error.localizedDescription)")
return
}
if let urlResponse = response as? HTTPURLResponse {
let statusCode = urlResponse.statusCode
Expand All @@ -44,7 +43,10 @@ class THEOplayerRCTNetworkUtils: NSObject, URLSessionDataDelegate {
}
}
completion?(data, statusCode, allHeaders, error)
} else {
completion?(data, -1, [:], error)
}

}
// start the task
task.resume()
Expand Down
4 changes: 4 additions & 0 deletions ios/contentprotection/THEOplayerRCTContentProtectionAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ class THEOplayerRCTContentProtectionAPI: RCTEventEmitter {
THEOplayerRCTNetworkUtils.shared.requestFromUrl(url: url, method: method, body: bodyData, headers: headers) { data, statusCode, responseHeaders, error in
if let responseError = error {
print(CPI_TAG, "Certificate request failure: error = \(responseError.localizedDescription)")
completion(data, error)
} else if statusCode >= 400 {
PrintUtils.printLog(logText: "Certificate request failure: statusCode = \(statusCode)")
completion(data, nil)
} else {
if DEBUG_CONTENT_PROTECTION_API {print(CPI_TAG, "Certificate request success: statusCode = \(statusCode)") }
let certificateRequest = CertificateRequest(url: urlString, method: method, headers: headers, body: bodyData)
Expand Down Expand Up @@ -278,8 +280,10 @@ class THEOplayerRCTContentProtectionAPI: RCTEventEmitter {
THEOplayerRCTNetworkUtils.shared.requestFromUrl(url: url, method: method, body: bodyData, headers: headers) { data, statusCode, responseHeaders, error in
if let responseError = error {
print(CPI_TAG, "License request failure: error = \(responseError.localizedDescription)")
completion(data, error)
} else if statusCode >= 400 {
print(CPI_TAG, "License request failure: statusCode = \(statusCode)")
completion(data, nil)
} else {
if DEBUG_CONTENT_PROTECTION_API {print(CPI_TAG, "License request success: statusCode = \(statusCode)") }
let licenseRequest = LicenseRequest(url: urlString, method: method, headers: headers, body: bodyData, fairplaySkdUrl: nil, useCredentials: false)
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-theoplayer",
"version": "3.0.2",
"version": "3.1.0",
"description": "A THEOplayer video component for react-native.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
3 changes: 3 additions & 0 deletions src/internal/adapter/THEOplayerAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
this._state.selectedAudioTrack = event.selectedAudioTrack;
this._state.selectedVideoTrack = event.selectedVideoTrack;
this._state.selectedTextTrack = event.selectedTextTrack;
if (isFinite(this._state.duration)) {
this._state.seekable = [{start: 0, end: this._state.duration}];
}
};

private onDurationChange = (event: DurationChangeEvent) => {
Expand Down

0 comments on commit eff06bc

Please sign in to comment.