Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Fixed an issue on iOS where the onPlayerStateSync callback was not called from the main thread.
- Fixed an issue on iOS where the `onPlayerStateSync` callback was not called from the main thread.

### Added

- Added the `DistributionLoaded` event for THEOlive.

## [10.9.0] - 26-01-29

Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ repositories {
mavenLocal()
}

// The minimum supported THEOplayer version is 10.0.1
def theoVersion = safeExtGet('THEOplayer_sdk', '[10.0.1, 11.0.0)')
// The minimum supported THEOplayer version is 10.10.0
def theoVersion = safeExtGet('THEOplayer_sdk', '[10.10.0, 11.0.0)')
def theoMediaSessionVersion = safeExtGet('THEOplayer_mediasession', '[8.0.0, 11.0.0)')
def theoAdsWrapperVersion = "10.0.0"
def coroutinesVersion = safeExtGet('coroutinesVersion', '1.10.2')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.theoplayer.android.api.event.EventListener
import com.theoplayer.android.api.event.player.theolive.DistributionLoadStartEvent
import com.theoplayer.android.api.event.player.theolive.DistributionLoadedEvent
import com.theoplayer.android.api.event.player.theolive.DistributionOfflineEvent
import com.theoplayer.android.api.event.player.theolive.EndpointLoadedEvent
import com.theoplayer.android.api.event.player.theolive.IntentToFallbackEvent
Expand All @@ -13,8 +14,11 @@ import com.theoplayer.util.PayloadBuilder

private const val EVENT_PROP_TYPE = "type"
private const val EVENT_PROP_DISTRIBUTION_ID = "distributionId"
private const val EVENT_PROP_DISTRIBUTION = "distribution"
private const val EVENT_PROP_ENDPOINT = "endpoint"
private const val EVENT_PROP_REASON = "reason"
private const val EVENT_PROP_NAME = "name"
private const val EVENT_PROP_ID = "id"

class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitter: Emitter) {

Expand All @@ -24,6 +28,8 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte

private val onDistributionLoadStart =
EventListener<DistributionLoadStartEvent> { onDistributionLoadStart(it) }
private val onDistributionLoaded =
EventListener<DistributionLoadedEvent> { onDistributionLoaded(it) }
private val onDistributionOffline =
EventListener<DistributionOfflineEvent> { onDistributionOffline(it) }
private val onEndPointLoaded =
Expand All @@ -33,6 +39,7 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte

init {
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONLOADSTART, onDistributionLoadStart)
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONLOADED, onDistributionLoaded)
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONOFFLINE, onDistributionOffline)
theoLiveApi.addEventListener(TheoLiveEventTypes.ENDPOINTLOADED, onEndPointLoaded)
theoLiveApi.addEventListener(TheoLiveEventTypes.INTENTTOFALLBACK, onIntentOfFallback)
Expand All @@ -43,6 +50,7 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
TheoLiveEventTypes.DISTRIBUTIONLOADSTART,
onDistributionLoadStart
)
theoLiveApi.removeEventListener(TheoLiveEventTypes.DISTRIBUTIONLOADED, onDistributionLoaded)
theoLiveApi.removeEventListener(TheoLiveEventTypes.DISTRIBUTIONOFFLINE, onDistributionOffline)
theoLiveApi.removeEventListener(TheoLiveEventTypes.ENDPOINTLOADED, onEndPointLoaded)
theoLiveApi.removeEventListener(TheoLiveEventTypes.INTENTTOFALLBACK, onIntentOfFallback)
Expand All @@ -55,6 +63,16 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
})
}

private fun onDistributionLoaded(event: DistributionLoadedEvent) {
emitter.emit(Arguments.createMap().apply {
putString(EVENT_PROP_TYPE, "distributionloaded")
putMap(EVENT_PROP_DISTRIBUTION, Arguments.createMap().apply {
putString(EVENT_PROP_ID, event.getDistribution().id)
putString(EVENT_PROP_NAME, event.getDistribution().name)
})
})
}

private fun onDistributionOffline(event: DistributionOfflineEvent) {
emitter.emit(Arguments.createMap().apply {
putString(EVENT_PROP_TYPE, "distributionoffline")
Expand Down
2 changes: 1 addition & 1 deletion e2e/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ newArchEnabled=true
hermesEnabled=true

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

# Override Android sdk versions
#THEOplayer_compileSdkVersion = 34
Expand Down
6 changes: 3 additions & 3 deletions e2e/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 example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ hermesEnabled=true
edgeToEdgeEnabled=false

# Version of the THEOplayer SDK, if not specified, the latest available version within bounds is set.
#THEOplayer_sdk=[10.0.1, 11.0.0)
#THEOplayer_sdk=[10.10.0, 11.0.0)

# Override Android sdk versions
#THEOplayer_compileSdkVersion = 36
Expand Down
8 changes: 4 additions & 4 deletions example/package-lock.json

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

16 changes: 16 additions & 0 deletions ios/theolive/THEOplayerRCTTHEOliveEventAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let PROP_ENDPOINT_PRIORITY: String = "priority"
let PROP_ENDPOINT_CONTENT_PROTECTION: String = "contentProtection"
let PROP_REASON_ERROR_CODE: String = "errorCode"
let PROP_REASON_ERROR_MESSAGE: String = "errorMessage"
let PROP_DISTRIBUTION_ID: String = "id"
let PROP_DISTRIBUTION_NAME: String = "name"

class THEOplayerRCTTHEOliveEventAdapter {

Expand Down Expand Up @@ -61,6 +63,20 @@ class THEOplayerRCTTHEOliveEventAdapter {
PROP_REASON_ERROR_MESSAGE: reason.message
]
}

class func fromDistribution(distribution: (any THEOplayerTHEOliveIntegration.DistributionAPI)?) -> [String:Any] {
guard let distribution = distribution else {
return [:]
}

var distributionData: [String:Any] = [:]
distributionData[PROP_DISTRIBUTION_ID] = distribution.id
distributionData[PROP_DISTRIBUTION_NAME] = distribution.name

return distributionData
}


#endif

}
31 changes: 28 additions & 3 deletions ios/theolive/THEOplayerRCTTHEOliveEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import THEOplayerTHEOliveIntegration
#endif

let EVENT_TYPE_DISTRIBUTION_LOAD_START: String = "distributionloadstart"
let EVENT_TYPE_DISTRIBUTION_LOADED: String = "distributionloaded"
let EVENT_TYPE_DISTRIBUTION_OFFLINE: String = "distributionoffline"
let EVENT_TYPE_ENDPOINT_LOADED: String = "endpointloaded"
let EVENT_TYPE_INTENT_TO_FALLBACK: String = "intenttofallback"

let THEOLIVE_EVENT_PROP_TYPE: String = "type"
let THEOLIVE_EVENT_PROP_DISTRIBUTION_ID: String = "distributionId"
let THEOLIVE_EVENT_PROP_DISTRIBUTION: String = "distribution"
let THEOLIVE_EVENT_PROP_ENDPOINT: String = "endpoint"
let THEOLIVE_EVENT_PROP_REASON: String = "reason"

Expand All @@ -26,6 +28,7 @@ class THEOplayerRCTTHEOliveEventHandler {

// MARK: THEOlive Listeners
private var distributionLoadStartListener: EventListener?
private var distributionLoadedListener: EventListener?
private var distributionOfflineListener: EventListener?
private var endPointLoadedListener: EventListener?
private var intentToFallbackListener: EventListener?
Expand Down Expand Up @@ -62,8 +65,21 @@ class THEOplayerRCTTHEOliveEventHandler {
}
}
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] DistributionLoadStart listener attached to THEOplayer.theolive") }




// DISTRIBUTION_LOADED
self.distributionLoadedListener = player.theoLive?.addEventListener(type: THEOliveEventTypes.DISTRIBUTION_LOADED) { [weak self] event in
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received DistributionLoaded event from THEOlive") }
if let forwardedTHEOliveEvent = self?.onNativeTHEOliveEvent {
forwardedTHEOliveEvent([
THEOLIVE_EVENT_PROP_TYPE: EVENT_TYPE_DISTRIBUTION_LOADED,
THEOLIVE_EVENT_PROP_DISTRIBUTION: THEOplayerRCTTHEOliveEventAdapter.fromDistribution(distribution: event.distribution)
])
}
}
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] DistributionOffline listener attached to THEOplayer.theolive") }


// DISTRIBUTION_OFFLINE
self.distributionOfflineListener = player.theoLive?.addEventListener(type: THEOliveEventTypes.DISTRIBUTION_OFFLINE) { [weak self] event in
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received DistributionOffline event from THEOlive") }
Expand Down Expand Up @@ -116,7 +132,16 @@ class THEOplayerRCTTHEOliveEventHandler {
)
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] DistributionLoadStart listener detached from THEOplayer.theolive") }
}


// DISTRIBUTION_LOADED
if let distributionLoadedListener = self.distributionLoadedListener {
player.theoLive?.removeEventListener(
type: THEOliveEventTypes.DISTRIBUTION_LOADED,
listener: distributionLoadedListener
)
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] DistributionLoaded listener detached from THEOplayer.theolive") }
}

// DISTRIBUTION_OFFLINE
if let distributionOfflineListener = self.distributionOfflineListener {
player.theoLive?.removeEventListener(
Expand Down
8 changes: 4 additions & 4 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
Expand Up @@ -70,7 +70,7 @@
"react": "^19.2.0",
"react-native": "^0.83.1",
"react-native-builder-bob": "^0.39.1",
"theoplayer": "^10",
"theoplayer": "^10.10.0",
"typedoc": "^0.25.13",
"typedoc-plugin-external-resolver": "^1.0.3",
"typedoc-plugin-mdn-links": "^3.3.4",
Expand Down
14 changes: 7 additions & 7 deletions react-native-theoplayer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,37 @@ Pod::Spec.new do |s|

# THEOplayer Dependency
puts "Adding THEOplayerSDK-core"
s.dependency "THEOplayerSDK-core", "~> 10.7"
s.dependency "THEOplayerSDK-core", "~> 10.10"

# THEOlive Dependency
puts "Adding THEOplayer-Integration-THEOlive"
s.dependency "THEOplayer-Integration-THEOlive", "~> 10.7"
s.dependency "THEOplayer-Integration-THEOlive", "~> 10.10"

# Feature based integration dependencies
if theofeatures.include?("GOOGLE_IMA")
puts "Adding THEOplayer-Integration-GoogleIMA"
s.dependency "THEOplayer-Integration-GoogleIMA", "~> 10.7"
s.dependency "THEOplayer-Integration-GoogleIMA", "~> 10.10"
end

if theofeatures.include?("CHROMECAST")
puts "Adding THEOplayer-Integration-GoogleCast"
s.ios.dependency "THEOplayer-Integration-GoogleCast", "~> 10.7"
s.ios.dependency "THEOplayer-Integration-GoogleCast", "~> 10.10"
end

if theofeatures.include?("THEO_ADS")
puts "Adding THEOplayer-Integration-THEOads"
s.dependency "THEOplayer-Integration-THEOads", "~> 10.7"
s.dependency "THEOplayer-Integration-THEOads", "~> 10.10"
end

if theofeatures.include?("MILLICAST")
puts "Adding THEOplayer-Integration-Millicast"
s.dependency "THEOplayer-Integration-Millicast", "~> 10.7"
s.dependency "THEOplayer-Integration-Millicast", "~> 10.10"
end

# Feature based connector dependencies
if theofeatures.include?("SIDELOADED_TEXTTRACKS")
puts "Adding THEOplayer-Connector-SideloadedSubtitle"
s.dependency "THEOplayer-Connector-SideloadedSubtitle", "~> 10.7"
s.dependency "THEOplayer-Connector-SideloadedSubtitle", "~> 10.10"
end

end
20 changes: 20 additions & 0 deletions src/api/event/TheoLiveEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Event, PlayerError, PlayerEventType, TheoLiveEndpoint } from 'react-native-theoplayer';
import { TheoLiveDistribution } from '../theolive/TheoLiveDistribution';

/**
* The THEOlive event dispatched by the {@link TheoLiveAPI THEOlive API}.
Expand Down Expand Up @@ -26,6 +27,18 @@ export interface TheoLiveDistributionEvent extends TheoLiveEvent {
distributionId: string;
}

/**
* Dispatched when a THEOlive distribution has been successfully loaded.
*
* @public
*/
export interface TheoLiveDistributionLoadedEvent extends TheoLiveEvent {
/**
* The distribution info.
*/
distribution?: TheoLiveDistribution;
}

/**
* Dispatched when the loading of a THEOlive endpoint is complete and playback can start.
* This event is dispatched on every endpoint load, when an error is encountered and the player recovers by choosing
Expand Down Expand Up @@ -67,6 +80,13 @@ export enum TheoLiveEventType {
*/
DISTRIBUTION_LOAD_START = 'distributionloadstart',

/**
* Dispatched when a THEOlive distribution has been successfully loaded.
*
* @public
*/
DISTRIBUTION_LOADED = 'distributionloaded',

/**
* Dispatched when loading a THEOlive distribution that cannot be played, for example because the publication is
* stopped or is still starting up.
Expand Down
10 changes: 10 additions & 0 deletions src/api/theolive/TheoLiveDistribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* A THEOlive distribution.
*
* @category THEOlive
* @public
*/
export interface TheoLiveDistribution {
id: string;
name: string;
}
1 change: 1 addition & 0 deletions src/api/theolive/barrel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './TheoLiveAPI';
export * from './TheoLiveConfiguration';
export * from './TheoLiveEndpoint';
export * from './TheoLiveDistribution';
export * from './TheoLiveSource';
Loading
Loading