react-native-theoplayer 2.5.0 → 2.7.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 +24 -0
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +9 -15
- package/android/src/main/java/com/theoplayer/util/PayloadBuilder.kt +2 -1
- package/android/src/main/java/com/theoplayer/util/ViewResolver.kt +9 -1
- package/ios/THEOplayerRCTDebug.swift +3 -3
- package/ios/THEOplayerRCTMainEventHandler.swift +59 -59
- package/ios/THEOplayerRCTMediaTrackEventHandler.swift +18 -18
- package/ios/THEOplayerRCTNetworkUtils.swift +1 -1
- package/ios/THEOplayerRCTPlayerAPI.swift +14 -14
- package/ios/THEOplayerRCTPrintUtils.swift +16 -0
- package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +6 -6
- package/ios/THEOplayerRCTTextTrackEventHandler.swift +21 -21
- package/ios/THEOplayerRCTView.swift +29 -29
- package/ios/ads/THEOplayerRCTAdsAPI+DAI.swift +6 -6
- package/ios/ads/THEOplayerRCTAdsAPI.swift +13 -13
- package/ios/ads/THEOplayerRCTAdsEventHandler.swift +27 -27
- package/ios/ads/THEOplayerRCTSourceDescriptionBuilder+Ads.swift +5 -5
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +63 -37
- package/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +16 -16
- package/ios/casting/THEOplayerRCTCastAPI+Airplay.swift +6 -6
- package/ios/casting/THEOplayerRCTCastAPI+Chromecast.swift +10 -10
- package/ios/casting/THEOplayerRCTCastAPI.swift +1 -1
- package/ios/casting/THEOplayerRCTCastEventHandler.swift +11 -11
- package/ios/contentprotection/THEOplayerRCTContentProtectionAPI.swift +1 -1
- package/ios/pip/THEOplayerRCTPipControlsManager.swift +1 -1
- package/lib/commonjs/api/abr/ABRConfiguration.js +25 -0
- package/lib/commonjs/api/abr/ABRConfiguration.js.map +1 -1
- package/lib/commonjs/api/track/Track.js +5 -1
- package/lib/commonjs/api/track/Track.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +2 -6
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +41 -10
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +105 -52
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/module/api/abr/ABRConfiguration.js +19 -0
- package/lib/module/api/abr/ABRConfiguration.js.map +1 -1
- package/lib/module/api/track/Track.js +4 -1
- package/lib/module/api/track/Track.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +2 -6
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js +41 -10
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js +106 -53
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/typescript/api/abr/ABRConfiguration.d.ts +5 -1
- package/lib/typescript/api/track/Track.d.ts +1 -0
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +2 -0
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +3 -3
- package/package.json +1 -1
- package/react-native-theoplayer.podspec +1 -1
- package/src/api/abr/ABRConfiguration.ts +5 -1
- package/src/api/track/Track.ts +5 -1
- package/src/internal/THEOplayerView.web.tsx +2 -6
- package/src/internal/adapter/THEOplayerAdapter.ts +44 -10
- package/src/internal/adapter/THEOplayerWebAdapter.ts +97 -50
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ 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.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.7.0] - 23-05-15
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Approved player behaviour on iOS and Android when doing player operations such as `play` and `pause` in case no source was set.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Fixed an issue on Android where if an invalid view tag is passed to the native bridge, it would crash the player.
|
|
17
|
+
|
|
18
|
+
## [2.6.0] - 23-05-05
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Fixed an issue on Android where the `currentProgramDateTime` property of `TimeUpdateEvent` would not be formatted in milliseconds.
|
|
23
|
+
- Fixed an issue on Android where the order of text and media tracks would change when adding tracks.
|
|
24
|
+
- Fixed an issue on Web where an exception would be thrown when accessing the player API after the player had been destroyed.
|
|
25
|
+
- Fixed an issue with Google IMA where the main content wasn't resumed after a pre-roll ended.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Use `enum` instead of a string union for `ABRStrategyType`.
|
|
30
|
+
- Changed the way artwork is fetched for NowPlayingInfo on the iOS Lockscreen, to prevent a crash caused by threading issues.
|
|
31
|
+
|
|
8
32
|
## [2.5.0] - 23-04-26
|
|
9
33
|
|
|
10
34
|
### Added
|
|
@@ -338,7 +338,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
338
338
|
|
|
339
339
|
// Limit update rate.
|
|
340
340
|
val dt = now - lastTimeUpdate
|
|
341
|
-
return timeUpdateRate == TimeUpdateRate.LIMITED_ONE_HZ && dt <
|
|
341
|
+
return timeUpdateRate == TimeUpdateRate.LIMITED_ONE_HZ && dt < 1e3 ||
|
|
342
342
|
timeUpdateRate == TimeUpdateRate.LIMITED_TWO_HZ && dt < 500 ||
|
|
343
343
|
timeUpdateRate == TimeUpdateRate.LIMITED_THREE_HZ && dt < 333
|
|
344
344
|
}
|
|
@@ -481,24 +481,17 @@ class PlayerEventEmitter internal constructor(
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
private fun activeAudioTrack(): MediaTrack<AudioQuality>? {
|
|
484
|
-
return
|
|
485
|
-
playerView.player!!.audioTracks
|
|
486
|
-
) else null
|
|
484
|
+
return activeTrack(playerView.player?.audioTracks)
|
|
487
485
|
}
|
|
488
486
|
|
|
489
487
|
private fun activeVideoTrack(): MediaTrack<VideoQuality>? {
|
|
490
|
-
return
|
|
491
|
-
playerView.player!!.videoTracks
|
|
492
|
-
) else null
|
|
488
|
+
return activeTrack(playerView.player?.videoTracks)
|
|
493
489
|
}
|
|
494
490
|
|
|
495
491
|
private fun <T : Quality?> activeTrack(tracks: MediaTrackList<T>?): MediaTrack<T>? {
|
|
496
|
-
tracks?.
|
|
497
|
-
|
|
498
|
-
return track
|
|
499
|
-
}
|
|
492
|
+
return tracks?.first { track ->
|
|
493
|
+
track.isEnabled
|
|
500
494
|
}
|
|
501
|
-
return null
|
|
502
495
|
}
|
|
503
496
|
|
|
504
497
|
private val onActiveQualityChanged = EventListener<QualityChangedEvent<*, *>> { event ->
|
|
@@ -642,13 +635,14 @@ class PlayerEventEmitter internal constructor(
|
|
|
642
635
|
}
|
|
643
636
|
})
|
|
644
637
|
}
|
|
645
|
-
if (BuildConfig.EXTENSION_CAST
|
|
646
|
-
castEventAdapter =
|
|
647
|
-
object : CastEventAdapter.Emitter {
|
|
638
|
+
if (BuildConfig.EXTENSION_CAST) {
|
|
639
|
+
castEventAdapter = playerView.castApi?.let {
|
|
640
|
+
CastEventAdapter(it, object : CastEventAdapter.Emitter {
|
|
648
641
|
override fun emit(payload: WritableMap?) {
|
|
649
642
|
receiveEvent(EVENT_CAST_EVENT, payload)
|
|
650
643
|
}
|
|
651
644
|
})
|
|
645
|
+
}
|
|
652
646
|
}
|
|
653
647
|
}
|
|
654
648
|
|
|
@@ -74,7 +74,8 @@ class PayloadBuilder {
|
|
|
74
74
|
currentProgramDateTime?.let {
|
|
75
75
|
payload.putDouble(
|
|
76
76
|
EVENT_PROP_CURRENT_PROGRAM_DATE_TIME,
|
|
77
|
-
|
|
77
|
+
// Date.time is already formatted in msecs.
|
|
78
|
+
currentProgramDateTime.time.toDouble()
|
|
78
79
|
)
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
package com.theoplayer.util
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
5
|
import com.facebook.react.uimanager.UIManagerModule
|
|
5
6
|
import com.theoplayer.ReactTHEOplayerView
|
|
6
7
|
|
|
8
|
+
private const val TAG = "ViewResolver"
|
|
9
|
+
|
|
7
10
|
class ViewResolver(private val reactContext: ReactApplicationContext) {
|
|
8
11
|
private var uiManager: UIManagerModule? = null
|
|
9
12
|
|
|
@@ -12,7 +15,12 @@ class ViewResolver(private val reactContext: ReactApplicationContext) {
|
|
|
12
15
|
uiManager = reactContext.getNativeModule(UIManagerModule::class.java)
|
|
13
16
|
}
|
|
14
17
|
uiManager?.addUIBlock {
|
|
15
|
-
|
|
18
|
+
try {
|
|
19
|
+
onResolved(it.resolveView(tag) as ReactTHEOplayerView)
|
|
20
|
+
} catch (ignore: Exception) {
|
|
21
|
+
// The ReactTHEOplayerView instance could not be resolved: log but do not forward exception.
|
|
22
|
+
Log.w(TAG, "Failed to resolve ReactTHEOplayerView tag $tag")
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
}
|
|
18
26
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// THEOplayerRCTDebug.swift
|
|
2
2
|
|
|
3
3
|
// General debug flag, if set to false none of the debug prints will appear
|
|
4
|
-
let DEBUG =
|
|
4
|
+
let DEBUG = true
|
|
5
5
|
|
|
6
6
|
// Debug flag to monitor incoming Theoplayer events
|
|
7
|
-
let DEBUG_THEOPLAYER_EVENTS = DEBUG &&
|
|
7
|
+
let DEBUG_THEOPLAYER_EVENTS = DEBUG && true
|
|
8
8
|
|
|
9
9
|
// Debug flag to monitor eventhandler setup and breakdown
|
|
10
10
|
let DEBUG_EVENTHANDLER = DEBUG && false
|
|
11
11
|
|
|
12
12
|
// Debug flag to monitor the interactions for each view with its underlying theoplayer instance
|
|
13
|
-
let DEBUG_THEOPLAYER_INTERACTION = DEBUG &&
|
|
13
|
+
let DEBUG_THEOPLAYER_INTERACTION = DEBUG && true
|
|
14
14
|
|
|
15
15
|
// Debug flag to monitor contentProtection integration handling
|
|
16
16
|
let DEBUG_CONTENT_PROTECTION_API = DEBUG && false
|
|
@@ -75,52 +75,52 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
75
75
|
|
|
76
76
|
// PLAY
|
|
77
77
|
self.playListener = player.addEventListener(type: PlayerEventTypes.PLAY) { [weak self] event in
|
|
78
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
78
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received PLAY event from THEOplayer") }
|
|
79
79
|
if let forwardedPlayEvent = self?.onNativePlay {
|
|
80
80
|
forwardedPlayEvent([:])
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
if DEBUG_EVENTHANDLER {
|
|
83
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Play listener attached to THEOplayer") }
|
|
84
84
|
|
|
85
85
|
// PAUSE
|
|
86
86
|
self.pauseListener = player.addEventListener(type: PlayerEventTypes.PAUSE) { [weak self] event in
|
|
87
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
87
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received PAUSE event from THEOplayer") }
|
|
88
88
|
if let forwardedPauseEvent = self?.onNativePause {
|
|
89
89
|
forwardedPauseEvent([:])
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
if DEBUG_EVENTHANDLER {
|
|
92
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Pause listener attached to THEOplayer") }
|
|
93
93
|
|
|
94
94
|
// SOURCE_CHANGE
|
|
95
95
|
self.sourceChangeListener = player.addEventListener(type: PlayerEventTypes.SOURCE_CHANGE) { [weak self] event in
|
|
96
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
96
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received SOURCE_CHANGE event from THEOplayer") }
|
|
97
97
|
if let forwardedSourceChangeEvent = self?.onNativeSourceChange {
|
|
98
98
|
forwardedSourceChangeEvent([:])
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
if DEBUG_EVENTHANDLER {
|
|
101
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] SourceChange listener attached to THEOplayer") }
|
|
102
102
|
|
|
103
103
|
// LOAD_START
|
|
104
104
|
self.loadStartListener = player.addEventListener(type: PlayerEventTypes.LOAD_START) { [weak self] event in
|
|
105
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
105
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received LOAD_START event from THEOplayer") }
|
|
106
106
|
if let forwardedLoadStartEvent = self?.onNativeLoadStart {
|
|
107
107
|
forwardedLoadStartEvent([:])
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
if DEBUG_EVENTHANDLER {
|
|
110
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] LoadStart listener attached to THEOplayer") }
|
|
111
111
|
|
|
112
112
|
// READY_STATE_CHANGE
|
|
113
113
|
self.readyStateChangeListener = player.addEventListener(type: PlayerEventTypes.READY_STATE_CHANGE) { [weak self] event in
|
|
114
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
114
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received READY_STATE_CHANGE event from THEOplayer") }
|
|
115
115
|
if let forwardedReadyStateChangeEvent = self?.onNativeReadyStateChange {
|
|
116
116
|
forwardedReadyStateChangeEvent(["readyState": event.readyState.rawValue - 1]) // [1-5] (iOS only) => [0-4] (other platforms + RN)
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
if DEBUG_EVENTHANDLER {
|
|
119
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] ReadyStateChange listener attached to THEOplayer") }
|
|
120
120
|
|
|
121
121
|
// DURATION_CHANGE
|
|
122
122
|
self.durationChangeListener = player.addEventListener(type: PlayerEventTypes.DURATION_CHANGE) { [weak self] event in
|
|
123
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
123
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received DURATION_CHANGE event from THEOplayer") }
|
|
124
124
|
if let forwardedDurationChangeEvent = self?.onNativeDurationChange {
|
|
125
125
|
forwardedDurationChangeEvent(
|
|
126
126
|
[
|
|
@@ -129,11 +129,11 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
129
129
|
)
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
if DEBUG_EVENTHANDLER {
|
|
132
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] DurationChange listener attached to THEOplayer") }
|
|
133
133
|
|
|
134
134
|
// VOLUME_CHANGE
|
|
135
135
|
self.volumeChangeListener = player.addEventListener(type: PlayerEventTypes.VOLUME_CHANGE) { [weak self, weak player] event in
|
|
136
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
136
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received VOLUME_CHANGE event from THEOplayer") }
|
|
137
137
|
if let wplayer = player,
|
|
138
138
|
let forwardedVolumeChangeEvent = self?.onNativeVolumeChange {
|
|
139
139
|
forwardedVolumeChangeEvent(
|
|
@@ -144,11 +144,11 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
144
144
|
)
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
if DEBUG_EVENTHANDLER {
|
|
147
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] VolumeChange listener attached to THEOplayer") }
|
|
148
148
|
|
|
149
149
|
// PROGRESS
|
|
150
150
|
self.progressListener = player.addEventListener(type: PlayerEventTypes.PROGRESS) { [weak self, weak player] event in
|
|
151
|
-
//if DEBUG_THEOPLAYER_EVENTS {
|
|
151
|
+
//if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received PROGRESS event from THEOplayer") }
|
|
152
152
|
if let wplayer = player,
|
|
153
153
|
let forwardedProgressEvent = self?.onNativeProgress {
|
|
154
154
|
wplayer.requestSeekable(completionHandler: { seekableTimeRanges, error in
|
|
@@ -181,11 +181,11 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
if DEBUG_EVENTHANDLER {
|
|
184
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Progress listener attached to THEOplayer") }
|
|
185
185
|
|
|
186
186
|
// TIME_UPDATE
|
|
187
187
|
self.timeUpdateListener = player.addEventListener(type: PlayerEventTypes.TIME_UPDATE) { [weak self] event in
|
|
188
|
-
//if DEBUG_THEOPLAYER_EVENTS {
|
|
188
|
+
//if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received TIME_UPDATE event from THEOplayer") }
|
|
189
189
|
if let forwardedTimeUpdateEvent = self?.onNativeTimeUpdate {
|
|
190
190
|
let currentTime = event.currentTime * 1000 // sec -> msec
|
|
191
191
|
let currentProgramDateTime = (event.currentProgramDateTime?.timeIntervalSince1970 ?? 0.0) * 1000 // sec -> msec
|
|
@@ -197,47 +197,47 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
197
197
|
)
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
if DEBUG_EVENTHANDLER {
|
|
200
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] TimeUpdate listener attached to THEOplayer") }
|
|
201
201
|
|
|
202
202
|
// PLAYING
|
|
203
203
|
self.playingListener = player.addEventListener(type: PlayerEventTypes.PLAYING) { [weak self] event in
|
|
204
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
204
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received PLAYING event from THEOplayer") }
|
|
205
205
|
if let forwardedPlayingEvent = self?.onNativePlaying {
|
|
206
206
|
forwardedPlayingEvent([:])
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
if DEBUG_EVENTHANDLER {
|
|
209
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Playing listener attached to THEOplayer") }
|
|
210
210
|
|
|
211
211
|
// SEEKING
|
|
212
212
|
self.seekingListener = player.addEventListener(type: PlayerEventTypes.SEEKING) { [weak self] event in
|
|
213
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
213
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received SEEKING event from THEOplayer") }
|
|
214
214
|
if let forwardedSeekingEvent = self?.onNativeSeeking {
|
|
215
215
|
forwardedSeekingEvent([:])
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
if DEBUG_EVENTHANDLER {
|
|
218
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Seeking listener attached to THEOplayer") }
|
|
219
219
|
|
|
220
220
|
// SEEKED
|
|
221
221
|
self.timeUpdateListener = player.addEventListener(type: PlayerEventTypes.SEEKED) { [weak self] event in
|
|
222
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
222
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received SEEKED event from THEOplayer") }
|
|
223
223
|
if let forwardedSeekedEvent = self?.onNativeSeeked {
|
|
224
224
|
forwardedSeekedEvent([:])
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
if DEBUG_EVENTHANDLER {
|
|
227
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Seeked listener attached to THEOplayer") }
|
|
228
228
|
|
|
229
229
|
// ENDED
|
|
230
230
|
self.endedListener = player.addEventListener(type: PlayerEventTypes.ENDED) { [weak self] event in
|
|
231
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
231
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received ENDED event from THEOplayer") }
|
|
232
232
|
if let forwardedEndedEvent = self?.onNativeEnded {
|
|
233
233
|
forwardedEndedEvent([:])
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
if DEBUG_EVENTHANDLER {
|
|
236
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Ended listener attached to THEOplayer") }
|
|
237
237
|
|
|
238
238
|
// ERROR
|
|
239
239
|
self.errorListener = player.addEventListener(type: PlayerEventTypes.ERROR) { [weak self] event in
|
|
240
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
240
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received ERROR event from THEOplayer") }
|
|
241
241
|
if let forwardedErrorEvent = self?.onNativeError,
|
|
242
242
|
let errorObject = event.errorObject
|
|
243
243
|
{
|
|
@@ -253,20 +253,20 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
253
253
|
)
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
if DEBUG_EVENTHANDLER {
|
|
256
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Error listener attached to THEOplayer") }
|
|
257
257
|
|
|
258
258
|
// LOADED_DATA
|
|
259
259
|
self.loadedDataListener = player.addEventListener(type: PlayerEventTypes.LOADED_DATA) { [weak self] event in
|
|
260
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
260
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received LOADED_DATA event from THEOplayer") }
|
|
261
261
|
if let forwardedLoadedDataEvent = self?.onNativeLoadedData {
|
|
262
262
|
forwardedLoadedDataEvent([:])
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
if DEBUG_EVENTHANDLER {
|
|
265
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] LoadedData listener attached to THEOplayer") }
|
|
266
266
|
|
|
267
267
|
// LOADED_META_DATA
|
|
268
268
|
self.loadedMetadataListener = player.addEventListener(type: PlayerEventTypes.LOADED_META_DATA) { [weak self, weak player] event in
|
|
269
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
269
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received LOADED_META_DATA event from THEOplayer") }
|
|
270
270
|
if let wplayer = player,
|
|
271
271
|
let forwardedLoadedMetadataEvent = self?.onNativeLoadedMetadata {
|
|
272
272
|
let metadata = THEOplayerRCTTrackMetadataAggregator.aggregateTrackMetadata(player: wplayer)
|
|
@@ -274,44 +274,44 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
274
274
|
forwardedLoadedMetadataEvent(metadata)
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
if DEBUG_EVENTHANDLER {
|
|
277
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] LoadedMetadata listener attached to THEOplayer") }
|
|
278
278
|
|
|
279
279
|
// RATE_CHANGE
|
|
280
280
|
self.rateChangeListener = player.addEventListener(type: PlayerEventTypes.RATE_CHANGE) { [weak self] event in
|
|
281
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
281
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received RATE_CHANGE event from THEOplayer") }
|
|
282
282
|
if let forwardedRateChangeEvent = self?.onNativeRateChange {
|
|
283
283
|
forwardedRateChangeEvent(["playbackRate": event.playbackRate])
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
if DEBUG_EVENTHANDLER {
|
|
286
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] RateChange listener attached to THEOplayer") }
|
|
287
287
|
|
|
288
288
|
// WAITING
|
|
289
289
|
self.waitingListener = player.addEventListener(type: PlayerEventTypes.WAITING) { [weak self] event in
|
|
290
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
290
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received WAITING event from THEOplayer") }
|
|
291
291
|
if let forwardedWaitingEvent = self?.onNativeWaiting {
|
|
292
292
|
forwardedWaitingEvent([:])
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
if DEBUG_EVENTHANDLER {
|
|
295
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Waiting listener attached to THEOplayer") }
|
|
296
296
|
|
|
297
297
|
// CAN_PLAY
|
|
298
298
|
self.canPlayListener = player.addEventListener(type: PlayerEventTypes.CAN_PLAY) { [weak self] event in
|
|
299
|
-
if DEBUG_THEOPLAYER_EVENTS {
|
|
299
|
+
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received CAN_PLAY event from THEOplayer") }
|
|
300
300
|
if let forwardedCanPlayEvent = self?.onNativeCanPlay {
|
|
301
301
|
forwardedCanPlayEvent([:])
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
if DEBUG_EVENTHANDLER {
|
|
304
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Waiting listener attached to THEOplayer") }
|
|
305
305
|
|
|
306
306
|
// PRESENTATION_MODE_CHANGE
|
|
307
307
|
self.presentationModeChangeListener = player.addEventListener(type: PlayerEventTypes.PRESENTATION_MODE_CHANGE) { [weak self] event in
|
|
308
|
-
if DEBUG_THEOPLAYER_EVENTS || true {
|
|
308
|
+
if DEBUG_THEOPLAYER_EVENTS || true { PrintUtils.printLog(logText: "[NATIVE] Received PRESENTATION_MODE_CHANGE event from THEOplayer (to \(event.presentationMode._rawValue))") }
|
|
309
309
|
if let forwardedPresentationModeChangeEvent = self?.onNativePresentationModeChange,
|
|
310
310
|
let presentationModeContext = self?.presentationModeContext {
|
|
311
311
|
forwardedPresentationModeChangeEvent(presentationModeContext.eventContextForNewPresentationMode(event.presentationMode))
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
if DEBUG_EVENTHANDLER {
|
|
314
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] PresentationModeChange listener attached to THEOplayer") }
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
private func dettachListeners() {
|
|
@@ -322,115 +322,115 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
322
322
|
// PLAY
|
|
323
323
|
if let playListener = self.playListener {
|
|
324
324
|
player.removeEventListener(type: PlayerEventTypes.PLAY, listener: playListener)
|
|
325
|
-
if DEBUG_EVENTHANDLER {
|
|
325
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Play listener dettached from THEOplayer") }
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
// PAUSE
|
|
329
329
|
if let pauseListener = self.pauseListener {
|
|
330
330
|
player.removeEventListener(type: PlayerEventTypes.PAUSE, listener: pauseListener)
|
|
331
|
-
if DEBUG_EVENTHANDLER {
|
|
331
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Pause listener dettached from THEOplayer") }
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
// SOURCE_CHANGE
|
|
335
335
|
if let sourceChangeListener = self.sourceChangeListener {
|
|
336
336
|
player.removeEventListener(type: PlayerEventTypes.SOURCE_CHANGE, listener: sourceChangeListener)
|
|
337
|
-
if DEBUG_EVENTHANDLER {
|
|
337
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] SourceChange listener dettached from THEOplayer") }
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
// LOAD_START
|
|
341
341
|
if let loadStartListener = self.loadStartListener {
|
|
342
342
|
player.removeEventListener(type: PlayerEventTypes.LOAD_START, listener: loadStartListener)
|
|
343
|
-
if DEBUG_EVENTHANDLER {
|
|
343
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] LoadStart listener dettached from THEOplayer") }
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
// READY_STATE_CHANGE
|
|
347
347
|
if let readyStateChangeListener = self.readyStateChangeListener {
|
|
348
348
|
player.removeEventListener(type: PlayerEventTypes.READY_STATE_CHANGE, listener: readyStateChangeListener)
|
|
349
|
-
if DEBUG_EVENTHANDLER {
|
|
349
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] ReadyStateChange listener dettached from THEOplayer") }
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
// DURATION_CHANGE
|
|
353
353
|
if let durationChangeListener = self.durationChangeListener {
|
|
354
354
|
player.removeEventListener(type: PlayerEventTypes.DURATION_CHANGE, listener: durationChangeListener)
|
|
355
|
-
if DEBUG_EVENTHANDLER {
|
|
355
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] DurationChange listener dettached from THEOplayer") }
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// PROGRESS
|
|
359
359
|
if let progressListener = self.progressListener {
|
|
360
360
|
player.removeEventListener(type: PlayerEventTypes.PROGRESS, listener: progressListener)
|
|
361
|
-
if DEBUG_EVENTHANDLER {
|
|
361
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Progress listener dettached from THEOplayer") }
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
// TIME_UPDATE
|
|
365
365
|
if let timeUpdateListener = self.timeUpdateListener {
|
|
366
366
|
player.removeEventListener(type: PlayerEventTypes.TIME_UPDATE, listener: timeUpdateListener)
|
|
367
|
-
if DEBUG_EVENTHANDLER {
|
|
367
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] TimeUpdate listener dettached from THEOplayer") }
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
// PLAYING
|
|
371
371
|
if let playingListener = self.playingListener {
|
|
372
372
|
player.removeEventListener(type: PlayerEventTypes.PLAYING, listener: playingListener)
|
|
373
|
-
if DEBUG_EVENTHANDLER {
|
|
373
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Playing listener dettached from THEOplayer") }
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
// SEEKING
|
|
377
377
|
if let seekingListener = self.seekingListener {
|
|
378
378
|
player.removeEventListener(type: PlayerEventTypes.SEEKING, listener: seekingListener)
|
|
379
|
-
if DEBUG_EVENTHANDLER {
|
|
379
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Seeking listener dettached from THEOplayer") }
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
// SEEKED
|
|
383
383
|
if let seekedListener = self.seekedListener {
|
|
384
384
|
player.removeEventListener(type: PlayerEventTypes.SEEKED, listener: seekedListener)
|
|
385
|
-
if DEBUG_EVENTHANDLER {
|
|
385
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Seeked listener dettached from THEOplayer") }
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
// ENDED
|
|
389
389
|
if let endedListener = self.endedListener {
|
|
390
390
|
player.removeEventListener(type: PlayerEventTypes.ENDED, listener: endedListener)
|
|
391
|
-
if DEBUG_EVENTHANDLER {
|
|
391
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Ended listener dettached from THEOplayer") }
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
// ERROR
|
|
395
395
|
if let errorListener = self.errorListener {
|
|
396
396
|
player.removeEventListener(type: PlayerEventTypes.ERROR, listener: errorListener)
|
|
397
|
-
if DEBUG_EVENTHANDLER {
|
|
397
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Error listener dettached from THEOplayer") }
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
// LOADED_DATA
|
|
401
401
|
if let loadedDataListener = self.loadedDataListener {
|
|
402
402
|
player.removeEventListener(type: PlayerEventTypes.LOADED_DATA, listener: loadedDataListener)
|
|
403
|
-
if DEBUG_EVENTHANDLER {
|
|
403
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] LoadedData listener dettached from THEOplayer") }
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
// LOADED_META_DATA
|
|
407
407
|
if let loadedMetadataListener = self.loadedMetadataListener {
|
|
408
408
|
player.removeEventListener(type: PlayerEventTypes.LOADED_META_DATA, listener: loadedMetadataListener)
|
|
409
|
-
if DEBUG_EVENTHANDLER {
|
|
409
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] LoadedMetadata listener dettached from THEOplayer") }
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
// RATE_CHANGE
|
|
413
413
|
if let rateChangeListener = self.rateChangeListener {
|
|
414
414
|
player.removeEventListener(type: PlayerEventTypes.RATE_CHANGE, listener: rateChangeListener)
|
|
415
|
-
if DEBUG_EVENTHANDLER {
|
|
415
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] RateChange listener dettached from THEOplayer") }
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
// WAITING
|
|
419
419
|
if let waitingListener = self.waitingListener {
|
|
420
420
|
player.removeEventListener(type: PlayerEventTypes.WAITING, listener: waitingListener)
|
|
421
|
-
if DEBUG_EVENTHANDLER {
|
|
421
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Waiting listener dettached from THEOplayer") }
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
// CAN_PLAY
|
|
425
425
|
if let canPlayListener = self.canPlayListener {
|
|
426
426
|
player.removeEventListener(type: PlayerEventTypes.CAN_PLAY, listener: canPlayListener)
|
|
427
|
-
if DEBUG_EVENTHANDLER {
|
|
427
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] CanPlay listener dettached from THEOplayer") }
|
|
428
428
|
}
|
|
429
429
|
|
|
430
430
|
// PRESENTATION_MODE_CHANGE
|
|
431
431
|
if let presentationModeChangeListener = self.presentationModeChangeListener {
|
|
432
432
|
player.removeEventListener(type: PlayerEventTypes.PRESENTATION_MODE_CHANGE, listener: presentationModeChangeListener)
|
|
433
|
-
if DEBUG_EVENTHANDLER {
|
|
433
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] PresentationModeChange listener dettached from THEOplayer") }
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
}
|