Skip to content

Commit

Permalink
Merge pull request #399 from THEOplayer/release/v8.2.0
Browse files Browse the repository at this point in the history
Release/v8.2.0
  • Loading branch information
tvanlaerhoven authored Sep 26, 2024
2 parents 25e5c91 + d584174 commit 3ebd36b
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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).

## [8.2.0] - 24-09-26

### Added

- Added the `PlaybackSettings` API for Android, allowing control of playback behaviour across all THEOplayer instances.

## [8.1.0] - 24-09-23

### Added
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ dependencies {
implementation "androidx.core:core-ktx:${safeExtGet('corektxVersion', '1.10.1')}"
implementation "com.google.code.gson:gson:2.11.0"

// The minimum supported THEOplayer version is 7.12.0
def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[7.12.0, 9.0.0)')
def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', '[7.12.0, 9.0.0)')
// The minimum supported THEOplayer version is 8.1.0
def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[8.1.0, 9.0.0)')
def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', '[8.1.0, 9.0.0)')

println("Using THEOplayer (${versionString(theoplayer_sdk_version)})")
implementation "com.theoplayer.theoplayer-sdk-android:core:${theoplayer_sdk_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.theoplayer.cache.CacheModule
import com.theoplayer.drm.ContentProtectionModule
import com.theoplayer.cast.CastModule
import com.theoplayer.broadcast.EventBroadcastModule
import com.theoplayer.playback.PlaybackSettingsModule
import com.theoplayer.player.PlayerModule

class ReactTHEOplayerPackage : ReactPackage {
Expand All @@ -19,7 +20,8 @@ class ReactTHEOplayerPackage : ReactPackage {
ContentProtectionModule(reactContext),
CastModule(reactContext),
CacheModule(reactContext),
EventBroadcastModule(reactContext)
EventBroadcastModule(reactContext),
PlaybackSettingsModule(reactContext)
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.theoplayer.playback

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.theoplayer.android.api.THEOplayerGlobal
import com.theoplayer.android.api.settings.PlaybackSettings

class PlaybackSettingsModule(private val context: ReactApplicationContext) :
ReactContextBaseJavaModule(context) {

private val playbackSettings: PlaybackSettings
get() = THEOplayerGlobal.getSharedInstance(context.applicationContext).playbackSettings

override fun getName(): String {
return "THEORCTPlaybackSettingsModule"
}

@ReactMethod
fun useFastStartup(useFastStartup: Boolean) {
playbackSettings.useFastStartup(useFastStartup)
}

@ReactMethod
fun setLipSyncCorrection(correctionMs: Double) {
playbackSettings.setLipSyncCorrection(correctionMs.toLong())
}
}
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ newArchEnabled=false
hermesEnabled=true

# Version of the THEOplayer SDK, if not specified, the latest available version within bounds is set.
#THEOplayer_sdk=[7.12.0, 9.0.0)
#THEOplayer_sdk=[8.1.0, 9.0.0)

# Override Android sdk versions
#THEOplayer_compileSdkVersion = 34
Expand Down
4 changes: 2 additions & 2 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": "8.1.0",
"version": "8.2.0",
"description": "A THEOplayer video component for react-native.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
39 changes: 39 additions & 0 deletions src/api/playback/PlaybackSettingsAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* The playback settings for all instances of THEOplayer.
*/
export interface PlaybackSettingsAPI {

/**
* The player starts the playback as soon as the first video data is available related to the initial playback position.
*
* <ul>
* <li>Using this feature will sacrifice the accuracy of the initial seek position
* <li>This API is in an experimental stage and may be subject to breaking changes.
* </ul>
*
* @experimental
* @param {boolean} useFastStartup Whether fast startup is enabled.
*
* @remarks
* - This API is experimental.
* - This property is supported on Android platforms only.
*/
useFastStartup(useFastStartup: boolean): void;

/**
* Sets the lip sync correction delay.
*
* This method adjusts the synchronization between audio and video playback for all instances of THEOplayer
* by applying a specified correction delay.
*
* @experimental
* @since Native THEOplayer SDK v8.1.0.
* @param {number} correctionMs The correction delay in milliseconds.
* Positive values advance the audio, while negative values delay it.
*
* @remarks
* - This API is experimental.
* - This property is supported on Android platforms only.
*/
setLipSyncCorrection(correctionMs: number): void;
}
1 change: 1 addition & 0 deletions src/api/playback/barrel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './PlaybackSettingsAPI';
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './api/barrel';
export { THEOplayerView } from './internal/THEOplayerView';
export { ContentProtectionRegistry } from './internal/drm/ContentProtectionRegistry';
export { MediaCache } from './internal/cache/MediaCache';
export { PlaybackSettings } from './internal/playback/PlaybackSettings';
25 changes: 25 additions & 0 deletions src/internal/playback/PlaybackSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NativeModules, Platform } from 'react-native';
import { PlaybackSettingsAPI } from '../../api/playback/PlaybackSettingsAPI';

const NativePlaybackSettingsModule = NativeModules.THEORCTPlaybackSettingsModule;

const TAG = 'PlaybackSettings';

export class NativePlaybackSettings implements PlaybackSettingsAPI {
useFastStartup(useFastStartup: boolean): void {
if (Platform.OS !== 'android') {
console.warn(TAG, 'useFastStartup is only available on Android platforms.');
return;
}
NativePlaybackSettingsModule.useFastStartup(useFastStartup);
}
setLipSyncCorrection(correctionMs: number): void {
if (Platform.OS !== 'android') {
console.warn(TAG, 'setLipSyncCorrect is only available on Android platforms.');
return;
}
NativePlaybackSettingsModule.setLipSyncCorrection(correctionMs);
}
}

export const PlaybackSettings: PlaybackSettingsAPI = new NativePlaybackSettings();

0 comments on commit 3ebd36b

Please sign in to comment.