@clappr/hlsjs-playback 1.3.0 → 1.4.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/dist/hlsjs-playback.esm.js +20 -20
- package/dist/hlsjs-playback.external.js +20 -20
- package/dist/hlsjs-playback.external.min.js +1 -1
- package/dist/hlsjs-playback.external.min.js.map +1 -1
- package/dist/hlsjs-playback.js +20 -20
- package/dist/hlsjs-playback.min.js +7 -7
- package/dist/hlsjs-playback.min.js.map +1 -1
- package/package.json +12 -3
- package/src/hls.js +3 -3
- package/src/hls.test.js +23 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clappr/hlsjs-playback",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "HLS Playback based on hls.js",
|
|
5
5
|
"main": "./dist/hlsjs-playback.js",
|
|
6
6
|
"module": "./dist/hlsjs-playback.esm.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://github.com/clappr/hlsjs-playback",
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@clappr/core": "
|
|
39
|
+
"@clappr/core": "*",
|
|
40
40
|
"hls.js": "^1.2.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/core": "^7.14.2",
|
|
44
44
|
"@babel/preset-env": "^7.14.2",
|
|
45
|
-
"@clappr/core": "^0.
|
|
45
|
+
"@clappr/core": "^0.8.0",
|
|
46
46
|
"@rollup/plugin-babel": "^5.3.0",
|
|
47
47
|
"@rollup/plugin-commonjs": "^19.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
@@ -65,5 +65,14 @@
|
|
|
65
65
|
"commitizen": {
|
|
66
66
|
"path": "./node_modules/cz-conventional-changelog"
|
|
67
67
|
}
|
|
68
|
+
},
|
|
69
|
+
"nx": {
|
|
70
|
+
"targets": {
|
|
71
|
+
"test": {
|
|
72
|
+
"dependsOn": [
|
|
73
|
+
"^release"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
68
77
|
}
|
|
69
78
|
}
|
package/src/hls.js
CHANGED
|
@@ -196,7 +196,7 @@ export default class HlsjsPlayback extends HTML5Video {
|
|
|
196
196
|
|
|
197
197
|
_destroyHLSInstance() {
|
|
198
198
|
if (!this._hls) return
|
|
199
|
-
this.
|
|
199
|
+
this._manifestLoading = false
|
|
200
200
|
this._ccIsSetup = false
|
|
201
201
|
this._ccTracksUpdated = false
|
|
202
202
|
this._setInitialState()
|
|
@@ -217,7 +217,7 @@ export default class HlsjsPlayback extends HTML5Video {
|
|
|
217
217
|
_listenHLSEvents() {
|
|
218
218
|
if (!this._hls) return
|
|
219
219
|
this._hls.once(HLSJS.Events.MEDIA_ATTACHED, () => { this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src) })
|
|
220
|
-
this._hls.on(HLSJS.Events.
|
|
220
|
+
this._hls.on(HLSJS.Events.MANIFEST_LOADING, () => this._manifestLoading = true)
|
|
221
221
|
this._hls.on(HLSJS.Events.LEVEL_LOADED, (evt, data) => this._updatePlaybackType(evt, data))
|
|
222
222
|
this._hls.on(HLSJS.Events.LEVEL_UPDATED, (evt, data) => this._onLevelUpdated(evt, data))
|
|
223
223
|
this._hls.on(HLSJS.Events.LEVEL_SWITCHING, (evt,data) => this._onLevelSwitch(evt, data))
|
|
@@ -486,7 +486,7 @@ export default class HlsjsPlayback extends HTML5Video {
|
|
|
486
486
|
|
|
487
487
|
play() {
|
|
488
488
|
!this._hls && this._setup()
|
|
489
|
-
!this.
|
|
489
|
+
!this._manifestLoading && !this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src)
|
|
490
490
|
super.play()
|
|
491
491
|
this._startTimeUpdateTimer()
|
|
492
492
|
}
|
package/src/hls.test.js
CHANGED
|
@@ -151,13 +151,13 @@ describe('HlsjsPlayback', () => {
|
|
|
151
151
|
})
|
|
152
152
|
|
|
153
153
|
describe('_setup method', () => {
|
|
154
|
-
test('sets
|
|
154
|
+
test('sets _manifestLoading flag to false', () => {
|
|
155
155
|
const playback = new HlsjsPlayback({ src: 'http://clappr.io/foo.m3u8' })
|
|
156
|
-
expect(playback.
|
|
156
|
+
expect(playback._manifestLoading).toBeUndefined()
|
|
157
157
|
|
|
158
158
|
playback._setup()
|
|
159
159
|
|
|
160
|
-
expect(playback.
|
|
160
|
+
expect(playback._manifestLoading).toBeFalsy()
|
|
161
161
|
})
|
|
162
162
|
|
|
163
163
|
test('calls this._hls.loadSource when MEDIA_ATTACHED event is triggered and hlsPlayback.preload is true', () => {
|
|
@@ -176,15 +176,16 @@ describe('HlsjsPlayback', () => {
|
|
|
176
176
|
expect(playback._hls.loadSource).toHaveBeenCalledTimes(1)
|
|
177
177
|
})
|
|
178
178
|
|
|
179
|
-
test('updates
|
|
180
|
-
const
|
|
179
|
+
test('updates _manifestLoading flag value to true if MANIFEST_LOADING event is triggered', () => {
|
|
180
|
+
const src = 'http://clappr.io/foo.m3u8'
|
|
181
|
+
const playback = new HlsjsPlayback({ src })
|
|
181
182
|
|
|
182
|
-
expect(playback.
|
|
183
|
+
expect(playback._manifestLoading).toBeUndefined()
|
|
183
184
|
|
|
184
185
|
playback._setup()
|
|
185
|
-
playback._hls.trigger(HLSJS.Events.
|
|
186
|
+
playback._hls.trigger(HLSJS.Events.MANIFEST_LOADING, { url: src })
|
|
186
187
|
|
|
187
|
-
expect(playback.
|
|
188
|
+
expect(playback._manifestLoading).toBeTruthy()
|
|
188
189
|
})
|
|
189
190
|
|
|
190
191
|
test('calls bindCustomListeners method', () => {
|
|
@@ -241,24 +242,29 @@ describe('HlsjsPlayback', () => {
|
|
|
241
242
|
})
|
|
242
243
|
|
|
243
244
|
describe('play method', () => {
|
|
244
|
-
test('calls this._hls.loadSource if
|
|
245
|
-
|
|
245
|
+
test('calls this._hls.loadSource once if _manifestLoading flag and options.hlsPlayback.preload are falsy', () => {
|
|
246
|
+
jest.spyOn(HLSJS.prototype, 'loadSource').mockImplementation()
|
|
247
|
+
const src = 'http://clappr.io/foo.m3u8'
|
|
248
|
+
const playback = new HlsjsPlayback({ src, hlsPlayback: { preload: false } })
|
|
246
249
|
playback._setup()
|
|
247
|
-
|
|
248
|
-
playback.play()
|
|
250
|
+
playback._hls.trigger(HLSJS.Events.MEDIA_ATTACHED, { media: playback.el })
|
|
249
251
|
|
|
250
252
|
expect(playback._hls.loadSource).not.toHaveBeenCalled()
|
|
251
253
|
|
|
252
|
-
playback.options.hlsPlayback.preload = false
|
|
253
|
-
playback._manifestParsed = true
|
|
254
254
|
playback.play()
|
|
255
|
+
playback._hls.trigger(HLSJS.Events.MANIFEST_LOADING, { url: src })
|
|
255
256
|
|
|
256
|
-
expect(playback._hls.loadSource).
|
|
257
|
+
expect(playback._hls.loadSource).toHaveBeenCalledTimes(1)
|
|
257
258
|
|
|
258
|
-
|
|
259
|
+
// do not call loadSource again while loading a manifest
|
|
259
260
|
playback.play()
|
|
260
|
-
|
|
261
261
|
expect(playback._hls.loadSource).toHaveBeenCalledTimes(1)
|
|
262
|
+
|
|
263
|
+
playback._manifestLoading = false
|
|
264
|
+
playback.play()
|
|
265
|
+
|
|
266
|
+
expect(playback._hls.loadSource).toHaveBeenCalledTimes(2)
|
|
267
|
+
HLSJS.prototype.loadSource.mockRestore()
|
|
262
268
|
})
|
|
263
269
|
})
|
|
264
270
|
|