ravnur-player-public 3.4.4 → 3.4.5
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 +10 -6
- 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/html.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import BasePlayer from './base';
|
|
2
|
-
|
|
3
|
-
import events from '../events';
|
|
4
|
-
|
|
5
|
-
import { createElement, append, each, find, first, isArray, uidGenerator, findIndex } from '../utils';
|
|
6
|
-
import isIOS from '../helpers/isiOS';
|
|
7
|
-
import {
|
|
8
|
-
UNTRANSLATED_TIMEDATA_STATUS
|
|
9
|
-
} from '../config/statuses';
|
|
10
|
-
|
|
11
|
-
export default class HtmlPlayer extends BasePlayer {
|
|
12
|
-
$el;
|
|
13
|
-
source;
|
|
14
|
-
_levels = [];
|
|
15
|
-
_currentLevel = null;
|
|
16
|
-
|
|
17
|
-
constructor(options, state) {
|
|
18
|
-
super(options, state);
|
|
19
|
-
this.logger.debug('html:player:creating');
|
|
20
|
-
|
|
21
|
-
let tag = 'video';
|
|
22
|
-
const params = { id: uidGenerator(), tabindex: -1 };
|
|
23
|
-
|
|
24
|
-
if ( options.disableAutoFullScreenOnIOS ) {
|
|
25
|
-
params['webkit-playsinline'] = true;
|
|
26
|
-
params.playsinline = true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if ( options.isMobile ) {
|
|
30
|
-
params.preload = 'metadata';
|
|
31
|
-
// use audio for audio. fix for ios safari RAV-2462
|
|
32
|
-
tag = options.isAudio ? 'audio' : 'video';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** @type {HTMLMediaElement} */
|
|
36
|
-
// use video also for audio. fix for opera. RAV-412
|
|
37
|
-
this.$el = createElement(tag, params);
|
|
38
|
-
|
|
39
|
-
each(events, type => {
|
|
40
|
-
this.addEvent(this.$el, type, event => {
|
|
41
|
-
this.logger.debug('triggered event', type);
|
|
42
|
-
this.bus.emit(type, event);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
this.handleFullscreenChanging = this.handleFullscreenChanging.bind(this);
|
|
47
|
-
this.handleWebkitEndFullscreen = this.handleWebkitEndFullscreen.bind(this);
|
|
48
|
-
|
|
49
|
-
if (isIOS()) {
|
|
50
|
-
this.bus.on('fullscreenchanging', this.handleFullscreenChanging);
|
|
51
|
-
}
|
|
52
|
-
this.logger.debug('html:player:created');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
load({type, src, cc}) {
|
|
56
|
-
let options = { type, src };
|
|
57
|
-
// i hate opera, safari, iOS
|
|
58
|
-
if (this.options.isMobile && type === 'audio/mp3') {
|
|
59
|
-
options = { src };
|
|
60
|
-
}
|
|
61
|
-
if ( isArray(src) ) {
|
|
62
|
-
this._levels = src;
|
|
63
|
-
if (this.options.qualityLevel) {
|
|
64
|
-
const h = parseInt(this.options.qualityLevel, 10);
|
|
65
|
-
if (h) {
|
|
66
|
-
this._currentLevel = find(this._levels, l => parseInt(l.name, 10) === h);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
this._currentLevel = this._currentLevel || find(this._levels, lvl => lvl.default);
|
|
70
|
-
this._currentLevel = this._currentLevel || first(this._levels);
|
|
71
|
-
options.src = this._currentLevel.src;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.logger.debug('html:player:loading', src);
|
|
75
|
-
this.source = createElement('source', options);
|
|
76
|
-
|
|
77
|
-
this.source.addEventListener('error', (e) => {
|
|
78
|
-
this.bus.emit('error', e);
|
|
79
|
-
this.logger.error(e);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
append(this.$el, this.source);
|
|
83
|
-
|
|
84
|
-
if (isIOS()) {
|
|
85
|
-
each(cc, (track) => {
|
|
86
|
-
if (track.state !== UNTRANSLATED_TIMEDATA_STATUS && track.type !== 'json') {
|
|
87
|
-
append(this.$el, createElement('track', track));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (this.$el.audioTracks) {
|
|
93
|
-
this.$el.audioTracks.onchange = () => {
|
|
94
|
-
this.bus.emit('audiotrackswitched');
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.$el.addEventListener('webkitendfullscreen', this.handleWebkitEndFullscreen);
|
|
99
|
-
if (isIOS()) {
|
|
100
|
-
this.bus.once('loadeddata', () => {
|
|
101
|
-
const textTracks = this.getTextTracks();
|
|
102
|
-
if (textTracks instanceof TextTrackList) {
|
|
103
|
-
textTracks.addEventListener('change', () => {
|
|
104
|
-
const tt = find(textTracks, (tt) => tt.mode === 'showing');
|
|
105
|
-
if (tt) {
|
|
106
|
-
this.bus.emit('cclang', tt.language);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
this.handleWebkitEndFullscreen();
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
getLevels() {
|
|
116
|
-
return this._levels;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
setLevel(level) {
|
|
120
|
-
const currentTime = this.$el.currentTime;
|
|
121
|
-
const paused = this.$el.paused;
|
|
122
|
-
this._currentLevel = level;
|
|
123
|
-
this.$el.pause();
|
|
124
|
-
this.source.src = level.src;
|
|
125
|
-
|
|
126
|
-
this.bus.once('loadedmetadata', () => {
|
|
127
|
-
this.$el.currentTime = currentTime;
|
|
128
|
-
|
|
129
|
-
if (!paused) {
|
|
130
|
-
this.$el.play();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
});
|
|
134
|
-
this.$el.currentTime = currentTime;
|
|
135
|
-
this.$el.load();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setPlaybackRate(rate) {
|
|
139
|
-
this.$el.playbackRate = rate;
|
|
140
|
-
this.$el.defaultPlaybackRate = rate;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
getLevel() {
|
|
144
|
-
return this._currentLevel;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
getElement() {
|
|
148
|
-
return this.$el;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getBufferedPercent() {
|
|
152
|
-
const target = this.$el;
|
|
153
|
-
if (target && target.buffered && target.buffered.length > 0 && target.buffered.end && target.duration) {
|
|
154
|
-
return target.buffered.end(target.buffered.length - 1) / target.duration;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return 0;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
getAudioTrack() {
|
|
161
|
-
return findIndex(this.getAudioTracks(), (track) => track.enabled);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
getAudioTracks() {
|
|
165
|
-
return this.$el.audioTracks || [];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
setAudioTrack(idx) {
|
|
169
|
-
each(this.getAudioTracks(), (track, index) => {
|
|
170
|
-
if (track && typeof track === 'object') {
|
|
171
|
-
track.enabled = index == idx;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
getTextTracks() {
|
|
177
|
-
return this.$el.textTracks || [];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
handleFullscreenChanging(flag) {
|
|
181
|
-
const lang = flag !== true ? this.state.getCCLang() : '__';
|
|
182
|
-
this._textTrackWalker((track) => track.language === lang ? 'showing' : 'disabled');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
handleWebkitEndFullscreen() {
|
|
186
|
-
this.handleFullscreenChanging(this.$el.webkitDisplayingFullscreen);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
_textTrackWalker(modeFiller) {
|
|
190
|
-
each(this.getTextTracks(), (track) => {
|
|
191
|
-
if (track && typeof track === 'object') {
|
|
192
|
-
track.mode = modeFiller(track);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
destroy() {
|
|
198
|
-
this.$el.removeEventListener('webkitendfullscreen', this.handleWebkitEndFullscreen);
|
|
199
|
-
this.bus.off('fullscreenchanging', this.handleFullscreenChanging);
|
|
200
|
-
super.destroy();
|
|
201
|
-
this.$el.parentNode.removeChild(this.$el);
|
|
202
|
-
this.$el = null;
|
|
203
|
-
this.source = null;
|
|
204
|
-
}
|
|
205
|
-
}
|
package/src/players/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import HtmlPlayer from './html';
|
|
3
|
-
import HLSPlayer from './hls';
|
|
4
|
-
import FlashPlayer from './flash';
|
|
5
|
-
import ShakaPlayer from './shaka';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
existy,
|
|
9
|
-
isFunction,
|
|
10
|
-
contains
|
|
11
|
-
} from '../utils';
|
|
12
|
-
|
|
13
|
-
import type { Player$CombineOptions } from '../types/Options';
|
|
14
|
-
|
|
15
|
-
const CODEC = 'video/mp4; codecs=avc1.42E01E,mp4a.40.2';
|
|
16
|
-
const HLS_TYPES = [ 'application/x-mpegURL', 'vnd.apple.mpegURL', 'application/vnd.apple.mpegurl' ];
|
|
17
|
-
|
|
18
|
-
export const HLS_TYPE = 'HLS';
|
|
19
|
-
export const FLASH_TYPE = 'Flash';
|
|
20
|
-
export const HTML5_TYPE = 'HTML5';
|
|
21
|
-
export const SHAKA_TYPE = 'Shaka';
|
|
22
|
-
|
|
23
|
-
const MAP = {};
|
|
24
|
-
MAP[HLS_TYPE] = HLSPlayer;
|
|
25
|
-
MAP[FLASH_TYPE] = FlashPlayer;
|
|
26
|
-
MAP[HTML5_TYPE] = HtmlPlayer;
|
|
27
|
-
MAP[SHAKA_TYPE] = ShakaPlayer;
|
|
28
|
-
|
|
29
|
-
export default function createInstance(options: $Shape<Player$CombineOptions>, state) {
|
|
30
|
-
const type = getPlayerType(options);
|
|
31
|
-
const Player = MAP[type];
|
|
32
|
-
return new Player(options, state);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function getPlayerType(opts: $Shape<Player$CombineOptions>) {
|
|
36
|
-
const {type, logger} = opts;
|
|
37
|
-
|
|
38
|
-
if (opts.useHTMLPlayer) {
|
|
39
|
-
logger.debug('Using html player for type: ', type);
|
|
40
|
-
return HTML5_TYPE;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (_canUseMediaSource() && (opts.useHLSJSPlayer || opts.isLive)) {
|
|
44
|
-
logger.debug('Using hlsjs player for type: ', type);
|
|
45
|
-
return HLS_TYPE;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
logger.debug('Using shaka player for type: ', type);
|
|
49
|
-
return SHAKA_TYPE;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function isHLS(type: string) {
|
|
53
|
-
return contains(HLS_TYPES, type);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _canUseMediaSource() {
|
|
57
|
-
const ms = window.ManagedMediaSource || window.MediaSource || window.WebKitMediaSource;
|
|
58
|
-
return existy(ms) && isFunction(ms.isTypeSupported) && ms.isTypeSupported(CODEC);
|
|
59
|
-
}
|
package/src/players/shaka.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import isiOS from '../helpers/isiOS';
|
|
2
|
-
import {
|
|
3
|
-
first,
|
|
4
|
-
createElement,
|
|
5
|
-
isArray,
|
|
6
|
-
isObject,
|
|
7
|
-
head
|
|
8
|
-
} from '../utils';
|
|
9
|
-
import HtmlPlayer from './html';
|
|
10
|
-
|
|
11
|
-
const AUTO_LEVEL = { name: 'Auto' };
|
|
12
|
-
|
|
13
|
-
export default class ShakaPlayer extends HtmlPlayer {
|
|
14
|
-
constructor(options, state) {
|
|
15
|
-
super(options, state);
|
|
16
|
-
this.logger.debug('shaka:player:created');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
load({ src, type }) {
|
|
20
|
-
src = isArray(src) ? head(src) : src;
|
|
21
|
-
src = isObject(src) ? src.src : src;
|
|
22
|
-
|
|
23
|
-
// If the source is a DASH stream
|
|
24
|
-
// and the device is an iOS device, we need to convert it to HLS
|
|
25
|
-
if (/format=mpd-time-csf/.test(src) && isiOS() && !this.options.disableAutoUrlRewrite) {
|
|
26
|
-
type = 'application/x-mpegurl';
|
|
27
|
-
src = src.replace('format=mpd-time-csf', 'format=m3u8-cmaf');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
this.onError = this.onError.bind(this);
|
|
31
|
-
|
|
32
|
-
this.logger.debug('shaka:player:loading', src);
|
|
33
|
-
this._loadLibraryAndAttachMedia(src, type);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
_loadLibraryAndAttachMedia(src, type) {
|
|
37
|
-
// use requiresjs if we can
|
|
38
|
-
if (typeof window.define === 'function' && window.define.amd) {
|
|
39
|
-
window.require.config({
|
|
40
|
-
paths: {
|
|
41
|
-
shakajs: this.options.shakaURL
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
window.require(['shakajs'], shaka => {
|
|
46
|
-
window.shaka = shaka;
|
|
47
|
-
this._attachMedia(src, type);
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
const script = createElement('script', { src: this.options.shakaURL });
|
|
51
|
-
const firstScriptTag = first(document.getElementsByTagName('script'));
|
|
52
|
-
script.onload = script.onreadystatechange = () => this._attachMedia(src, type);
|
|
53
|
-
|
|
54
|
-
if (!firstScriptTag.parentNode) return;
|
|
55
|
-
|
|
56
|
-
firstScriptTag.parentNode.insertBefore(script, firstScriptTag);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async _attachMedia(src, type) {
|
|
61
|
-
let shakaOptions = this.options.shaka;
|
|
62
|
-
window.shaka.polyfill.installAll();
|
|
63
|
-
|
|
64
|
-
if (window.shaka.Player.isBrowserSupported()) {
|
|
65
|
-
this.shaka = new window.shaka.Player();
|
|
66
|
-
|
|
67
|
-
if (this.options.shaka) {
|
|
68
|
-
this.shaka.configure(this.options.shaka);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.shaka.setTextTrackVisibility(!!this.options.showSubtitles);
|
|
72
|
-
|
|
73
|
-
this.preselectQuality();
|
|
74
|
-
this.modifyRequests(src);
|
|
75
|
-
|
|
76
|
-
if (this.options.maxQualityLevel) {
|
|
77
|
-
this.limitLevel(this.options.maxQualityLevel);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
await this.configureDRM();
|
|
81
|
-
await this.shaka.attach(this.$el);
|
|
82
|
-
|
|
83
|
-
// See: https://github.com/shaka-project/shaka-player/issues/9415
|
|
84
|
-
// Can be removed after Shaka v5 release and Ravnur Player update to Shaka v5
|
|
85
|
-
const normolizedMimeType = type.toLowerCase();
|
|
86
|
-
|
|
87
|
-
await this.shaka.load(src, null, normolizedMimeType).catch(this.onError);
|
|
88
|
-
|
|
89
|
-
// Catching errors after load
|
|
90
|
-
const listener = new window.shaka.util.EventManager();
|
|
91
|
-
listener.listen(this.shaka, 'error', (e) => this.onError(e.detail));
|
|
92
|
-
|
|
93
|
-
this.shaka.configure(shakaOptions);
|
|
94
|
-
} else {
|
|
95
|
-
this.logger.error('Browser not supported!');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async configureDRM() {
|
|
100
|
-
const servers = {};
|
|
101
|
-
|
|
102
|
-
if (this.options.widevineURL) {
|
|
103
|
-
servers['com.widevine.alpha'] = this.options.widevineURL;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (this.options.playreadyURL) {
|
|
107
|
-
servers['com.microsoft.playready'] = this.options.playreadyURL;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (this.options.fairplayURL) {
|
|
111
|
-
servers['com.apple.fps.1_0'] = this.options.fairplayURL;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
this.shaka.configure({ drm: { servers } });
|
|
115
|
-
|
|
116
|
-
if (this.options.fairplayCertificateUrl) {
|
|
117
|
-
const req = await fetch(this.options.fairplayCertificateUrl);
|
|
118
|
-
const cert = await req.arrayBuffer();
|
|
119
|
-
|
|
120
|
-
this.shaka.configure('drm.advanced.com\\.apple\\.fps\\.1_0.serverCertificate', new Uint8Array(cert));
|
|
121
|
-
|
|
122
|
-
window.shaka.polyfill.PatchedMediaKeysApple.install();
|
|
123
|
-
|
|
124
|
-
const FairPlayUtils = window.shaka.util.FairPlayUtils;
|
|
125
|
-
this.shaka.getNetworkingEngine().registerRequestFilter(FairPlayUtils.ezdrmFairPlayRequest);
|
|
126
|
-
this.shaka.getNetworkingEngine().registerResponseFilter(FairPlayUtils.commonFairPlayResponse);
|
|
127
|
-
this.shaka.configure('drm.initDataTransform', FairPlayUtils.ezdrmInitDataTransform);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
onError(event) {
|
|
132
|
-
this.bus.emit('error', event);
|
|
133
|
-
this.logger.error(event);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
modifyRequests(src) {
|
|
137
|
-
this.shaka.getNetworkingEngine().registerRequestFilter((type, request) => {
|
|
138
|
-
if (type === window.shaka.net.NetworkingEngine.RequestType.KEY && this.options.aesToken) {
|
|
139
|
-
request.headers.Authorization = 'Bearer ' + this.options.aesToken;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const params = src?.split('?')[1]?.split('&');
|
|
143
|
-
|
|
144
|
-
// Append query parameters in case when token is required in the query
|
|
145
|
-
// check query parameters and if request uri don't contain it add it
|
|
146
|
-
if (params?.length) {
|
|
147
|
-
params.forEach((value) => {
|
|
148
|
-
const requestHadParams = request.uris[0]?.split('?')[1];
|
|
149
|
-
|
|
150
|
-
if (!requestHadParams) {
|
|
151
|
-
request.uris[0] += '?' + value;
|
|
152
|
-
} else if (!request.uris[0].includes(value)) {
|
|
153
|
-
request.uris[0] += '&' + value;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
preselectQuality() {
|
|
161
|
-
if (!this.options.qualityLevel) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const eventManager = new window.shaka.util.EventManager();
|
|
166
|
-
|
|
167
|
-
eventManager.listen(this.shaka, 'streaming', () => {
|
|
168
|
-
const h = parseInt(this.options.qualityLevel, 10);
|
|
169
|
-
const level = this.getLevels().find(l => l.height === h);
|
|
170
|
-
|
|
171
|
-
if (level) {
|
|
172
|
-
this.setLevel(level);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
getLevels() {
|
|
179
|
-
return [AUTO_LEVEL].concat(this.shaka.getVariantTracks());
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
setLevel(level) {
|
|
183
|
-
if (level === AUTO_LEVEL) {
|
|
184
|
-
this.shaka.configure({ abr: { enabled: true } });
|
|
185
|
-
} else {
|
|
186
|
-
this.shaka.configure({ abr: { enabled: false } });
|
|
187
|
-
this.shaka.selectVariantTrack(level, true);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
limitLevel(level) {
|
|
192
|
-
const h = parseInt(level, 10);
|
|
193
|
-
if (h) {
|
|
194
|
-
this.shaka.configure({ abr: { restrictions: { maxHeight: h } } });
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
goToLive() {
|
|
199
|
-
this.shaka.goToLive();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
isLive() {
|
|
203
|
-
return this.$el.currentTime >= this.shaka?.seekRange()?.end - 10;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
getLevel() {
|
|
207
|
-
const track = this.shaka.getVariantTracks().find(track => track.active);
|
|
208
|
-
return this.shaka.getConfiguration().abr.enabled ? AUTO_LEVEL : track;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
isMultiQuality() {
|
|
212
|
-
return this.shaka.getVariantTracks().length > 1;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
destroy() {
|
|
216
|
-
this.shaka.destroy();
|
|
217
|
-
super.destroy();
|
|
218
|
-
}
|
|
219
|
-
}
|