react-native-theoplayer 2.5.0 → 2.6.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 +14 -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/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +49 -24
- 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/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/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/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/THEOplayerWebAdapter.ts +97 -50
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ 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.6.0] - 23-05-05
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Fixed an issue on Android where the `currentProgramDateTime` property of `TimeUpdateEvent` would not be formatted in milliseconds.
|
|
13
|
+
- Fixed an issue on Android where the order of text and media tracks would change when adding tracks.
|
|
14
|
+
- Fixed an issue on Web where an exception would be thrown when accessing the player API after the player had been destroyed.
|
|
15
|
+
- Fixed an issue with Google IMA where the main content wasn't resumed after a pre-roll ended.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Use `enum` instead of a string union for `ABRStrategyType`.
|
|
20
|
+
- Changed the way artwork is fetched for NowPlayingInfo on the iOS Lockscreen, to prevent a crash caused by threading issues.
|
|
21
|
+
|
|
8
22
|
## [2.5.0] - 23-04-26
|
|
9
23
|
|
|
10
24
|
### 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,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// THEOplayerRCTNowPlayingManager.swift
|
|
2
2
|
|
|
3
3
|
import Foundation
|
|
4
4
|
import THEOplayerSDK
|
|
@@ -41,32 +41,47 @@ class THEOplayerRCTNowPlayingManager {
|
|
|
41
41
|
let sourceDescription = player.source,
|
|
42
42
|
let metadata = sourceDescription.metadata {
|
|
43
43
|
let artWorkUrlString = self.getArtWorkUrlStringFromSourceDescription(sourceDescription)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
self
|
|
55
|
-
|
|
56
|
-
if let welf = self {
|
|
57
|
-
MPNowPlayingInfoCenter.default().nowPlayingInfo = welf.nowPlayingInfo
|
|
58
|
-
if DEBUG_NOWINFO { print("[NATIVE] NowPlayingInfoCenter Updated.") }
|
|
59
|
-
}
|
|
44
|
+
self.updatePlaybackState()
|
|
45
|
+
self.nowPlayingInfo = [String : Any]()
|
|
46
|
+
self.updateTitle(metadata.title)
|
|
47
|
+
self.updateSubtitle(metadata.metadataKeys?["subtitle"] as? String)
|
|
48
|
+
self.updateDuration(player.duration)
|
|
49
|
+
self.updateMediaType() // video
|
|
50
|
+
self.updatePlaybackRate(player.playbackRate)
|
|
51
|
+
self.updateServiceIdentifier(metadata.metadataKeys?["nowPlayingServiceIdentifier"] as? String)
|
|
52
|
+
self.updateContentIdentifier(metadata.metadataKeys?["nowPlayingContentIdentifier"] as? String)
|
|
53
|
+
self.updateArtWork(artWorkUrlString) { [weak self] in
|
|
54
|
+
self?.updateCurrentTime { [weak self] in
|
|
55
|
+
self?.processNowPlayingToInfoCenter()
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
|
|
61
|
+
private func processNowPlayingToInfoCenter() {
|
|
62
|
+
DispatchQueue.main.async {
|
|
63
|
+
MPNowPlayingInfoCenter.default().nowPlayingInfo = self.nowPlayingInfo
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private func clearNowPlayingOnInfoCenter() {
|
|
68
|
+
DispatchQueue.main.async {
|
|
69
|
+
MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private func processPlaybackStateToInfoCenter(paused: Bool) {
|
|
74
|
+
if #available(iOS 13.0, tvOS 13.0, *) {
|
|
75
|
+
DispatchQueue.main.async {
|
|
76
|
+
MPNowPlayingInfoCenter.default().playbackState = paused ? MPNowPlayingPlaybackState.paused : MPNowPlayingPlaybackState.playing
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
65
81
|
private func getArtWorkUrlStringFromSourceDescription(_ sourceDescription: SourceDescription) -> String? {
|
|
66
82
|
if let posterUrlString = sourceDescription.poster?.absoluteString {
|
|
67
83
|
return posterUrlString
|
|
68
84
|
}
|
|
69
|
-
|
|
70
85
|
if let metadata = sourceDescription.metadata,
|
|
71
86
|
let displayIconUrlString = metadata.metadataKeys?["displayIconUri"] as? String {
|
|
72
87
|
return displayIconUrlString
|
|
@@ -120,14 +135,24 @@ class THEOplayerRCTNowPlayingManager {
|
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
|
|
123
|
-
private func updateArtWork(_ urlString: String?) {
|
|
138
|
+
private func updateArtWork(_ urlString: String?, completion: (() -> Void)?) {
|
|
124
139
|
if let artUrlString = urlString,
|
|
125
|
-
let artUrl = URL(string: artUrlString)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
let artUrl = URL(string: artUrlString) {
|
|
141
|
+
let dataTask = URLSession.shared.dataTask(with: artUrl) { [weak self] (data, _, _) in
|
|
142
|
+
if let displayIconData = data,
|
|
143
|
+
let displayIcon = UIImage(data: displayIconData) {
|
|
144
|
+
self?.nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: displayIcon.size) { size in
|
|
145
|
+
return displayIcon
|
|
146
|
+
}
|
|
147
|
+
if DEBUG_NOWINFO { print("[NATIVE] Artwork updated in nowPlayingInfo.") }
|
|
148
|
+
} else {
|
|
149
|
+
if DEBUG_NOWINFO { print("[NATIVE] Failed to update artwork in nowPlayingInfo.") }
|
|
150
|
+
}
|
|
151
|
+
completion?()
|
|
130
152
|
}
|
|
153
|
+
dataTask.resume()
|
|
154
|
+
} else {
|
|
155
|
+
completion?()
|
|
131
156
|
}
|
|
132
157
|
}
|
|
133
158
|
|
|
@@ -1,2 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ABRStrategyType = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The adaptive bitrate strategy of the first segment, represented by a value from the following list:
|
|
9
|
+
* <br/> - `'performance'`: The player will optimize ABR behavior to focus on the performance of the player. This strategy initiates playback with the lowest quality suitable for the device which means faster start-up time.
|
|
10
|
+
* <br/> - `'quality'`: The player will optimize ABR behavior to focus displaying the best visual quality to the end-user. This strategy initiates playback with the highest bit rate suitable for the device.
|
|
11
|
+
* <br/> - `'bandwidth'`: The player will optimize the ABR behavior to focus on displaying the most optimal quality based on historic data of available bandwidth and knowledge of the network conditions.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
let ABRStrategyType;
|
|
16
|
+
/**
|
|
17
|
+
* Describes the metadata of the adaptive bitrate strategy.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
exports.ABRStrategyType = ABRStrategyType;
|
|
22
|
+
(function (ABRStrategyType) {
|
|
23
|
+
ABRStrategyType["performance"] = "performance";
|
|
24
|
+
ABRStrategyType["quality"] = "quality";
|
|
25
|
+
ABRStrategyType["bandwidth"] = "bandwidth";
|
|
26
|
+
})(ABRStrategyType || (exports.ABRStrategyType = ABRStrategyType = {}));
|
|
2
27
|
//# sourceMappingURL=ABRConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["ABRConfiguration.ts"],"sourcesContent":["/**\n * The adaptive bitrate strategy of the first segment, represented by a value from the following list:\n * <br/> - `'performance'`: The player will optimize ABR behavior to focus on the performance of the player. This strategy initiates playback with the lowest quality suitable for the device which means faster start-up time.\n * <br/> - `'quality'`: The player will optimize ABR behavior to focus displaying the best visual quality to the end-user. This strategy initiates playback with the highest bit rate suitable for the device.\n * <br/> - `'bandwidth'`: The player will optimize the ABR behavior to focus on displaying the most optimal quality based on historic data of available bandwidth and knowledge of the network conditions.\n *\n * @public\n */\nexport
|
|
1
|
+
{"version":3,"names":["ABRStrategyType","exports"],"sources":["ABRConfiguration.ts"],"sourcesContent":["/**\n * The adaptive bitrate strategy of the first segment, represented by a value from the following list:\n * <br/> - `'performance'`: The player will optimize ABR behavior to focus on the performance of the player. This strategy initiates playback with the lowest quality suitable for the device which means faster start-up time.\n * <br/> - `'quality'`: The player will optimize ABR behavior to focus displaying the best visual quality to the end-user. This strategy initiates playback with the highest bit rate suitable for the device.\n * <br/> - `'bandwidth'`: The player will optimize the ABR behavior to focus on displaying the most optimal quality based on historic data of available bandwidth and knowledge of the network conditions.\n *\n * @public\n */\nexport enum ABRStrategyType {\n performance = 'performance',\n quality = 'quality',\n bandwidth = 'bandwidth',\n}\n\n/**\n * Describes the metadata of the adaptive bitrate strategy.\n *\n * @public\n */\nexport interface ABRMetadata {\n /**\n * The initial bitrate, in bits per second.\n *\n * @defaultValue Bitrate available to the browser.\n */\n bitrate?: number;\n}\n\n/**\n * Describes the configuration of the adaptive bitrate strategy.\n *\n * @public\n */\nexport interface ABRStrategyConfiguration {\n /**\n * The strategy for initial playback.\n */\n type: ABRStrategyType;\n\n /**\n * The metadata for the initial playback strategy.\n *\n * @defaultValue A {@link ABRMetadata} object with default values.\n */\n metadata?: ABRMetadata;\n}\n\n/**\n * The adaptive bitrate stratey.\n *\n * @public\n */\nexport type ABRStrategy = ABRStrategyConfiguration | ABRStrategyType;\n\n/**\n * Describes the adaptive bitrate configuration.\n *\n * @public\n */\nexport interface ABRConfiguration {\n /**\n * The adaptive bitrate strategy.\n *\n * @defaultValue `'bandwidth'`\n */\n strategy?: ABRStrategy;\n\n /**\n * The amount which the player should buffer ahead of the current playback position, in seconds.\n *\n * @remarks\n * <br/> - Before v4.3.0: This duration has a maximum of 60 seconds.\n * <br/> - After v4.3.0: This duration has no maximum.\n * <br/> - The player might reduce or ignore the configured amount because of device or performance constraints.\n *\n * @defaultValue `20`\n */\n targetBuffer?: number;\n\n /**\n * The amount of data which the player should keep in its buffer before the current playback position, in seconds.\n * This configuration option can be used to reduce the memory footprint on memory restricted devices or on devices\n * which don't automatically prune decoder buffers.\n *\n * Note that the player can decide to keep less data in the decoder buffer in case memory is running low.\n * A value of 0 or lower is not accepted and will be treated as default.\n *\n * @defaultValue `30`\n *\n * @remarks\n * <br/> - This property is currently supported on Web platforms only.\n */\n bufferLookbackWindow?: number;\n\n /**\n * The maximum length of the player's buffer, in seconds.\n *\n * The player will initially buffer up to {@link ABRConfiguration.targetBuffer} seconds of media data.\n * If the player detects that the decoder is unable to hold so much data,\n * it will reduce `maxBufferLength` and restrict `targetBuffer` to be less than\n * this maximum.\n *\n * @remarks\n * <br/> - This property is currently supported on Web platforms only.\n */\n readonly maxBufferLength?: number;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAQYA,eAAe;AAM3B;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAD,eAAA,GAAAA,eAAA;AAAA,WANYA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;AAAA,GAAfA,eAAe,KAAAC,OAAA,CAAAD,eAAA,GAAfA,eAAe"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.addTrack = addTrack;
|
|
7
7
|
exports.hasTrack = hasTrack;
|
|
8
8
|
exports.removeTrack = removeTrack;
|
|
9
|
+
exports.sortTracks = sortTracks;
|
|
9
10
|
/**
|
|
10
11
|
* Represents a track of a media resource.
|
|
11
12
|
*
|
|
@@ -22,6 +23,9 @@ function removeTrack(trackList, track) {
|
|
|
22
23
|
return trackList && track ? trackList.filter(t => t.uid !== track.uid) : trackList;
|
|
23
24
|
}
|
|
24
25
|
function addTrack(trackList, track) {
|
|
25
|
-
return trackList && track && !hasTrack(trackList, track) ? [...trackList, track] : trackList;
|
|
26
|
+
return trackList && track && !hasTrack(trackList, track) ? sortTracks([...trackList, track]) : trackList;
|
|
27
|
+
}
|
|
28
|
+
function sortTracks(trackList) {
|
|
29
|
+
return (trackList === null || trackList === void 0 ? void 0 : trackList.sort((t1, t2) => t1.uid - t2.uid)) || [];
|
|
26
30
|
}
|
|
27
31
|
//# sourceMappingURL=Track.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hasTrack","trackList","track","find","t","uid","removeTrack","filter","addTrack"],"sources":["Track.ts"],"sourcesContent":["/**\n * Represents a track of a media resource.\n *\n * @remarks\n * <br/> - A specific track type (e.g. {@link TextTrack}) will always be used.\n *\n * @public\n */\nexport interface Track {\n /**\n * The kind of the track.\n *\n * @remarks\n * <br/> - The values for this property depend on the specific type of the track.\n */\n readonly kind: string;\n\n /**\n * The label of the track.\n */\n label: string;\n\n /**\n * The identifier of the track.\n *\n * @remarks\n * <br/> - This identifier can be used to distinguish between related tracks, e.g. tracks in the same list.\n *\n * @privateRemarks\n * <br/> - This identifier is a randomly generated string.\n */\n readonly id: string;\n\n /**\n * A unique identifier of the track.\n *\n * @remarks\n * <br/> - This identifier is unique across tracks of a THEOplayer instance and can be used to distinguish between tracks.\n * <br/> - This identifier is a randomly generated number.\n */\n readonly uid: number;\n\n /**\n * The language of the track.\n */\n readonly language: string;\n}\n\nexport function hasTrack<TTrack extends Track>(trackList: TTrack[], track: TTrack): boolean {\n return !!(trackList && track && trackList.find((t) => t.uid === track.uid));\n}\n\nexport function removeTrack<TTrack extends Track>(trackList: TTrack[], track: TTrack): TTrack[] {\n return trackList && track ? trackList.filter((t) => t.uid !== track.uid) : trackList;\n}\n\nexport function addTrack<TTrack extends Track>(trackList: TTrack[], track: TTrack): TTrack[] {\n return trackList && track && !hasTrack(trackList, track) ? [...trackList, track] : trackList;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["hasTrack","trackList","track","find","t","uid","removeTrack","filter","addTrack","sortTracks","sort","t1","t2"],"sources":["Track.ts"],"sourcesContent":["/**\n * Represents a track of a media resource.\n *\n * @remarks\n * <br/> - A specific track type (e.g. {@link TextTrack}) will always be used.\n *\n * @public\n */\nexport interface Track {\n /**\n * The kind of the track.\n *\n * @remarks\n * <br/> - The values for this property depend on the specific type of the track.\n */\n readonly kind: string;\n\n /**\n * The label of the track.\n */\n label: string;\n\n /**\n * The identifier of the track.\n *\n * @remarks\n * <br/> - This identifier can be used to distinguish between related tracks, e.g. tracks in the same list.\n *\n * @privateRemarks\n * <br/> - This identifier is a randomly generated string.\n */\n readonly id: string;\n\n /**\n * A unique identifier of the track.\n *\n * @remarks\n * <br/> - This identifier is unique across tracks of a THEOplayer instance and can be used to distinguish between tracks.\n * <br/> - This identifier is a randomly generated number.\n */\n readonly uid: number;\n\n /**\n * The language of the track.\n */\n readonly language: string;\n}\n\nexport function hasTrack<TTrack extends Track>(trackList: TTrack[], track: TTrack): boolean {\n return !!(trackList && track && trackList.find((t) => t.uid === track.uid));\n}\n\nexport function removeTrack<TTrack extends Track>(trackList: TTrack[], track: TTrack): TTrack[] {\n return trackList && track ? trackList.filter((t) => t.uid !== track.uid) : trackList;\n}\n\nexport function addTrack<TTrack extends Track>(trackList: TTrack[], track: TTrack): TTrack[] {\n return trackList && track && !hasTrack(trackList, track) ? sortTracks([...trackList, track]) : trackList;\n}\n\nexport function sortTracks<TTrack extends Track>(trackList?: TTrack[]): TTrack[] {\n return trackList?.sort((t1: TTrack, t2: TTrack) => t1.uid - t2.uid) || [];\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCO,SAASA,QAAQA,CAAuBC,SAAmB,EAAEC,KAAa,EAAW;EAC1F,OAAO,CAAC,EAAED,SAAS,IAAIC,KAAK,IAAID,SAAS,CAACE,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,GAAG,KAAKH,KAAK,CAACG,GAAG,CAAC,CAAC;AAC7E;AAEO,SAASC,WAAWA,CAAuBL,SAAmB,EAAEC,KAAa,EAAY;EAC9F,OAAOD,SAAS,IAAIC,KAAK,GAAGD,SAAS,CAACM,MAAM,CAAEH,CAAC,IAAKA,CAAC,CAACC,GAAG,KAAKH,KAAK,CAACG,GAAG,CAAC,GAAGJ,SAAS;AACtF;AAEO,SAASO,QAAQA,CAAuBP,SAAmB,EAAEC,KAAa,EAAY;EAC3F,OAAOD,SAAS,IAAIC,KAAK,IAAI,CAACF,QAAQ,CAACC,SAAS,EAAEC,KAAK,CAAC,GAAGO,UAAU,CAAC,CAAC,GAAGR,SAAS,EAAEC,KAAK,CAAC,CAAC,GAAGD,SAAS;AAC1G;AAEO,SAASQ,UAAUA,CAAuBR,SAAoB,EAAY;EAC/E,OAAO,CAAAA,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAES,IAAI,CAAC,CAACC,EAAU,EAAEC,EAAU,KAAKD,EAAE,CAACN,GAAG,GAAGO,EAAE,CAACP,GAAG,CAAC,KAAI,EAAE;AAC3E"}
|
|
@@ -7,8 +7,6 @@ exports.THEOplayerView = THEOplayerView;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var THEOplayer = _interopRequireWildcard(require("theoplayer"));
|
|
9
9
|
var _THEOplayerWebAdapter = require("./adapter/THEOplayerWebAdapter");
|
|
10
|
-
var _BaseEvent = require("./adapter/event/BaseEvent");
|
|
11
|
-
var _reactNativeTheoplayer = require("react-native-theoplayer");
|
|
12
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
12
|
function THEOplayerView(props) {
|
|
@@ -55,7 +53,7 @@ function THEOplayerView(props) {
|
|
|
55
53
|
|
|
56
54
|
// Clean-up
|
|
57
55
|
return () => {
|
|
58
|
-
var _adapter$current
|
|
56
|
+
var _adapter$current;
|
|
59
57
|
// Notify the player will be destroyed.
|
|
60
58
|
const {
|
|
61
59
|
onPlayerDestroy
|
|
@@ -63,9 +61,7 @@ function THEOplayerView(props) {
|
|
|
63
61
|
if (adapter !== null && adapter !== void 0 && adapter.current && onPlayerDestroy) {
|
|
64
62
|
onPlayerDestroy(adapter === null || adapter === void 0 ? void 0 : adapter.current);
|
|
65
63
|
}
|
|
66
|
-
adapter === null || adapter === void 0 ? void 0 : (_adapter$current = adapter.current) === null || _adapter$current === void 0 ? void 0 : _adapter$current.
|
|
67
|
-
adapter === null || adapter === void 0 ? void 0 : (_adapter$current2 = adapter.current) === null || _adapter$current2 === void 0 ? void 0 : _adapter$current2.destroy();
|
|
68
|
-
player === null || player === void 0 ? void 0 : (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.destroy();
|
|
64
|
+
adapter === null || adapter === void 0 ? void 0 : (_adapter$current = adapter.current) === null || _adapter$current === void 0 ? void 0 : _adapter$current.destroy();
|
|
69
65
|
};
|
|
70
66
|
}, [container]);
|
|
71
67
|
const chromeless = (config === null || config === void 0 ? void 0 : config.chromeless) === undefined || (config === null || config === void 0 ? void 0 : config.chromeless) === true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","THEOplayer","_THEOplayerWebAdapter","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","THEOplayer","_THEOplayerWebAdapter","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","THEOplayerView","props","config","children","player","useRef","adapter","container","useEffect","current","_props$onPlayerReady","chromeless","undefined","updatedConfig","allowNativeFullscreen","ChromelessPlayer","Player","ui","fluid","THEOplayerWebAdapter","window","nativePlayer","onPlayerReady","_adapter$current","onPlayerDestroy","destroy","createElement","Fragment","ref","style","styles","className","display","position","width","height","maxHeight","maxWidth","aspectRatio"],"sources":["THEOplayerView.web.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport type { THEOplayerViewProps } from 'react-native-theoplayer';\nimport * as THEOplayer from 'theoplayer';\nimport { THEOplayerWebAdapter } from './adapter/THEOplayerWebAdapter';\n\nexport function THEOplayerView(props: React.PropsWithChildren<THEOplayerViewProps>) {\n const { config, children } = props;\n const player = useRef<THEOplayer.ChromelessPlayer | null>(null);\n const adapter = useRef<THEOplayerWebAdapter | null>(null);\n const container = useRef<null | HTMLDivElement>(null);\n\n useEffect(() => {\n // Create player inside container.\n if (container.current) {\n const chromeless = config?.chromeless === true || config?.chromeless === undefined;\n const updatedConfig = { ...config, allowNativeFullscreen: true };\n if (chromeless) {\n player.current = new THEOplayer.ChromelessPlayer(container.current, updatedConfig);\n } else {\n player.current = new THEOplayer.Player(container.current, {\n ...updatedConfig,\n ui: {\n fluid: true,\n },\n } as THEOplayer.PlayerConfiguration);\n }\n\n // Adapt native player to react-native player.\n adapter.current = new THEOplayerWebAdapter(player.current, config);\n\n // Expose players for easy access\n // @ts-ignore\n window.player = adapter.current;\n\n // @ts-ignore\n window.nativePlayer = player;\n\n // Notify the player is ready\n props.onPlayerReady?.(adapter.current);\n }\n\n // Clean-up\n return () => {\n // Notify the player will be destroyed.\n const { onPlayerDestroy } = props;\n if (adapter?.current && onPlayerDestroy) {\n onPlayerDestroy(adapter?.current);\n }\n adapter?.current?.destroy();\n };\n }, [container]);\n\n const chromeless = config?.chromeless === undefined || config?.chromeless === true;\n return (\n <>\n <div\n ref={container}\n style={styles.container}\n className={chromeless ? 'theoplayer-container' : 'theoplayer-container video-js theoplayer-skin'}\n />\n {children}\n </>\n );\n}\n\nconst styles = {\n // by default stretch the video to cover the container.\n // Override using the 'theoplayer-container' class.\n container: {\n display: 'flex',\n position: 'relative',\n width: '100%',\n height: '100%',\n maxHeight: '100vh',\n maxWidth: '100vw',\n aspectRatio: '16 / 9',\n } as React.CSSProperties,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAAsE,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAE/D,SAASW,cAAcA,CAACC,KAAmD,EAAE;EAClF,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAGF,KAAK;EAClC,MAAMG,MAAM,GAAG,IAAAC,aAAM,EAAqC,IAAI,CAAC;EAC/D,MAAMC,OAAO,GAAG,IAAAD,aAAM,EAA8B,IAAI,CAAC;EACzD,MAAME,SAAS,GAAG,IAAAF,aAAM,EAAwB,IAAI,CAAC;EAErD,IAAAG,gBAAS,EAAC,MAAM;IACd;IACA,IAAID,SAAS,CAACE,OAAO,EAAE;MAAA,IAAAC,oBAAA;MACrB,MAAMC,UAAU,GAAG,CAAAT,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAES,UAAU,MAAK,IAAI,IAAI,CAAAT,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAES,UAAU,MAAKC,SAAS;MAClF,MAAMC,aAAa,GAAG;QAAE,GAAGX,MAAM;QAAEY,qBAAqB,EAAE;MAAK,CAAC;MAChE,IAAIH,UAAU,EAAE;QACdP,MAAM,CAACK,OAAO,GAAG,IAAIjC,UAAU,CAACuC,gBAAgB,CAACR,SAAS,CAACE,OAAO,EAAEI,aAAa,CAAC;MACpF,CAAC,MAAM;QACLT,MAAM,CAACK,OAAO,GAAG,IAAIjC,UAAU,CAACwC,MAAM,CAACT,SAAS,CAACE,OAAO,EAAE;UACxD,GAAGI,aAAa;UAChBI,EAAE,EAAE;YACFC,KAAK,EAAE;UACT;QACF,CAAC,CAAmC;MACtC;;MAEA;MACAZ,OAAO,CAACG,OAAO,GAAG,IAAIU,0CAAoB,CAACf,MAAM,CAACK,OAAO,EAAEP,MAAM,CAAC;;MAElE;MACA;MACAkB,MAAM,CAAChB,MAAM,GAAGE,OAAO,CAACG,OAAO;;MAE/B;MACAW,MAAM,CAACC,YAAY,GAAGjB,MAAM;;MAE5B;MACA,CAAAM,oBAAA,GAAAT,KAAK,CAACqB,aAAa,cAAAZ,oBAAA,uBAAnBA,oBAAA,CAAAb,IAAA,CAAAI,KAAK,EAAiBK,OAAO,CAACG,OAAO,CAAC;IACxC;;IAEA;IACA,OAAO,MAAM;MAAA,IAAAc,gBAAA;MACX;MACA,MAAM;QAAEC;MAAgB,CAAC,GAAGvB,KAAK;MACjC,IAAIK,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEG,OAAO,IAAIe,eAAe,EAAE;QACvCA,eAAe,CAAClB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,OAAO,CAAC;MACnC;MACAH,OAAO,aAAPA,OAAO,wBAAAiB,gBAAA,GAAPjB,OAAO,CAAEG,OAAO,cAAAc,gBAAA,uBAAhBA,gBAAA,CAAkBE,OAAO,EAAE;IAC7B,CAAC;EACH,CAAC,EAAE,CAAClB,SAAS,CAAC,CAAC;EAEf,MAAMI,UAAU,GAAG,CAAAT,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAES,UAAU,MAAKC,SAAS,IAAI,CAAAV,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAES,UAAU,MAAK,IAAI;EAClF,oBACEtC,MAAA,CAAAY,OAAA,CAAAyC,aAAA,CAAArD,MAAA,CAAAY,OAAA,CAAA0C,QAAA,qBACEtD,MAAA,CAAAY,OAAA,CAAAyC,aAAA;IACEE,GAAG,EAAErB,SAAU;IACfsB,KAAK,EAAEC,MAAM,CAACvB,SAAU;IACxBwB,SAAS,EAAEpB,UAAU,GAAG,sBAAsB,GAAG;EAAgD,EACjG,EACDR,QAAQ,CACR;AAEP;AAEA,MAAM2B,MAAM,GAAG;EACb;EACA;EACAvB,SAAS,EAAE;IACTyB,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE,UAAU;IACpBC,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACdC,SAAS,EAAE,OAAO;IAClBC,QAAQ,EAAE,OAAO;IACjBC,WAAW,EAAE;EACf;AACF,CAAC"}
|
|
@@ -12,6 +12,7 @@ var _TrackUtils = require("./web/TrackUtils");
|
|
|
12
12
|
var _WebEventForwarder = require("./WebEventForwarder");
|
|
13
13
|
var _WebPresentationModeManager = require("./web/WebPresentationModeManager");
|
|
14
14
|
var _WebMediaSession = require("./web/WebMediaSession");
|
|
15
|
+
var _BaseEvent = require("./event/BaseEvent");
|
|
15
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
18
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -25,17 +26,20 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
25
26
|
constructor(player, config) {
|
|
26
27
|
var _config$mediaControl;
|
|
27
28
|
super();
|
|
28
|
-
_defineProperty(this, "_player", void 0);
|
|
29
29
|
_defineProperty(this, "_adsAdapter", void 0);
|
|
30
30
|
_defineProperty(this, "_castAdapter", void 0);
|
|
31
|
-
_defineProperty(this, "_eventForwarder", void 0);
|
|
32
31
|
_defineProperty(this, "_presentationModeManager", void 0);
|
|
32
|
+
_defineProperty(this, "_player", void 0);
|
|
33
|
+
_defineProperty(this, "_eventForwarder", void 0);
|
|
33
34
|
_defineProperty(this, "_mediaSession", undefined);
|
|
34
35
|
_defineProperty(this, "_targetVideoQuality", undefined);
|
|
35
36
|
_defineProperty(this, "_backgroundAudioConfiguration", defaultBackgroundAudioConfiguration);
|
|
36
37
|
_defineProperty(this, "_pipConfiguration", defaultPipConfiguration);
|
|
37
38
|
_defineProperty(this, "onVisibilityChange", () => {
|
|
38
39
|
var _this$_mediaSession;
|
|
40
|
+
if (!this._player) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
39
43
|
if (document.visibilityState !== 'visible') {
|
|
40
44
|
// Apply background configuration: by default, pause when going to background, unless in pip
|
|
41
45
|
if (this.presentationMode !== _reactNativeTheoplayer.PresentationMode.pip && !this.backgroundAudioConfiguration.enabled) {
|
|
@@ -58,37 +62,51 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
get abr() {
|
|
61
|
-
|
|
65
|
+
var _this$_player;
|
|
66
|
+
return (_this$_player = this._player) === null || _this$_player === void 0 ? void 0 : _this$_player.abr;
|
|
62
67
|
}
|
|
63
68
|
get source() {
|
|
64
|
-
|
|
69
|
+
var _this$_player2;
|
|
70
|
+
return (_this$_player2 = this._player) === null || _this$_player2 === void 0 ? void 0 : _this$_player2.source;
|
|
65
71
|
}
|
|
66
72
|
set source(source) {
|
|
67
73
|
this._targetVideoQuality = undefined;
|
|
68
|
-
this._player
|
|
74
|
+
if (this._player) {
|
|
75
|
+
this._player.source = source;
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
play() {
|
|
71
|
-
|
|
79
|
+
var _this$_player3;
|
|
80
|
+
(_this$_player3 = this._player) === null || _this$_player3 === void 0 ? void 0 : _this$_player3.play();
|
|
72
81
|
}
|
|
73
82
|
pause() {
|
|
74
|
-
|
|
83
|
+
var _this$_player4;
|
|
84
|
+
(_this$_player4 = this._player) === null || _this$_player4 === void 0 ? void 0 : _this$_player4.pause();
|
|
75
85
|
}
|
|
76
86
|
get paused() {
|
|
77
|
-
return this._player.paused;
|
|
87
|
+
return this._player ? this._player.paused : true;
|
|
78
88
|
}
|
|
79
89
|
get autoplay() {
|
|
80
|
-
return this._player.autoplay;
|
|
90
|
+
return this._player ? this._player.autoplay : false;
|
|
81
91
|
}
|
|
82
92
|
set autoplay(autoplay) {
|
|
83
|
-
this._player
|
|
93
|
+
if (this._player) {
|
|
94
|
+
this._player.autoplay = autoplay;
|
|
95
|
+
}
|
|
84
96
|
}
|
|
85
97
|
set preload(type) {
|
|
86
|
-
this._player
|
|
98
|
+
if (this._player) {
|
|
99
|
+
this._player.preload = type;
|
|
100
|
+
}
|
|
87
101
|
}
|
|
88
102
|
get preload() {
|
|
89
|
-
|
|
103
|
+
var _this$_player5;
|
|
104
|
+
return ((_this$_player5 = this._player) === null || _this$_player5 === void 0 ? void 0 : _this$_player5.preload) || 'none';
|
|
90
105
|
}
|
|
91
106
|
get seekable() {
|
|
107
|
+
if (!this._player) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
92
110
|
const nativeRange = this._player.seekable;
|
|
93
111
|
return [...Array(nativeRange.length)].map((_, index) => ({
|
|
94
112
|
start: 1e3 * nativeRange.start(index),
|
|
@@ -96,6 +114,9 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
96
114
|
}));
|
|
97
115
|
}
|
|
98
116
|
get buffered() {
|
|
117
|
+
if (!this._player) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
99
120
|
const nativeRange = this._player.buffered;
|
|
100
121
|
return [...Array(nativeRange.length)].map((_, index) => ({
|
|
101
122
|
start: 1e3 * nativeRange.start(index),
|
|
@@ -103,10 +124,12 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
103
124
|
}));
|
|
104
125
|
}
|
|
105
126
|
get playbackRate() {
|
|
106
|
-
return this._player.playbackRate;
|
|
127
|
+
return this._player ? this._player.playbackRate : 1;
|
|
107
128
|
}
|
|
108
129
|
set playbackRate(playbackRate) {
|
|
109
|
-
this._player
|
|
130
|
+
if (this._player) {
|
|
131
|
+
this._player.playbackRate = playbackRate;
|
|
132
|
+
}
|
|
110
133
|
}
|
|
111
134
|
get pipConfiguration() {
|
|
112
135
|
return this._pipConfiguration;
|
|
@@ -125,19 +148,23 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
125
148
|
(_this$_mediaSession2 = this._mediaSession) === null || _this$_mediaSession2 === void 0 ? void 0 : _this$_mediaSession2.updateActionHandlers();
|
|
126
149
|
}
|
|
127
150
|
get volume() {
|
|
128
|
-
return this._player.volume;
|
|
151
|
+
return this._player ? this._player.volume : 1;
|
|
129
152
|
}
|
|
130
153
|
set volume(volume) {
|
|
131
|
-
this._player
|
|
154
|
+
if (this._player) {
|
|
155
|
+
this._player.volume = volume;
|
|
156
|
+
}
|
|
132
157
|
}
|
|
133
158
|
get muted() {
|
|
134
|
-
return this._player.muted;
|
|
159
|
+
return this._player ? this._player.muted : false;
|
|
135
160
|
}
|
|
136
161
|
set muted(muted) {
|
|
137
|
-
this._player
|
|
162
|
+
if (this._player) {
|
|
163
|
+
this._player.muted = muted;
|
|
164
|
+
}
|
|
138
165
|
}
|
|
139
166
|
get seeking() {
|
|
140
|
-
return this._player.seeking;
|
|
167
|
+
return this._player ? this._player.seeking : false;
|
|
141
168
|
}
|
|
142
169
|
get presentationMode() {
|
|
143
170
|
return this._presentationModeManager.presentationMode;
|
|
@@ -146,61 +173,82 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
146
173
|
this._presentationModeManager.presentationMode = presentationMode;
|
|
147
174
|
}
|
|
148
175
|
get audioTracks() {
|
|
149
|
-
return (0, _TrackUtils.fromNativeMediaTrackList)(this._player.audioTracks);
|
|
176
|
+
return this._player ? (0, _TrackUtils.fromNativeMediaTrackList)(this._player.audioTracks) : [];
|
|
150
177
|
}
|
|
151
178
|
get videoTracks() {
|
|
152
|
-
return (0, _TrackUtils.fromNativeMediaTrackList)(this._player.videoTracks);
|
|
179
|
+
return this._player ? (0, _TrackUtils.fromNativeMediaTrackList)(this._player.videoTracks) : [];
|
|
153
180
|
}
|
|
154
181
|
get textTracks() {
|
|
155
|
-
return (0, _TrackUtils.fromNativeTextTrackList)(this._player.textTracks);
|
|
182
|
+
return this._player ? (0, _TrackUtils.fromNativeTextTrackList)(this._player.textTracks) : [];
|
|
156
183
|
}
|
|
157
184
|
get selectedTextTrack() {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return textTrack
|
|
161
|
-
|
|
185
|
+
if (this._player) {
|
|
186
|
+
var _this$_player$textTra;
|
|
187
|
+
return (_this$_player$textTra = this._player.textTracks.find(textTrack => {
|
|
188
|
+
return textTrack.mode === 'showing';
|
|
189
|
+
})) === null || _this$_player$textTra === void 0 ? void 0 : _this$_player$textTra.uid;
|
|
190
|
+
}
|
|
191
|
+
return undefined;
|
|
162
192
|
}
|
|
163
193
|
set selectedTextTrack(selectedTextTrack) {
|
|
164
|
-
this._player
|
|
165
|
-
|
|
166
|
-
|
|
194
|
+
if (this._player) {
|
|
195
|
+
this._player.textTracks.forEach(textTrack => {
|
|
196
|
+
textTrack.mode = textTrack.uid === selectedTextTrack ? 'showing' : 'disabled';
|
|
197
|
+
});
|
|
198
|
+
}
|
|
167
199
|
}
|
|
168
200
|
get textTrackStyle() {
|
|
169
|
-
|
|
201
|
+
var _this$_player6;
|
|
202
|
+
return (_this$_player6 = this._player) === null || _this$_player6 === void 0 ? void 0 : _this$_player6.textTrackStyle;
|
|
170
203
|
}
|
|
171
204
|
get selectedVideoTrack() {
|
|
172
|
-
|
|
173
|
-
|
|
205
|
+
if (this._player) {
|
|
206
|
+
var _this$_player$videoTr;
|
|
207
|
+
return (_this$_player$videoTr = this._player.videoTracks.find(videoTrack => videoTrack.enabled)) === null || _this$_player$videoTr === void 0 ? void 0 : _this$_player$videoTr.uid;
|
|
208
|
+
}
|
|
209
|
+
return undefined;
|
|
174
210
|
}
|
|
175
211
|
set selectedVideoTrack(selectedVideoTrack) {
|
|
176
|
-
this.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
212
|
+
if (this._player) {
|
|
213
|
+
this._targetVideoQuality = undefined;
|
|
214
|
+
this._player.videoTracks.forEach(videoTrack => {
|
|
215
|
+
videoTrack.enabled = videoTrack.uid === selectedVideoTrack;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
180
218
|
}
|
|
181
219
|
get selectedAudioTrack() {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return audioTrack
|
|
185
|
-
|
|
220
|
+
if (this._player) {
|
|
221
|
+
var _this$_player$audioTr;
|
|
222
|
+
return (_this$_player$audioTr = this._player.audioTracks.find(audioTrack => {
|
|
223
|
+
return audioTrack.enabled;
|
|
224
|
+
})) === null || _this$_player$audioTr === void 0 ? void 0 : _this$_player$audioTr.uid;
|
|
225
|
+
}
|
|
226
|
+
return undefined;
|
|
186
227
|
}
|
|
187
228
|
set selectedAudioTrack(selectedAudioTrack) {
|
|
188
|
-
this._player
|
|
189
|
-
|
|
190
|
-
|
|
229
|
+
if (this._player) {
|
|
230
|
+
this._player.audioTracks.forEach(audioTrack => {
|
|
231
|
+
audioTrack.enabled = audioTrack.uid === selectedAudioTrack;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
191
234
|
}
|
|
192
235
|
get targetVideoQuality() {
|
|
193
|
-
|
|
236
|
+
if (this._player) {
|
|
237
|
+
return this._targetVideoQuality;
|
|
238
|
+
}
|
|
239
|
+
return undefined;
|
|
194
240
|
}
|
|
195
241
|
set targetVideoQuality(targetVideoQuality) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
242
|
+
if (this._player) {
|
|
243
|
+
const enabledVideoTrack = this._player.videoTracks.find(videoTrack => videoTrack.enabled);
|
|
244
|
+
if (enabledVideoTrack) {
|
|
245
|
+
enabledVideoTrack.targetQuality = (0, _TrackUtils.findNativeQualitiesByUid)(enabledVideoTrack, targetVideoQuality);
|
|
246
|
+
}
|
|
247
|
+
this._targetVideoQuality = targetVideoQuality;
|
|
199
248
|
}
|
|
200
|
-
this._targetVideoQuality = targetVideoQuality;
|
|
201
249
|
}
|
|
202
250
|
get currentTime() {
|
|
203
|
-
return 1e3 * this._player.currentTime;
|
|
251
|
+
return this._player ? 1e3 * this._player.currentTime : NaN;
|
|
204
252
|
}
|
|
205
253
|
set currentTime(currentTime) {
|
|
206
254
|
if (isNaN(currentTime)) {
|
|
@@ -217,7 +265,7 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
217
265
|
// unused
|
|
218
266
|
}
|
|
219
267
|
get duration() {
|
|
220
|
-
return this._player.duration * 1e3;
|
|
268
|
+
return this._player ? this._player.duration * 1e3 : NaN;
|
|
221
269
|
}
|
|
222
270
|
get ads() {
|
|
223
271
|
return this._adsAdapter;
|
|
@@ -226,10 +274,15 @@ class THEOplayerWebAdapter extends _DefaultEventDispatcher.DefaultEventDispatche
|
|
|
226
274
|
return this._castAdapter;
|
|
227
275
|
}
|
|
228
276
|
destroy() {
|
|
229
|
-
var _this$_mediaSession3;
|
|
230
|
-
this.
|
|
277
|
+
var _this$_eventForwarder, _this$_mediaSession3, _this$_player7;
|
|
278
|
+
this.dispatchEvent(new _BaseEvent.BaseEvent(_reactNativeTheoplayer.PlayerEventType.DESTROY));
|
|
279
|
+
(_this$_eventForwarder = this._eventForwarder) === null || _this$_eventForwarder === void 0 ? void 0 : _this$_eventForwarder.unload();
|
|
231
280
|
(_this$_mediaSession3 = this._mediaSession) === null || _this$_mediaSession3 === void 0 ? void 0 : _this$_mediaSession3.destroy();
|
|
232
281
|
document.removeEventListener('visibilitychange', this.onVisibilityChange);
|
|
282
|
+
this._eventForwarder = undefined;
|
|
283
|
+
this._mediaSession = undefined;
|
|
284
|
+
(_this$_player7 = this._player) === null || _this$_player7 === void 0 ? void 0 : _this$_player7.destroy();
|
|
285
|
+
this._player = undefined;
|
|
233
286
|
}
|
|
234
287
|
get nativeHandle() {
|
|
235
288
|
return this._player;
|