ravnur-player-public 3.4.4 → 3.4.6
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/dist/RavnurMediaPlayer.min.js +1 -1
- package/dist/cdn/RavnurMediaPlayer.min.js +1 -1
- package/package.json +72 -68
- package/.eslintignore +0 -7
- package/.eslintrc.js +0 -206
- package/.flowconfig +0 -3
- package/.vscode/extensions.json +0 -7
- package/.vscode/launch.json +0 -37
- package/.vscode/settings.json +0 -4
- package/README-Private.md +0 -54
- package/babel.config.js +0 -28
- package/bitbucket-pipelines.yml +0 -61
- package/cert.pem +0 -23
- package/demo/BaseM.mp4 +0 -0
- package/demo/HD.mp4 +0 -0
- package/demo/annotations.json +0 -50
- package/demo/annotations_ge.json +0 -50
- package/demo/base.mp3 +0 -0
- package/demo/cc_2125en.vtt +0 -4958
- package/demo/cc_en.vtt +0 -171
- package/demo/cc_ge.vtt +0 -178
- package/demo/chapters_en.vtt +0 -38
- package/demo/chapters_ge.vtt +0 -5
- package/demo/chapters_ge1.json +0 -23
- package/demo/hls/audio/stereo/en/128kbit.m3u8 +0 -912
- package/demo/hls/audio/stereo/none/128kbit.m3u8 +0 -912
- package/demo/hls/audio/surround/en/320kbit.m3u8 +0 -912
- package/demo/hls/playlist.m3u8 +0 -31
- package/demo/hls/video/10000kbit.m3u8 +0 -894
- package/demo/hls/video/1100kbit.m3u8 +0 -894
- package/demo/hls/video/1500kbit.m3u8 +0 -894
- package/demo/hls/video/250kbit.m3u8 +0 -894
- package/demo/hls/video/4000kbit.m3u8 +0 -894
- package/demo/hls/video/500kbit.m3u8 +0 -894
- package/demo/hls/video/6000kbit.m3u8 +0 -894
- package/demo/hls/video/800kbit.m3u8 +0 -894
- package/demo/hls.js +0 -5
- package/demo/hls.js.map +0 -1
- package/demo/hls.min.js +0 -2
- package/demo/hls.min.js.map +0 -1
- package/demo/playlist.m3u8 +0 -31
- package/demo/ravnur-flash-audio.swf +0 -0
- package/demo/ravnur-flash-video-hls.swf +0 -0
- package/demo/ravnur-flash-video.swf +0 -0
- package/demo/shaka/shaka-player.foo.debug.d.ts +0 -4532
- package/demo/shaka/shaka-player.foo.debug.externs.js +0 -3886
- package/demo/shaka/shaka-player.foo.debug.js +0 -1746
- package/demo/shaka/shaka-player.foo.debug.map +0 -8
- package/demo/shaka/wrapper.js +0 -7
- package/demo/test.html +0 -458
- package/jest.config.js +0 -4
- package/key.pem +0 -27
- package/lib/es5.js +0 -344
- package/lib/images/Spinner-small.gif +0 -0
- package/lib/images/close.png +0 -0
- package/lib/images/ic_check_box_black_24dp_1x.png +0 -0
- package/lib/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
- package/lib/images/ic_chevron_left_white_24dp_1x.png +0 -0
- package/lib/images/ic_chevron_right_white_24dp_1x.png +0 -0
- package/lib/images/ic_closed_caption_white_24dp_1x.png +0 -0
- package/lib/images/ic_fast_forward_white_24dp_1x.png +0 -0
- package/lib/images/ic_fast_rewind_white_24dp_1x.png +0 -0
- package/lib/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
- package/lib/images/ic_fullscreen_white_24dp_1x.png +0 -0
- package/lib/images/ic_hd_white_24dp_1x.png +0 -0
- package/lib/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
- package/lib/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
- package/lib/images/ic_pause_white_24dp_1x.png +0 -0
- package/lib/images/ic_photo_white_24dp_1x.png +0 -0
- package/lib/images/ic_play_arrow_white_24dp_1x.png +0 -0
- package/lib/images/ic_refresh_white_24dp_1x.png +0 -0
- package/lib/images/ic_settings_white_24dp_1x.png +0 -0
- package/lib/images/ic_skip_next_white_24dp_1x.png +0 -0
- package/lib/images/ic_skip_previous_white_24dp_1x.png +0 -0
- package/lib/images/ic_toc_white_24dp_1x.png +0 -0
- package/lib/images/ic_volume_off_white_24dp_1x.png +0 -0
- package/lib/images/ic_volume_up_white_24dp_1x.png +0 -0
- package/lib/player4ie8.css +0 -225
- package/server.js +0 -29
- package/src/config/cc.js +0 -56
- package/src/config/i18n.js +0 -101
- package/src/config/options.js +0 -123
- package/src/config/playlist.js +0 -9
- package/src/config/source.js +0 -23
- package/src/config/statuses.js +0 -8
- package/src/config/styles.js +0 -16
- package/src/entity.js +0 -27
- package/src/events.js +0 -5
- package/src/extensions/annotations.js +0 -142
- package/src/extensions/audio-tarcks.js +0 -115
- package/src/extensions/backward.js +0 -45
- package/src/extensions/base.js +0 -73
- package/src/extensions/bottom-next.js +0 -50
- package/src/extensions/bottom-prev.js +0 -50
- package/src/extensions/buffering.js +0 -78
- package/src/extensions/c2pa.js +0 -350
- package/src/extensions/caption-search.js +0 -230
- package/src/extensions/cc.js +0 -874
- package/src/extensions/crawl.js +0 -118
- package/src/extensions/download.js +0 -411
- package/src/extensions/error.js +0 -47
- package/src/extensions/forward.js +0 -44
- package/src/extensions/fullscreen.js +0 -84
- package/src/extensions/help.js +0 -201
- package/src/extensions/helpers/FileSaver.js +0 -157
- package/src/extensions/helpers/clickOpener.js +0 -180
- package/src/extensions/helpers/opener.js +0 -30
- package/src/extensions/helpers/openerHeightChecker.js +0 -13
- package/src/extensions/helpers/popover.js +0 -33
- package/src/extensions/helpers/popoverPosition.js +0 -30
- package/src/extensions/helpers/scrollIntoView.js +0 -9
- package/src/extensions/helpers/storage.js +0 -20
- package/src/extensions/helpers/textContent.js +0 -6
- package/src/extensions/helpers/timeCodeToSeconds.js +0 -44
- package/src/extensions/helpers/transport.js +0 -43
- package/src/extensions/helpers/vtt-loader.js +0 -42
- package/src/extensions/index.js +0 -87
- package/src/extensions/live.js +0 -76
- package/src/extensions/mux.js +0 -57
- package/src/extensions/next-frame.js +0 -44
- package/src/extensions/next.js +0 -48
- package/src/extensions/placeholder.js +0 -241
- package/src/extensions/play.js +0 -102
- package/src/extensions/poster.js +0 -47
- package/src/extensions/prev-frame.js +0 -44
- package/src/extensions/prev.js +0 -48
- package/src/extensions/progress.js +0 -465
- package/src/extensions/resizer.js +0 -37
- package/src/extensions/settings.js +0 -367
- package/src/extensions/theater.js +0 -56
- package/src/extensions/title.js +0 -38
- package/src/extensions/toc.js +0 -334
- package/src/extensions/volume.js +0 -196
- package/src/flash/FlashPlugin.js +0 -301
- package/src/flash/MediaElement.js +0 -361
- package/src/flash/plugins.js +0 -32
- package/src/flash-detector.js +0 -66
- package/src/helpers/$t.js +0 -10
- package/src/helpers/binder.js +0 -11
- package/src/helpers/isAndroid.js +0 -5
- package/src/helpers/isBlackBerry.js +0 -5
- package/src/helpers/isCanvasSupported.js +0 -6
- package/src/helpers/isIE.js +0 -21
- package/src/helpers/isMobile.js +0 -10
- package/src/helpers/isWindows.js +0 -5
- package/src/helpers/isWindowsPhone.js +0 -5
- package/src/helpers/isiOS.js +0 -5
- package/src/html5media.js +0 -19
- package/src/index.js +0 -2
- package/src/logger.js +0 -31
- package/src/microevent.js +0 -65
- package/src/normalize-options.js +0 -139
- package/src/player.js +0 -864
- package/src/players/base.js +0 -209
- package/src/players/flash.js +0 -172
- package/src/players/hls.js +0 -278
- package/src/players/html.js +0 -205
- package/src/players/index.js +0 -59
- package/src/players/shaka.js +0 -219
- package/src/playlist.js +0 -362
- package/src/screenfull.js +0 -121
- package/src/state.js +0 -474
- package/src/static/es5.js +0 -344
- package/src/static/images/Spinner-small.gif +0 -0
- package/src/static/images/close.png +0 -0
- package/src/static/images/ic_check_box_black_24dp_1x.png +0 -0
- package/src/static/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
- package/src/static/images/ic_chevron_left_white_24dp_1x.png +0 -0
- package/src/static/images/ic_chevron_right_white_24dp_1x.png +0 -0
- package/src/static/images/ic_closed_caption_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fast_forward_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fast_rewind_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
- package/src/static/images/ic_fullscreen_white_24dp_1x.png +0 -0
- package/src/static/images/ic_hd_white_24dp_1x.png +0 -0
- package/src/static/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
- package/src/static/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
- package/src/static/images/ic_pause_white_24dp_1x.png +0 -0
- package/src/static/images/ic_play_arrow_white_24dp_1x.png +0 -0
- package/src/static/images/ic_refresh_white_24dp_1x.png +0 -0
- package/src/static/images/ic_settings_white_24dp_1x.png +0 -0
- package/src/static/images/ic_skip_next_white_24dp_1x.png +0 -0
- package/src/static/images/ic_skip_previous_white_24dp_1x.png +0 -0
- package/src/static/images/ic_toc_white_24dp_1x.png +0 -0
- package/src/static/images/ic_volume_off_white_24dp_1x.png +0 -0
- package/src/static/images/ic_volume_up_white_24dp_1x.png +0 -0
- package/src/static/player4ie8.css +0 -225
- package/src/styles/bplaylist.css.js +0 -124
- package/src/styles/index.js +0 -1966
- package/src/styles/playlist.css.js +0 -84
- package/src/styles/rplaylist.css.js +0 -98
- package/src/svgs.js +0 -111
- package/src/types/Logger.js +0 -10
- package/src/types/Options.js +0 -179
- package/src/types/Playlist.js +0 -3
- package/src/types/Source.js +0 -28
- package/src/types/State.js +0 -46
- package/src/types/Styles.js +0 -11
- package/src/types/TimeData.js +0 -8
- package/src/types/Translation.js +0 -69
- package/src/utils/absolutizeUrl.js +0 -9
- package/src/utils/addClass.js +0 -9
- package/src/utils/addEvent.js +0 -31
- package/src/utils/addProperty.js +0 -65
- package/src/utils/appendChild.js +0 -14
- package/src/utils/buff2hex.js +0 -5
- package/src/utils/contains.js +0 -33
- package/src/utils/createElement.js +0 -24
- package/src/utils/each.js +0 -34
- package/src/utils/escapeHTML.js +0 -8
- package/src/utils/existy.js +0 -4
- package/src/utils/extend.js +0 -17
- package/src/utils/filter.js +0 -16
- package/src/utils/find.js +0 -11
- package/src/utils/findIndex.js +0 -20
- package/src/utils/first.js +0 -5
- package/src/utils/get.js +0 -19
- package/src/utils/has.js +0 -5
- package/src/utils/hasClass.js +0 -6
- package/src/utils/head.js +0 -11
- package/src/utils/inRange.js +0 -16
- package/src/utils/index.js +0 -73
- package/src/utils/isArray.js +0 -4
- package/src/utils/isBoolean.js +0 -3
- package/src/utils/isElement.js +0 -7
- package/src/utils/isEmpty.js +0 -6
- package/src/utils/isEqual.js +0 -33
- package/src/utils/isEqualBuffer.js +0 -13
- package/src/utils/isFunction.js +0 -3
- package/src/utils/isNotEmpty.js +0 -5
- package/src/utils/isObject.js +0 -5
- package/src/utils/isString.js +0 -9
- package/src/utils/last.js +0 -4
- package/src/utils/map.js +0 -11
- package/src/utils/negate.js +0 -8
- package/src/utils/noop.js +0 -1
- package/src/utils/notExisty.js +0 -5
- package/src/utils/reduce.js +0 -8
- package/src/utils/remove.js +0 -7
- package/src/utils/removeClass.js +0 -8
- package/src/utils/removeEvent.js +0 -7
- package/src/utils/toArray.js +0 -7
- package/src/utils/toggleClass.js +0 -16
- package/src/utils/uidGenerator.js +0 -8
- package/src/utils/upperFirst.js +0 -4
- package/tests/extensions/__snapshots__/download.spec.js.snap +0 -226
- package/tests/extensions/__snapshots__/fullscreen.spec.js.snap +0 -30
- package/tests/extensions/__snapshots__/title.spec.js.snap +0 -16
- package/tests/extensions/download.spec.js +0 -111
- package/tests/extensions/fullscreen.spec.js +0 -56
- package/tests/extensions/title.spec.js +0 -35
- package/tests/mocks/assets/BaseM.mp4 +0 -0
- package/tests/mocks/assets/hls.min.js +0 -5
- package/tests/mocks/assets/styleMock.js +0 -1
- package/tests/mocks/base-player-options.js +0 -47
- package/tests/mocks/sources.js +0 -58
- package/tests/mocks/timedata/cc_en.vtt +0 -171
- package/tests/mocks/timedata/cc_ge.vtt +0 -178
- package/tests/utils/wait.js +0 -1
- package/webpack.config.js +0 -78
package/src/players/base.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import Entity from '../entity';
|
|
3
|
-
|
|
4
|
-
import type { Player$ControllerOptions } from '../types/Options';
|
|
5
|
-
|
|
6
|
-
const MS_IN_SEC = 1000;
|
|
7
|
-
|
|
8
|
-
export default class BasePlayer extends Entity {
|
|
9
|
-
options: Player$ControllerOptions
|
|
10
|
-
state;
|
|
11
|
-
constructor(options: Player$ControllerOptions, state) {
|
|
12
|
-
super(options.bus, options.logger);
|
|
13
|
-
this.state = state;
|
|
14
|
-
this.logger.debug('player:created');
|
|
15
|
-
this.options = options;
|
|
16
|
-
setTimeout( () => this.getElement().setAttribute('tabindex', '-1') );
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
focus() {
|
|
20
|
-
let el = this.getElement();
|
|
21
|
-
// fix for ff
|
|
22
|
-
if ( this.options.isAudio ) {
|
|
23
|
-
// $FlowFixMe
|
|
24
|
-
el = el.parentNode.parentNode;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if ( el && el instanceof HTMLElement ) {
|
|
28
|
-
el.focus();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getTimeCode(): number {
|
|
33
|
-
return this.options.timecode;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getCurrentTime() {
|
|
37
|
-
return this.getElement().currentTime + this.getTimeCode();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
setCurrentTime(time: number, silent: ?boolean = true) {
|
|
41
|
-
if (!this.getElement()) return;
|
|
42
|
-
|
|
43
|
-
time -= this.getTimeCode();
|
|
44
|
-
|
|
45
|
-
const { clip } = this.options;
|
|
46
|
-
if ( clip ) {
|
|
47
|
-
let [ start, end ] = clip;
|
|
48
|
-
start = start || 0;
|
|
49
|
-
end = end || this.getElement().duration;
|
|
50
|
-
time = Math.max(time, start);
|
|
51
|
-
time = Math.min(time, end);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.getElement().currentTime = time;
|
|
55
|
-
if ( !silent ) {
|
|
56
|
-
this.focus();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
nextFrame() {
|
|
61
|
-
const frameDuration = this._getFrameDuration();
|
|
62
|
-
let time = this.getElement().currentTime;
|
|
63
|
-
let frameNumber = Math.floor(time * MS_IN_SEC / frameDuration);
|
|
64
|
-
time = Math.ceil(++frameNumber * frameDuration) / MS_IN_SEC;
|
|
65
|
-
this.setCurrentTime(time + this.getTimeCode());
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
prevFrame() {
|
|
69
|
-
const frameDuration = this._getFrameDuration();
|
|
70
|
-
let time = this.getElement().currentTime;
|
|
71
|
-
let frameNumber = Math.floor(time * MS_IN_SEC / frameDuration);
|
|
72
|
-
time = Math.ceil(--frameNumber * frameDuration) / MS_IN_SEC;
|
|
73
|
-
this.setCurrentTime(time + this.getTimeCode());
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
isPaused() {
|
|
77
|
-
if (!this.getElement()) return false;
|
|
78
|
-
return this.getElement().paused;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
isEnded() {
|
|
82
|
-
if (!this.getElement()) return false;
|
|
83
|
-
|
|
84
|
-
const { clip } = this.options;
|
|
85
|
-
if ( clip ) {
|
|
86
|
-
const duration = this.getElement().duration;
|
|
87
|
-
let [ start, end ] = clip; // eslint-disable-line no-unused-vars
|
|
88
|
-
end = end || duration;
|
|
89
|
-
end += this.getTimeCode();
|
|
90
|
-
return this.getCurrentTime() >= end;
|
|
91
|
-
}
|
|
92
|
-
return this.getElement().ended;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
play(silent: ?boolean = true) {
|
|
96
|
-
this.bus.emit('handle-play-clicked');
|
|
97
|
-
if (!silent) {
|
|
98
|
-
this.focus();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const { clip } = this.options;
|
|
102
|
-
if ( this.isEnded() && clip ) {
|
|
103
|
-
const [ start ] = clip;
|
|
104
|
-
this.setCurrentTime(start || 0);
|
|
105
|
-
}
|
|
106
|
-
return this.getElement().play();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
pause(silent: ?boolean = true) {
|
|
110
|
-
if (!silent) {
|
|
111
|
-
this.focus();
|
|
112
|
-
}
|
|
113
|
-
return this.getElement().pause();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
getDuration() {
|
|
117
|
-
if (!this.getElement()) return '';
|
|
118
|
-
|
|
119
|
-
let duration = this.getElement().duration;
|
|
120
|
-
const { clip } = this.options;
|
|
121
|
-
if ( clip ) {
|
|
122
|
-
let [ start, end ] = clip;
|
|
123
|
-
start = start || 0;
|
|
124
|
-
end = end || duration;
|
|
125
|
-
duration = end - start;
|
|
126
|
-
}
|
|
127
|
-
return duration + this.getTimeCode();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
isMuted() {
|
|
131
|
-
return this.getElement().muted;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
setMuted(muted: boolean, silent: ?boolean = true) {
|
|
135
|
-
this.getElement().muted = muted;
|
|
136
|
-
if (!silent) {
|
|
137
|
-
this.focus();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
getVolume() {
|
|
142
|
-
return this.getElement().volume;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
setVolume(volume: number, silent: ?boolean = true) {
|
|
146
|
-
this.getElement().volume = volume;
|
|
147
|
-
if (!silent) {
|
|
148
|
-
this.focus();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
destroy() {
|
|
153
|
-
this.logger.debug('player:destroy');
|
|
154
|
-
super.destroy();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
getLevels() {
|
|
158
|
-
throw new Error('You must override it');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
getLevel() {
|
|
162
|
-
throw new Error('You must override it');
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
setLevel(/* level */) {
|
|
166
|
-
throw new Error('You must override it');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
isMultiAudioTracks() {
|
|
170
|
-
return this.getAudioTracks().length > 1;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
getAudioTracks() {
|
|
174
|
-
return [];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
getAudioTrack() {
|
|
178
|
-
return 0;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
setAudioTrack(idx) {
|
|
182
|
-
// noop;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
getTextTracks() {
|
|
186
|
-
// noop;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
load(/* sources */) {
|
|
190
|
-
throw new Error('You must override it');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
isMultiQuality(): boolean {
|
|
194
|
-
// eslint-disable-next-line no-magic-numbers
|
|
195
|
-
return this.getLevels().length > 1;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
getBufferedPercent(): number {
|
|
199
|
-
return 0;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
getElement(): HTMLVideoElement | HTMLAudioElement {
|
|
203
|
-
throw new Error('You must override it');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
_getFrameDuration(): number {
|
|
207
|
-
return MS_IN_SEC / this.options.frameRate;
|
|
208
|
-
}
|
|
209
|
-
}
|
package/src/players/flash.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import BasePlayer from './base';
|
|
2
|
-
|
|
3
|
-
import MediaElement from '../flash/MediaElement';
|
|
4
|
-
|
|
5
|
-
import { get, createElement, toArray, find, first, isArray } from '../utils';
|
|
6
|
-
|
|
7
|
-
import type { Player$Options } from '../types/Options';
|
|
8
|
-
|
|
9
|
-
const AUTO_LEVEL = { name: 'Auto', index: -1 };
|
|
10
|
-
|
|
11
|
-
export default class FlashPlayer extends BasePlayer {
|
|
12
|
-
$el: HTMLAudioElement | HTMLVideoElement
|
|
13
|
-
_levels = [];
|
|
14
|
-
_currentLevel = null;
|
|
15
|
-
|
|
16
|
-
mediaElement: ?MediaElement = null
|
|
17
|
-
|
|
18
|
-
constructor(options: Player$Options, state) {
|
|
19
|
-
super(options, state);
|
|
20
|
-
this.logger.debug('flash:controller:creating');
|
|
21
|
-
|
|
22
|
-
this.$el = createElement(options.isAudio ? 'audio' : 'video');
|
|
23
|
-
|
|
24
|
-
this.onFullScreenChanged = this.onFullScreenChanged.bind(this);
|
|
25
|
-
|
|
26
|
-
this.logger.debug('flash:controller:created');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
load({src}) {
|
|
30
|
-
|
|
31
|
-
if ( isArray(src) ) {
|
|
32
|
-
this._levels = src;
|
|
33
|
-
this._currentLevel = find(this._levels, lvl => lvl.default) || first(this._levels);
|
|
34
|
-
src = this._currentLevel.src;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.logger.debug('flash:controller:loading', src);
|
|
38
|
-
|
|
39
|
-
const mediaElement = new MediaElement(this.$el, this.options);
|
|
40
|
-
this.mediaElement = mediaElement;
|
|
41
|
-
mediaElement.setSrc(src);
|
|
42
|
-
mediaElement.setSize('100%', '100%');
|
|
43
|
-
|
|
44
|
-
mediaElement.play();
|
|
45
|
-
|
|
46
|
-
this.bus.once('loadedmetadata', () => {
|
|
47
|
-
mediaElement.pause();
|
|
48
|
-
|
|
49
|
-
if (this.options.qualityLevel) {
|
|
50
|
-
const h = parseInt(this.options.qualityLevel, 10);
|
|
51
|
-
const level = find(this.getLevels(), l => l.height === h);
|
|
52
|
-
if (level) {
|
|
53
|
-
this.setLevel(level);
|
|
54
|
-
this.bus.emit('qualitychange', `${h}p`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (this.options.isAudio) {
|
|
60
|
-
mediaElement.pause();
|
|
61
|
-
this.bus.once('canplaythrough', () => {
|
|
62
|
-
mediaElement.pause();
|
|
63
|
-
this.bus.emit('loadedmetadata');
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.bus.on('fullscreenchanged', this.onFullScreenChanged);
|
|
68
|
-
this.bus.on('cclayoutchange', this.onFullScreenChanged);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
isHLS() {
|
|
72
|
-
return get(this.mediaElement, 'rendererName') === 'flash_hls';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getLevels() {
|
|
76
|
-
if (this.isHLS()) {
|
|
77
|
-
const levels = toArray(this.mediaElement.levels);
|
|
78
|
-
return [ AUTO_LEVEL ].concat(levels);
|
|
79
|
-
}
|
|
80
|
-
return this._levels;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setLevel(level) {
|
|
84
|
-
if (this.isHLS()) {
|
|
85
|
-
this.mediaElement.level = level.index;
|
|
86
|
-
} else if ( this._currentLevel !== level ) {
|
|
87
|
-
const currentTime = this.mediaElement.currentTime;
|
|
88
|
-
const paused = this.mediaElement.paused;
|
|
89
|
-
this._currentLevel = level;
|
|
90
|
-
this.mediaElement.setSrc(level.src);
|
|
91
|
-
this.mediaElement.setSize('100%', '100%');
|
|
92
|
-
this.mediaElement.play();
|
|
93
|
-
this.bus.once('loadedmetadata', () => {
|
|
94
|
-
this.mediaElement.currentTime = currentTime;
|
|
95
|
-
this.mediaElement.pause();
|
|
96
|
-
this.mediaElement.play();
|
|
97
|
-
if (paused) {
|
|
98
|
-
this.mediaElement.pause();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
getLevel() {
|
|
105
|
-
if (this.isHLS()) {
|
|
106
|
-
return this.mediaElement.levels[this.getElement().currentLevel] || AUTO_LEVEL;
|
|
107
|
-
}
|
|
108
|
-
return this._currentLevel;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
getElement() {
|
|
112
|
-
return this.mediaElement;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setCurrentTime(time: number, silent: ?boolean = true) {
|
|
116
|
-
const paused = this.isPaused();
|
|
117
|
-
this.pause(silent);
|
|
118
|
-
super.setCurrentTime(time, silent);
|
|
119
|
-
if ( !paused ) {
|
|
120
|
-
this.play(silent);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
isMultiQuality() {
|
|
125
|
-
const levels = this.isHLS() ? this.mediaElement.levels : this._levels;
|
|
126
|
-
// eslint-disable-next-line no-magic-numbers
|
|
127
|
-
return levels.length > 1;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
onFullScreenChanged(isFullScreen: ?boolean = false) {
|
|
131
|
-
if (isFullScreen) {
|
|
132
|
-
const { mediaElement } = this;
|
|
133
|
-
if (mediaElement) {
|
|
134
|
-
mediaElement.setSize('100%', '100%');
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
setTimeout(() => this._resizeME());
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
_resizeME() {
|
|
142
|
-
const parent = this.$el.parentNode;
|
|
143
|
-
const me = this.mediaElement;
|
|
144
|
-
if (parent && me && parent instanceof HTMLElement) {
|
|
145
|
-
const width = parent.offsetWidth;
|
|
146
|
-
const height = parent.offsetHeight;
|
|
147
|
-
me.setSize(`${width}px`, `${height}px`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getBufferedPercent() {
|
|
152
|
-
const $el = this.mediaElement;
|
|
153
|
-
return $el.buffered.end($el.buffered.length - 1) / $el.duration;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
destroy() {
|
|
157
|
-
this.pause();
|
|
158
|
-
const { mediaElement } = this;
|
|
159
|
-
if ( mediaElement ) {
|
|
160
|
-
mediaElement.renderer.hide();
|
|
161
|
-
}
|
|
162
|
-
super.destroy();
|
|
163
|
-
this.bus.off('fullscreenchanged', this.onFullScreenChanged);
|
|
164
|
-
this.bus.off('cclayoutchange', this.onFullScreenChanged);
|
|
165
|
-
|
|
166
|
-
if (mediaElement) {
|
|
167
|
-
mediaElement.removeChild(this.$el);
|
|
168
|
-
mediaElement.parentNode.removeChild(mediaElement);
|
|
169
|
-
}
|
|
170
|
-
this.mediaElement = null;
|
|
171
|
-
}
|
|
172
|
-
}
|
package/src/players/hls.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import HTMLPlayer from './html';
|
|
2
|
-
|
|
3
|
-
// import { C2PA, ValidationResult, C2PAValidationError } from '@ravnur-inc/c2pa';
|
|
4
|
-
import {
|
|
5
|
-
findIndex,
|
|
6
|
-
existy,
|
|
7
|
-
createElement,
|
|
8
|
-
first,
|
|
9
|
-
isArray,
|
|
10
|
-
isObject,
|
|
11
|
-
head,
|
|
12
|
-
extend,
|
|
13
|
-
find
|
|
14
|
-
// isEqualBuffer
|
|
15
|
-
} from '../utils';
|
|
16
|
-
|
|
17
|
-
const AUTO_LEVEL = { name: 'Auto' };
|
|
18
|
-
const HLS_OPTIONS = {
|
|
19
|
-
maxFragLookUpTolerance: 0.5,
|
|
20
|
-
maxMaxBufferLength: 600,
|
|
21
|
-
highBufferWatchdogPeriod: 3,
|
|
22
|
-
playlistLoadPolicy: {
|
|
23
|
-
default: {
|
|
24
|
-
maxTimeToFirstByteMs: 10000,
|
|
25
|
-
maxLoadTimeMs: 120000,
|
|
26
|
-
timeoutRetry: {
|
|
27
|
-
maxNumRetry: 10,
|
|
28
|
-
retryDelayMs: 0,
|
|
29
|
-
maxRetryDelayMs: 0
|
|
30
|
-
},
|
|
31
|
-
errorRetry: {
|
|
32
|
-
maxNumRetry: 10,
|
|
33
|
-
retryDelayMs: 3000,
|
|
34
|
-
maxRetryDelayMs: 8000
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default class HLSPlayer extends HTMLPlayer {
|
|
41
|
-
constructor(options, state) {
|
|
42
|
-
super(options, state);
|
|
43
|
-
this.logger.debug('hls:player:created');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
load({ src }) {
|
|
47
|
-
src = isArray(src) ? head(src) : src;
|
|
48
|
-
src = isObject(src) ? src.src : src;
|
|
49
|
-
this.logger.debug('hls:player:loading', src);
|
|
50
|
-
|
|
51
|
-
if (existy(window.Hls)) {
|
|
52
|
-
this._attachMedia(src);
|
|
53
|
-
} else {
|
|
54
|
-
this._loadLibraryAndAttachMedia(src);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
_loadLibraryAndAttachMedia(src) {
|
|
59
|
-
// use requiresjs if we can
|
|
60
|
-
if (typeof window.define === 'function' && window.define.amd) {
|
|
61
|
-
window.require.config({
|
|
62
|
-
paths: {
|
|
63
|
-
hlsjs: this.options.hlsjsURL
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
window.require(['hlsjs'], hls => {
|
|
68
|
-
window.Hls = hls;
|
|
69
|
-
this._attachMedia(src);
|
|
70
|
-
});
|
|
71
|
-
} else {
|
|
72
|
-
const script = createElement('script', { src: this.options.hlsjsURL });
|
|
73
|
-
const firstScriptTag = first(document.getElementsByTagName('script'));
|
|
74
|
-
script.onload = script.onreadystatechange = () => this._attachMedia(src);
|
|
75
|
-
|
|
76
|
-
if (!firstScriptTag.parentNode) return;
|
|
77
|
-
|
|
78
|
-
firstScriptTag.parentNode.insertBefore(script, firstScriptTag);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
_attachMedia(src) {
|
|
83
|
-
const Hls = window.Hls;
|
|
84
|
-
if (Hls.isSupported()) {
|
|
85
|
-
this.hls = new Hls(extend(HLS_OPTIONS, this.options.hls));
|
|
86
|
-
|
|
87
|
-
// if (this.options.showC2PA) {
|
|
88
|
-
// this.c2pa = new C2PA((status, data) => {
|
|
89
|
-
// switch (status) {
|
|
90
|
-
// case ValidationResult.Complete:
|
|
91
|
-
// this.bus.emit('c2painit', { status, data });
|
|
92
|
-
// break;
|
|
93
|
-
// case ValidationResult.NoData:
|
|
94
|
-
// this.bus.emit('c2painit', { status, data });
|
|
95
|
-
// break;
|
|
96
|
-
// case ValidationResult.Failed:
|
|
97
|
-
// this.bus.emit('c2painit', { status, data });
|
|
98
|
-
// if (!(data instanceof C2PAValidationError)) {
|
|
99
|
-
// this.bus.emit('c2paexception');
|
|
100
|
-
// }
|
|
101
|
-
// break;
|
|
102
|
-
// default:
|
|
103
|
-
// console.debug(`[HLS] Unrecognized status ${status}`);
|
|
104
|
-
// }
|
|
105
|
-
// });
|
|
106
|
-
|
|
107
|
-
// // The video init segment is parsing
|
|
108
|
-
// this.hls.on(Hls.Events.FRAG_PARSING_INIT_SEGMENT, (name, data) => {
|
|
109
|
-
// console.debug(`[HLS] Executed ${name} handler, data: ${data}`);
|
|
110
|
-
|
|
111
|
-
// this.c2pa.initSegment(data);
|
|
112
|
-
// });
|
|
113
|
-
|
|
114
|
-
// // The video segment is appending to buffer
|
|
115
|
-
// this.hls.on(Hls.Events.BUFFER_APPENDING, (name, data) => {
|
|
116
|
-
// console.debug(`[HLS] Executed ${name} handler, data: ${data}`);
|
|
117
|
-
|
|
118
|
-
// // Check whether buffered segment is init segment
|
|
119
|
-
// if (isEqualBuffer(data.data, data.frag.initSegment.data)) {
|
|
120
|
-
// return;
|
|
121
|
-
// }
|
|
122
|
-
|
|
123
|
-
// // TODO: c2pa.validateSegment should define own data model, not just accept hls event data
|
|
124
|
-
// data.data1 = data.data;
|
|
125
|
-
// this.c2pa.validateSegment(data, validationResult => {
|
|
126
|
-
// this.bus.emit('c2pafragment', validationResult);
|
|
127
|
-
// });
|
|
128
|
-
// });
|
|
129
|
-
// }
|
|
130
|
-
|
|
131
|
-
this.hls.loadSource(src);
|
|
132
|
-
this.hls.attachMedia(this.$el);
|
|
133
|
-
|
|
134
|
-
this.hls.on(Hls.Events.ERROR, (a, data) => {
|
|
135
|
-
this.bus.emit('error', data);
|
|
136
|
-
this.logger.error(data);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
this.hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, () => {
|
|
140
|
-
this.bus.emit('audiotrackswitched');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
this.hls.on(Hls.Events.MANIFEST_PARSED, (a, data) => {
|
|
144
|
-
if (!this.options.showSubtitles) {
|
|
145
|
-
this.hls.subtitleDisplay = false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (this.options.qualityLevel) {
|
|
149
|
-
const h = parseInt(this.options.qualityLevel, 10);
|
|
150
|
-
if (h) {
|
|
151
|
-
const level = find(data.levels, l => l.height === h);
|
|
152
|
-
if (level) {
|
|
153
|
-
this.setLevel(level);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (this.options.maxQualityLevel) {
|
|
159
|
-
this.limitLevel(this.options.maxQualityLevel);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (this.options.startLevel) {
|
|
163
|
-
const h = parseInt(this.options.startLevel, 10);
|
|
164
|
-
if (h) {
|
|
165
|
-
const idx = findIndex(data.levels, l => l.height === h);
|
|
166
|
-
this.hls.startLevel = idx;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
this.hls.on(Hls.Events.BUFFER_CREATED, () => {
|
|
172
|
-
if (this.options.isLive) {
|
|
173
|
-
this.goToLive();
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// Encryption. Token should be passed as an option or as a query parameter
|
|
178
|
-
if (this.options.aesToken) {
|
|
179
|
-
let descriptionUrl;
|
|
180
|
-
|
|
181
|
-
this.hls.config.xhrSetup = (xhr, url) => {
|
|
182
|
-
xhr.addEventListener('load', () => {
|
|
183
|
-
if (typeof xhr.response === 'string' && xhr.response.indexOf('#EXTM3U') >= 0) {
|
|
184
|
-
const lines = xhr.response.split('\n');
|
|
185
|
-
const keyLine = lines.find(line => line.indexOf('#EXT-X-KEY') === 0);
|
|
186
|
-
const keyUrl = keyLine?.split('URI="')[1].split('"')[0];
|
|
187
|
-
const urlBase = 'https://' + url.split('/')[2];
|
|
188
|
-
const finalUrl = urlBase + keyUrl;
|
|
189
|
-
|
|
190
|
-
if (keyUrl) {
|
|
191
|
-
descriptionUrl = finalUrl;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
if (url === descriptionUrl) {
|
|
197
|
-
xhr.setRequestHeader('Authorization', 'Bearer ' + this.options.aesToken);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
} else {
|
|
201
|
-
// append all query parameters to the subsequent requests
|
|
202
|
-
const query = src.split('?')[1];
|
|
203
|
-
|
|
204
|
-
if (query) {
|
|
205
|
-
this.hls.config.xhrSetup = (xhr, url) => {
|
|
206
|
-
xhr.open('GET', url + `?${query}`, true);
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
} else {
|
|
211
|
-
this.logger.error('HLS is not supported for this browser');
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
goToLive() {
|
|
216
|
-
if (!this.hls.media) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
this.logger.debug('hls:player:live');
|
|
221
|
-
this.hls.media.currentTime = this.hls.liveSyncPosition || this.hls.media.duration - 10;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
isLive() {
|
|
225
|
-
if (this.hls?.liveSyncPosition) {
|
|
226
|
-
return this.hls?.media.currentTime >= (this.hls?.liveSyncPosition - 10);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return this.hls?.media.currentTime >= (this.hls?.media.duration - 10); // Default to 10s from duration
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
getLevels() {
|
|
233
|
-
return [AUTO_LEVEL].concat(this.hls.levels);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
setLevel(level) {
|
|
237
|
-
const idx = findIndex(this.hls.levels, level);
|
|
238
|
-
this.hls.currentLevel = idx;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
limitLevel(level) {
|
|
242
|
-
const h = parseInt(level, 10);
|
|
243
|
-
if (h) {
|
|
244
|
-
const idx = findIndex(this.hls.levels, l => l.height === h);
|
|
245
|
-
this.hls.autoLevelCapping = idx;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
getLevel() {
|
|
250
|
-
return this.hls.levels[this.hls.manualLevel] || AUTO_LEVEL;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
isMultiQuality() {
|
|
254
|
-
// eslint-disable-next-line no-magic-numbers
|
|
255
|
-
return this.hls.levels.length > 1;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
getAudioTracks() {
|
|
259
|
-
return this.hls.audioTracks;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
getAudioTrack() {
|
|
263
|
-
return this.hls.audioTrack;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
getTextTracks() {
|
|
267
|
-
return this.$el.textTracks || [];
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
setAudioTrack(idx) {
|
|
271
|
-
this.hls.audioTrack = idx;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
destroy() {
|
|
275
|
-
this.hls.destroy();
|
|
276
|
-
super.destroy();
|
|
277
|
-
}
|
|
278
|
-
}
|