ovenplayer 0.10.2 → 0.10.3-3.alpha-2
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/LICENSE +1 -1
- package/README.md +39 -46
- package/dist/ovenplayer.js +1 -1
- package/dist/ovenplayer.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/fonts/seek-icons.svg +13 -13
- package/src/js/api/Api.js +231 -140
- package/src/js/api/Configurator.js +6 -3
- package/src/js/api/SupportChecker.js +9 -3
- package/src/js/api/constants.js +203 -15
- package/src/js/api/media/Manager.js +15 -106
- package/src/js/api/provider/Controller.js +5 -6
- package/src/js/api/provider/html5/Provider.js +107 -86
- package/src/js/api/provider/html5/providers/Dash.js +39 -110
- package/src/js/api/provider/html5/providers/Hls.js +139 -99
- package/src/js/api/provider/html5/providers/Html5.js +3 -1
- package/src/js/api/provider/html5/providers/WebRTC.js +207 -37
- package/src/js/api/provider/html5/providers/WebRTCLoader.js +247 -116
- package/src/js/ovenplayer.js +5 -9
- package/src/js/ovenplayer.sdk.js +5 -6
- package/src/js/utils/browser.js +6 -1
- package/src/js/utils/getTouchSection.js +23 -0
- package/src/js/utils/likeA$.js +4 -3
- package/src/js/utils/resize-sensor.js +168 -1
- package/src/js/utils/underscore.js +5 -5
- package/src/js/view/components/controls/fullScreenButton.js +22 -15
- package/src/js/view/components/controls/main.js +33 -20
- package/src/js/view/components/controls/playlistPanel.js +1 -1
- package/src/js/view/components/controls/progressBar.js +151 -76
- package/src/js/view/components/controls/settingButton.js +65 -48
- package/src/js/view/components/controls/settingPanel/audioTrackPanel.js +57 -0
- package/src/js/view/components/controls/settingPanel/captionPanel.js +1 -1
- package/src/js/view/components/controls/settingPanel/main.js +110 -80
- package/src/js/view/components/controls/settingPanel/qualityPanel.js +2 -2
- package/src/js/view/components/controls/settingPanel/sourcePanel.js +1 -1
- package/src/js/view/components/controls/settingPanel/speedPanel.js +1 -1
- package/src/js/view/components/controls/settingPanel/timeDisplayPanel.js +1 -1
- package/src/js/view/components/controls/timeDisplay.js +95 -23
- package/src/js/view/components/controls/timeDisplayTemplate.js +1 -1
- package/src/js/view/components/controls/volumeButton.js +2 -3
- package/src/js/view/components/helpers/captionViewer.js +1 -1
- package/src/js/view/components/helpers/contextPanel.js +1 -1
- package/src/js/view/components/helpers/contextPanelTemplate.js +1 -1
- package/src/js/view/components/helpers/main.js +21 -0
- package/src/js/view/components/helpers/thumbnailTemplate.js +0 -1
- package/src/js/view/engine/Templates.js +2 -0
- package/src/js/view/view.js +53 -14
- package/src/js/view/viewTemplate.js +8 -8
- package/src/stylesheet/ovenplayer.less +565 -308
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
STATE_AD_PLAYING,
|
|
11
11
|
STATE_AD_PAUSED,
|
|
12
12
|
INIT_DASH_UNSUPPORT,
|
|
13
|
-
|
|
13
|
+
INIT_DASH_FAIL,
|
|
14
14
|
ERRORS,
|
|
15
15
|
PLAYER_UNKNWON_NETWORK_ERROR,
|
|
16
16
|
CONTENT_LEVEL_CHANGED,
|
|
@@ -43,40 +43,26 @@ const Dash = function (element, playerConfig, adTagUrl) {
|
|
|
43
43
|
|
|
44
44
|
try {
|
|
45
45
|
|
|
46
|
-
if (dashjs.Version < "
|
|
46
|
+
if (dashjs.Version < "3.0.0") {
|
|
47
47
|
throw ERRORS.codes[INIT_DASH_UNSUPPORT];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const coveredSetAutoSwitchQualityFor = function (isAuto) {
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
video: isAuto
|
|
58
|
-
}
|
|
52
|
+
dash.updateSettings({
|
|
53
|
+
streaming: {
|
|
54
|
+
abr: {
|
|
55
|
+
autoSwitchBitrate: {
|
|
56
|
+
video: isAuto
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
dash.setAutoSwitchQualityFor("video", isAuto);
|
|
64
|
-
} else {
|
|
65
|
-
dash.setAutoSwitchQualityFor(isAuto);
|
|
66
|
-
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
67
61
|
};
|
|
68
62
|
|
|
69
63
|
const coveredGetAutoSwitchQualityFor = function () {
|
|
70
|
-
let result = "";
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
result = dash.getSettings().streaming.abr.autoSwitchBitrate.video;
|
|
74
|
-
} else if (dashjs.Version > "2.9.0") {
|
|
75
|
-
result = dash.getAutoSwitchQualityFor("video");
|
|
76
|
-
} else {
|
|
77
|
-
result = dash.getAutoSwitchQualityFor();
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
65
|
+
return dash.getSettings().streaming.abr.autoSwitchBitrate.video;
|
|
80
66
|
};
|
|
81
67
|
|
|
82
68
|
const liveDelayReducingCallback = function () {
|
|
@@ -124,122 +110,71 @@ const Dash = function (element, playerConfig, adTagUrl) {
|
|
|
124
110
|
|
|
125
111
|
OvenPlayerConsole.log("DASH : Attach File : ", source, "lastPlayPosition : " + lastPlayPosition);
|
|
126
112
|
|
|
127
|
-
that.trigger(DASH_PREPARED, dash);
|
|
128
|
-
|
|
129
113
|
coveredSetAutoSwitchQualityFor(true);
|
|
130
114
|
sourceOfFile = source.file;
|
|
131
115
|
|
|
132
|
-
dash.off(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
|
|
116
|
+
// dash.off(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
|
|
133
117
|
|
|
134
118
|
if (source.lowLatency === true) {
|
|
135
119
|
|
|
136
120
|
prevLLLiveDuration = null;
|
|
137
121
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
streaming: {
|
|
142
|
-
lowLatencyEnabled: source.lowLatency
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
|
|
148
|
-
dash.setLowLatencyEnabled(source.lowLatency);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (playerConfig.getConfig().lowLatencyMpdLiveDelay && typeof(playerConfig.getConfig().lowLatencyMpdLiveDelay) === 'number') {
|
|
152
|
-
|
|
153
|
-
if (dashjs.Version >= '3.0.0') {
|
|
154
|
-
|
|
155
|
-
dash.updateSettings({
|
|
156
|
-
streaming: {
|
|
157
|
-
liveDelay: playerConfig.getConfig().lowLatencyMpdLiveDelay
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
dash.setLiveDelay(playerConfig.getConfig().lowLatencyMpdLiveDelay);
|
|
122
|
+
dash.updateSettings({
|
|
123
|
+
streaming: {
|
|
124
|
+
lowLatencyEnabled: source.lowLatency
|
|
162
125
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
dash.on(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
|
|
166
|
-
|
|
167
|
-
} else {
|
|
126
|
+
});
|
|
168
127
|
|
|
169
|
-
if (
|
|
128
|
+
if (playerConfig.getConfig().lowLatencyMpdLiveDelay && typeof(playerConfig.getConfig().lowLatencyMpdLiveDelay) === 'number') {
|
|
170
129
|
|
|
171
130
|
dash.updateSettings({
|
|
172
131
|
streaming: {
|
|
173
|
-
|
|
174
|
-
liveDelay: undefined
|
|
132
|
+
liveDelay: playerConfig.getConfig().lowLatencyMpdLiveDelay
|
|
175
133
|
}
|
|
176
134
|
});
|
|
177
|
-
|
|
178
|
-
} else {
|
|
179
|
-
|
|
180
|
-
dash.setLowLatencyEnabled(false);
|
|
181
|
-
dash.setLiveDelay();
|
|
182
135
|
}
|
|
183
136
|
|
|
184
|
-
|
|
137
|
+
// dash.on(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
|
|
185
138
|
|
|
186
|
-
|
|
139
|
+
} else {
|
|
187
140
|
|
|
188
141
|
dash.updateSettings({
|
|
189
|
-
|
|
190
|
-
|
|
142
|
+
streaming: {
|
|
143
|
+
lowLatencyEnabled: false,
|
|
144
|
+
liveDelay: undefined
|
|
191
145
|
}
|
|
192
146
|
});
|
|
193
147
|
|
|
194
|
-
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
dash.updateSettings({
|
|
151
|
+
debug: {
|
|
152
|
+
logLevel: dashjs.Debug.LOG_LEVEL_NONE
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
let dashConfigFromPlayerConfig = playerConfig.getConfig().dashConfig;
|
|
195
157
|
|
|
196
|
-
|
|
158
|
+
if (dashConfigFromPlayerConfig) {
|
|
159
|
+
dash.updateSettings(dashConfigFromPlayerConfig);
|
|
197
160
|
}
|
|
198
161
|
|
|
162
|
+
that.trigger(DASH_PREPARED, dash);
|
|
163
|
+
|
|
199
164
|
dash.attachSource(sourceOfFile);
|
|
200
165
|
|
|
201
166
|
seekPosition_sec = lastPlayPosition;
|
|
202
|
-
|
|
203
167
|
});
|
|
204
168
|
|
|
205
169
|
superPlay_func = that.super('play');
|
|
206
170
|
superDestroy_func = that.super('destroy');
|
|
207
171
|
OvenPlayerConsole.log("DASH PROVIDER LOADED.");
|
|
208
172
|
|
|
209
|
-
let loadingRetryCount = playerConfig.getConfig().loadingRetryCount;
|
|
210
|
-
|
|
211
173
|
dash.on(dashjs.MediaPlayer.events.ERROR, function (error) {
|
|
212
174
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
error.error.code === dashjs.MediaPlayer.errors.DOWNLOAD_ERROR_ID_MANIFEST_CODE ||
|
|
217
|
-
error.error.code === dashjs.MediaPlayer.errors.MANIFEST_LOADER_LOADING_FAILURE_ERROR_CODE
|
|
218
|
-
)) {
|
|
219
|
-
|
|
220
|
-
if (loadingRetryCount > 0) {
|
|
221
|
-
|
|
222
|
-
that.setState(STATE_LOADING);
|
|
223
|
-
|
|
224
|
-
if (loadRetryer) {
|
|
225
|
-
clearTimeout(loadRetryer);
|
|
226
|
-
loadRetryer = null;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
loadingRetryCount = loadingRetryCount - 1;
|
|
230
|
-
|
|
231
|
-
loadRetryer = setTimeout(function () {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
dash.attachSource(sourceOfFile);
|
|
235
|
-
}, 1000);
|
|
236
|
-
} else {
|
|
237
|
-
|
|
238
|
-
let tempError = ERRORS.codes[PLAYER_UNKNWON_NETWORK_ERROR];
|
|
239
|
-
tempError.error = error;
|
|
240
|
-
errorTrigger(tempError, that);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
175
|
+
let tempError = ERRORS.codes[PLAYER_UNKNWON_NETWORK_ERROR];
|
|
176
|
+
tempError.error = error;
|
|
177
|
+
errorTrigger(tempError, that);
|
|
243
178
|
});
|
|
244
179
|
|
|
245
180
|
dash.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_REQUESTED, function (event) {
|
|
@@ -288,12 +223,6 @@ const Dash = function (element, playerConfig, adTagUrl) {
|
|
|
288
223
|
dash.seek(seekPosition_sec);
|
|
289
224
|
}
|
|
290
225
|
|
|
291
|
-
// if (playerConfig.isAutoStart() && !runedAutoStart) {
|
|
292
|
-
// OvenPlayerConsole.log("DASH : AUTOPLAY()!");
|
|
293
|
-
// that.play();
|
|
294
|
-
// runedAutoStart = true;
|
|
295
|
-
// }
|
|
296
|
-
|
|
297
226
|
});
|
|
298
227
|
|
|
299
228
|
that.play = (mutedPlay) => {
|
|
@@ -344,7 +273,7 @@ const Dash = function (element, playerConfig, adTagUrl) {
|
|
|
344
273
|
if (error && error.code && error.code === INIT_DASH_UNSUPPORT) {
|
|
345
274
|
throw error;
|
|
346
275
|
} else {
|
|
347
|
-
let tempError = ERRORS.codes[
|
|
276
|
+
let tempError = ERRORS.codes[INIT_DASH_FAIL];
|
|
348
277
|
tempError.error = error;
|
|
349
278
|
throw tempError;
|
|
350
279
|
}
|
|
@@ -6,18 +6,17 @@ import {errorTrigger} from "api/provider/utils";
|
|
|
6
6
|
import {
|
|
7
7
|
PROVIDER_HLS,
|
|
8
8
|
PLAYER_STATE, STATE_IDLE, STATE_LOADING,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
PLAYER_UNKNWON_ERROR,
|
|
9
|
+
ERRORS,
|
|
10
|
+
INIT_HLSJS_FAIL,
|
|
11
|
+
HLS_PREPARED,
|
|
12
|
+
HLS_DESTROYED,
|
|
15
13
|
PLAYER_UNKNWON_NETWORK_ERROR,
|
|
16
|
-
PLAYER_UNKNWON_DECODE_ERROR,
|
|
17
14
|
PLAYER_BAD_REQUEST_ERROR,
|
|
18
15
|
PLAYER_AUTH_FAILED_ERROR,
|
|
19
|
-
PLAYER_NOT_ACCEPTABLE_ERROR
|
|
20
|
-
} from "
|
|
16
|
+
PLAYER_NOT_ACCEPTABLE_ERROR, STATE_PLAYING, CONTENT_LEVEL_CHANGED, AUDIO_TRACK_CHANGED
|
|
17
|
+
} from "api/constants";
|
|
18
|
+
|
|
19
|
+
import sizeHumanizer from "utils/sizeHumanizer";
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* @brief hlsjs provider extended core.
|
|
@@ -35,13 +34,10 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
35
34
|
let isManifestLoaded = false;
|
|
36
35
|
let firstLoaded = false;
|
|
37
36
|
|
|
38
|
-
|
|
39
37
|
try {
|
|
40
38
|
|
|
41
39
|
let hlsConfig = {
|
|
42
|
-
debug: false
|
|
43
|
-
maxBufferLength: 20,
|
|
44
|
-
maxMaxBufferLength: 30
|
|
40
|
+
debug: false
|
|
45
41
|
};
|
|
46
42
|
|
|
47
43
|
let hlsConfigFromPlayerConfig = playerConfig.getConfig().hlsConfig;
|
|
@@ -53,6 +49,23 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
|
|
52
|
+
if (playerConfig.getConfig().licenseCustomHeader) {
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const licenseXhrSetup = function (xhr, url, keyContext, licenseChallenge) {
|
|
56
|
+
|
|
57
|
+
xhr.withCredentials = true;
|
|
58
|
+
|
|
59
|
+
xhr.open('POST', url, true);
|
|
60
|
+
|
|
61
|
+
xhr.setRequestHeader(playerConfig.getConfig().licenseCustomHeader.key, playerConfig.getConfig().licenseCustomHeader.value);
|
|
62
|
+
|
|
63
|
+
return Promise.resolve({xhr, licenseChallenge});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
hlsConfig.licenseXhrSetup = licenseXhrSetup
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
hls = new Hls(hlsConfig);
|
|
57
70
|
|
|
58
71
|
window.op_hls = hls;
|
|
@@ -70,10 +83,13 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
70
83
|
seeking: false,
|
|
71
84
|
state: STATE_IDLE,
|
|
72
85
|
buffer: 0,
|
|
86
|
+
dvrWindow: 0,
|
|
73
87
|
framerate: 0,
|
|
74
88
|
currentQuality: -1,
|
|
75
|
-
currentSource: -1,
|
|
76
89
|
qualityLevels: [],
|
|
90
|
+
currentAudioTrack: -1,
|
|
91
|
+
audioTracks: [],
|
|
92
|
+
currentSource: -1,
|
|
77
93
|
sources: [],
|
|
78
94
|
adTagUrl: adTagUrl
|
|
79
95
|
};
|
|
@@ -82,13 +98,42 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
82
98
|
|
|
83
99
|
OvenPlayerConsole.log("HLS : onExtendedLoad : ", source, "lastPlayPosition : " + lastPlayPosition);
|
|
84
100
|
|
|
85
|
-
|
|
101
|
+
that.trigger(HLS_PREPARED, hls);
|
|
86
102
|
|
|
87
103
|
hls.loadSource(source.file);
|
|
88
104
|
|
|
89
105
|
hls.once(Hls.Events.MANIFEST_LOADED, function (event, data) {
|
|
90
106
|
|
|
91
107
|
isManifestLoaded = true;
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < hls.levels.length; i++) {
|
|
110
|
+
|
|
111
|
+
let qualityLevel = hls.levels[i];
|
|
112
|
+
|
|
113
|
+
spec.qualityLevels.push({
|
|
114
|
+
bitrate: qualityLevel.bitrate,
|
|
115
|
+
height: qualityLevel.height,
|
|
116
|
+
width: qualityLevel.width,
|
|
117
|
+
index: i,
|
|
118
|
+
label: qualityLevel.width + "x" + qualityLevel.height + ", " + sizeHumanizer(qualityLevel.bitrate, true, "bps")
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
spec.currentQuality = hls.firstLevel;
|
|
123
|
+
|
|
124
|
+
for (let i = 0; i < hls.audioTracks.length; i++) {
|
|
125
|
+
|
|
126
|
+
let audioTrack = hls.audioTracks[i];
|
|
127
|
+
|
|
128
|
+
spec.audioTracks.push({
|
|
129
|
+
index: audioTrack.id,
|
|
130
|
+
label: audioTrack.name
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (audioTrack.default === true) {
|
|
134
|
+
spec.currentAudioTrack = audioTrack.id;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
92
137
|
});
|
|
93
138
|
|
|
94
139
|
hls.once(Hls.Events.LEVEL_LOADED, function (event, data) {
|
|
@@ -110,6 +155,32 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
110
155
|
}
|
|
111
156
|
});
|
|
112
157
|
|
|
158
|
+
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {
|
|
159
|
+
|
|
160
|
+
spec.currentQuality = data.level;
|
|
161
|
+
|
|
162
|
+
that.trigger(CONTENT_LEVEL_CHANGED, {
|
|
163
|
+
isAuto: hls.autoLevelEnabled,
|
|
164
|
+
currentQuality: spec.currentQuality,
|
|
165
|
+
type: "render"
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, function (event, data) {
|
|
170
|
+
|
|
171
|
+
spec.currentAudioTrack = data.id;
|
|
172
|
+
that.trigger(AUDIO_TRACK_CHANGED, {
|
|
173
|
+
currentAudioTrack: spec.currentAudioTrack
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
hls.on(Hls.Events.LEVEL_UPDATED, function (event, data) {
|
|
178
|
+
if (data && data.details) {
|
|
179
|
+
spec.dvrWindow = data.details.totalduration;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
});
|
|
183
|
+
|
|
113
184
|
hls.on(Hls.Events.ERROR, function (event, data) {
|
|
114
185
|
|
|
115
186
|
if (data && data.networkDetails && data.networkDetails.status === 202) {
|
|
@@ -132,89 +203,27 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
132
203
|
|
|
133
204
|
}, 1000);
|
|
134
205
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
hls.once(Hls.Events.FRAG_LOADING, function () {
|
|
138
|
-
that.setState(STATE_LOADING);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
|
142
|
-
|
|
143
|
-
if (!data.fatal) {
|
|
144
|
-
// do nothing when non fatal media error. hlsjs will recover it automatically.
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (loadingRetryCount > 0) {
|
|
150
|
-
|
|
151
|
-
that.setState(STATE_LOADING);
|
|
152
|
-
|
|
153
|
-
if (loadRetryer) {
|
|
154
|
-
clearTimeout(loadRetryer);
|
|
155
|
-
loadRetryer = null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
loadingRetryCount = loadingRetryCount - 1;
|
|
159
|
-
|
|
160
|
-
if (data.type === Hls.ErrorTypes.NETWORK_ERROR) {
|
|
161
|
-
|
|
162
|
-
loadRetryer = setTimeout(function () {
|
|
163
|
-
|
|
164
|
-
that.stop();
|
|
165
|
-
|
|
166
|
-
if (hls) {
|
|
167
|
-
|
|
168
|
-
hls.stopLoad();
|
|
169
|
-
hls.startLoad();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
that.play();
|
|
173
|
-
}, 1000);
|
|
174
|
-
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
|
175
|
-
|
|
176
|
-
loadRetryer = setTimeout(function () {
|
|
177
|
-
|
|
178
|
-
if (hls) {
|
|
179
|
-
|
|
180
|
-
hls.recoverMediaError();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
that.play();
|
|
184
|
-
}, 1000);
|
|
185
|
-
} else {
|
|
186
|
-
|
|
187
|
-
loadRetryer = setTimeout(function () {
|
|
188
|
-
|
|
189
|
-
that.stop();
|
|
190
|
-
|
|
191
|
-
if (hls) {
|
|
192
|
-
|
|
193
|
-
hls.stopLoad();
|
|
194
|
-
hls.startLoad();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
that.play();
|
|
198
|
-
}, 1000);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
} else {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
202
208
|
|
|
203
|
-
|
|
209
|
+
if (!data.fatal) {
|
|
210
|
+
// do nothing when non fatal error. hlsjs will recover it automatically.
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
204
213
|
|
|
205
|
-
|
|
206
|
-
errorType = PLAYER_BAD_REQUEST_ERROR;
|
|
207
|
-
} else if (data && data.networkDetails && data.networkDetails.status === 403) {
|
|
208
|
-
errorType = PLAYER_AUTH_FAILED_ERROR;
|
|
209
|
-
} else if (data && data.networkDetails && data.networkDetails.status === 406) {
|
|
210
|
-
errorType = PLAYER_NOT_ACCEPTABLE_ERROR;
|
|
211
|
-
}
|
|
214
|
+
let errorType = PLAYER_UNKNWON_NETWORK_ERROR;
|
|
212
215
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
if (data && data.networkDetails && data.networkDetails.status === 400) {
|
|
217
|
+
errorType = PLAYER_BAD_REQUEST_ERROR;
|
|
218
|
+
} else if (data && data.networkDetails && data.networkDetails.status === 403) {
|
|
219
|
+
errorType = PLAYER_AUTH_FAILED_ERROR;
|
|
220
|
+
} else if (data && data.networkDetails && data.networkDetails.status === 406) {
|
|
221
|
+
errorType = PLAYER_NOT_ACCEPTABLE_ERROR;
|
|
217
222
|
}
|
|
223
|
+
|
|
224
|
+
let tempError = ERRORS.codes[errorType];
|
|
225
|
+
tempError.error = data.details;
|
|
226
|
+
errorTrigger(tempError, that);
|
|
218
227
|
});
|
|
219
228
|
|
|
220
229
|
that.on(PLAYER_STATE, function (data) {
|
|
@@ -234,11 +243,38 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
234
243
|
});
|
|
235
244
|
});
|
|
236
245
|
|
|
237
|
-
|
|
238
|
-
OvenPlayerConsole.log("HLS PROVIDER LOADED.");
|
|
246
|
+
that.setCurrentQuality = (qualityIndex) => {
|
|
239
247
|
|
|
240
|
-
|
|
248
|
+
hls.currentLevel = qualityIndex;
|
|
249
|
+
spec.currentQuality = qualityIndex;
|
|
250
|
+
|
|
251
|
+
return spec.currentQuality;
|
|
252
|
+
};
|
|
241
253
|
|
|
254
|
+
that.isAutoQuality = () => {
|
|
255
|
+
return hls.autoLevelEnabled;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
that.setAutoQuality = (isAuto) => {
|
|
259
|
+
if (isAuto) {
|
|
260
|
+
hls.currentLevel = -1;
|
|
261
|
+
} else {
|
|
262
|
+
hls.currentLevel = hls.currentLevel;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
that.setCurrentAudioTrack = (audioTrackIndex) => {
|
|
267
|
+
hls.audioTrack = audioTrackIndex;
|
|
268
|
+
spec.currentAudioTrack = audioTrackIndex;
|
|
269
|
+
|
|
270
|
+
return spec.currentAudioTrack;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
that.getDuration = () => {
|
|
274
|
+
return element.duration;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
superStop_func = that.super('stop');
|
|
242
278
|
that.stop = () => {
|
|
243
279
|
|
|
244
280
|
if (loadRetryer) {
|
|
@@ -254,6 +290,7 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
254
290
|
superStop_func();
|
|
255
291
|
};
|
|
256
292
|
|
|
293
|
+
superDestroy_func = that.super('destroy');
|
|
257
294
|
that.destroy = () => {
|
|
258
295
|
|
|
259
296
|
if (loadRetryer) {
|
|
@@ -265,14 +302,17 @@ const HlsProvider = function (element, playerConfig, adTagUrl) {
|
|
|
265
302
|
if (hls) {
|
|
266
303
|
|
|
267
304
|
hls.destroy();
|
|
305
|
+
that.trigger(HLS_DESTROYED);
|
|
268
306
|
}
|
|
269
307
|
|
|
270
308
|
hls = null;
|
|
271
|
-
OvenPlayerConsole.log("HLS : PROVIDER
|
|
309
|
+
OvenPlayerConsole.log("HLS : PROVIDER DESTROYED.");
|
|
272
310
|
superDestroy_func();
|
|
273
311
|
};
|
|
312
|
+
|
|
313
|
+
OvenPlayerConsole.log("HLS PROVIDER LOADED.");
|
|
274
314
|
} catch (error) {
|
|
275
|
-
let tempError = ERRORS.codes[
|
|
315
|
+
let tempError = ERRORS.codes[INIT_HLSJS_FAIL];
|
|
276
316
|
tempError.error = error;
|
|
277
317
|
throw tempError;
|
|
278
318
|
}
|
|
@@ -26,8 +26,10 @@ const Html5 = function(element, playerConfig, adTagUrl){
|
|
|
26
26
|
buffer : 0,
|
|
27
27
|
framerate : 0,
|
|
28
28
|
currentQuality : -1,
|
|
29
|
-
currentSource : -1,
|
|
30
29
|
qualityLevels : [],
|
|
30
|
+
currentAudioTrack: -1,
|
|
31
|
+
audioTracks: [],
|
|
32
|
+
currentSource : -1,
|
|
31
33
|
sources : [],
|
|
32
34
|
adTagUrl : adTagUrl
|
|
33
35
|
};
|