@gcorevideo/player 2.24.2 → 2.24.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/assets/big-mute-button/big-mute-button.ejs +2 -2
- package/dist/core.js +2 -2
- package/dist/index.css +418 -418
- package/dist/index.js +135 -112
- package/dist/player.d.ts +76 -30
- package/docs/api/player.bigmutebutton.md +13 -1
- package/docs/api/player.clapprstatssettings.md +51 -4
- package/docs/api/player.clapprstatssettings.runeach.md +16 -0
- package/docs/api/player.clipspluginsettings.md +1 -1
- package/docs/api/player.clipspluginsettings.text.md +1 -1
- package/docs/api/player.cmcdconfig.exportids.md +4 -0
- package/docs/api/player.cmcdconfig.md +19 -105
- package/docs/api/{player.cmcdconfig.version.md → player.cmcdconfigoptions.contentid.md} +5 -3
- package/docs/api/player.cmcdconfigoptions.md +79 -0
- package/docs/api/{player.cmcdconfigpluginsettings.md → player.cmcdconfigoptions.sessionid.md} +4 -6
- package/docs/api/player.extendedevents.md +9 -0
- package/docs/api/player.md +37 -31
- package/docs/api/player.mediacontrol.getavailableheight.md +24 -0
- package/docs/api/player.mediacontrol.md +14 -0
- package/docs/api/{player.cmcdconfig.name.md → player.posterpluginsettings.custom.md} +4 -3
- package/docs/api/player.posterpluginsettings.md +108 -7
- package/docs/api/player.posterpluginsettings.showfornoop.md +16 -0
- package/docs/api/player.posterpluginsettings.showonvideoend.md +16 -0
- package/docs/api/{player.cmcdconfig.bindevents.md → player.posterpluginsettings.url.md} +4 -7
- package/lib/Player.js +1 -1
- package/lib/index.embed.d.ts +30 -0
- package/lib/index.embed.d.ts.map +1 -0
- package/lib/index.embed.js +29 -0
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +18 -13
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +77 -83
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +6 -2
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +1 -1
- package/lib/plugins/clips/Clips.d.ts +1 -1
- package/lib/plugins/clips/Clips.d.ts.map +1 -1
- package/lib/plugins/clips/Clips.js +2 -1
- package/lib/plugins/cmcd-config/CmcdConfig.d.ts +34 -11
- package/lib/plugins/cmcd-config/CmcdConfig.d.ts.map +1 -1
- package/lib/plugins/cmcd-config/CmcdConfig.js +28 -18
- package/lib/plugins/media-control/MediaControl.d.ts +4 -0
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +6 -1
- package/lib/plugins/poster/Poster.d.ts +7 -3
- package/lib/plugins/poster/Poster.d.ts.map +1 -1
- package/lib/plugins/source-controller/SourceController.d.ts +1 -0
- package/lib/plugins/source-controller/SourceController.d.ts.map +1 -1
- package/lib/plugins/source-controller/SourceController.js +22 -9
- package/lib/testUtils.d.ts +1 -0
- package/lib/testUtils.d.ts.map +1 -1
- package/lib/testUtils.js +1 -0
- package/package.json +1 -1
- package/src/Player.ts +1 -1
- package/src/index.embed.ts +29 -0
- package/src/plugins/big-mute-button/BigMuteButton.ts +84 -108
- package/src/plugins/big-mute-button/__tests__/BigMuteButton.test.ts +86 -0
- package/src/plugins/big-mute-button/__tests__/__snapshots__/BigMuteButton.test.ts.snap +8 -0
- package/src/plugins/clappr-stats/ClapprStats.ts +5 -1
- package/src/plugins/click-to-pause/ClickToPause.ts +1 -1
- package/src/plugins/clips/Clips.ts +3 -2
- package/src/plugins/cmcd-config/CmcdConfig.ts +33 -27
- package/src/plugins/media-control/MediaControl.ts +6 -1
- package/src/plugins/poster/Poster.ts +6 -2
- package/src/plugins/source-controller/SourceController.ts +27 -9
- package/src/plugins/source-controller/__tests__/SourceController.test.ts +28 -8
- package/src/testUtils.ts +5 -1
- package/temp/player.api.json +229 -154
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.cmcdconfig.supportedversion.md +0 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Events as
|
|
2
|
+
Events as Events,
|
|
3
3
|
CorePlugin,
|
|
4
4
|
type Core as ClapprCore,
|
|
5
5
|
} from '@clappr/core'
|
|
@@ -127,6 +127,8 @@ export class SourceController extends CorePlugin {
|
|
|
127
127
|
|
|
128
128
|
private active = false
|
|
129
129
|
|
|
130
|
+
private autoPlay = false
|
|
131
|
+
|
|
130
132
|
private switching = false
|
|
131
133
|
|
|
132
134
|
private sync: SyncFn = noSync
|
|
@@ -165,10 +167,10 @@ export class SourceController extends CorePlugin {
|
|
|
165
167
|
override bindEvents() {
|
|
166
168
|
super.bindEvents()
|
|
167
169
|
|
|
168
|
-
this.listenTo(this.core,
|
|
170
|
+
this.listenTo(this.core, Events.CORE_READY, this.onCoreReady)
|
|
169
171
|
this.listenTo(
|
|
170
172
|
this.core,
|
|
171
|
-
|
|
173
|
+
Events.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
172
174
|
this.onActiveContainerChanged,
|
|
173
175
|
)
|
|
174
176
|
}
|
|
@@ -200,7 +202,7 @@ export class SourceController extends CorePlugin {
|
|
|
200
202
|
|
|
201
203
|
private bindContainerEventListeners() {
|
|
202
204
|
this.core.activePlayback.on(
|
|
203
|
-
|
|
205
|
+
Events.PLAYBACK_ERROR,
|
|
204
206
|
(error: PlaybackError) => {
|
|
205
207
|
trace(`${T} on PLAYBACK_ERROR`, {
|
|
206
208
|
error: {
|
|
@@ -215,6 +217,9 @@ export class SourceController extends CorePlugin {
|
|
|
215
217
|
if (this.switching) {
|
|
216
218
|
return
|
|
217
219
|
}
|
|
220
|
+
// The autoPlay metadata flag is set between a call to play and the actual playback start event, after which the flag is cleared.
|
|
221
|
+
this.autoPlay =
|
|
222
|
+
!!this.core.activeContainer.actionsMetadata.playEvent?.autoPlay
|
|
218
223
|
switch (error.code) {
|
|
219
224
|
case PlaybackErrorCode.MediaSourceUnavailable:
|
|
220
225
|
this.core.activeContainer?.getPlugin('poster')?.disable()
|
|
@@ -225,7 +230,7 @@ export class SourceController extends CorePlugin {
|
|
|
225
230
|
}
|
|
226
231
|
},
|
|
227
232
|
)
|
|
228
|
-
this.core.activePlayback.on(
|
|
233
|
+
this.core.activePlayback.on(Events.PLAYBACK_PLAY, () => {
|
|
229
234
|
trace(`${T} on PLAYBACK_PLAY`, {
|
|
230
235
|
currentSource: this.sourcesList[this.currentSourceIndex],
|
|
231
236
|
retrying: this.active,
|
|
@@ -236,6 +241,16 @@ export class SourceController extends CorePlugin {
|
|
|
236
241
|
this.core.activeContainer?.getPlugin('spinner')?.hide()
|
|
237
242
|
}
|
|
238
243
|
})
|
|
244
|
+
this.listenTo(
|
|
245
|
+
this.core.activeContainer,
|
|
246
|
+
Events.CONTAINER_PLAY,
|
|
247
|
+
(_: string, { autoPlay }: { autoPlay?: boolean }) => {
|
|
248
|
+
trace(`${T} onContainerPlay`, {
|
|
249
|
+
autoPlay,
|
|
250
|
+
})
|
|
251
|
+
this.autoPlay = !!autoPlay
|
|
252
|
+
},
|
|
253
|
+
)
|
|
239
254
|
}
|
|
240
255
|
|
|
241
256
|
private reset() {
|
|
@@ -255,17 +270,20 @@ export class SourceController extends CorePlugin {
|
|
|
255
270
|
trace(`${T} retryPlayback syncing...`, {
|
|
256
271
|
nextSource,
|
|
257
272
|
})
|
|
258
|
-
const rnd = RETRY_DELAY_BLUR * Math.random()
|
|
273
|
+
const rnd = Math.round(RETRY_DELAY_BLUR * Math.random())
|
|
259
274
|
this.sync(() => {
|
|
260
|
-
trace(`${T} retryPlayback loading...`)
|
|
261
275
|
this.switching = false
|
|
262
276
|
this.core.load(nextSource.source, nextSource.mimeType)
|
|
263
277
|
trace(`${T} retryPlayback loaded`, {
|
|
264
278
|
nextSource,
|
|
265
279
|
})
|
|
266
280
|
setTimeout(() => {
|
|
267
|
-
|
|
268
|
-
|
|
281
|
+
trace(`${T} retryPlayback playing`, {
|
|
282
|
+
autoPlay: this.autoPlay,
|
|
283
|
+
})
|
|
284
|
+
this.core.activeContainer.play({
|
|
285
|
+
autoPlay: this.autoPlay,
|
|
286
|
+
})
|
|
269
287
|
}, rnd)
|
|
270
288
|
})
|
|
271
289
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
-
|
|
3
2
|
import FakeTimers from '@sinonjs/fake-timers'
|
|
4
3
|
|
|
5
4
|
import { SourceController } from '../SourceController'
|
|
@@ -11,6 +10,11 @@ import {
|
|
|
11
10
|
createSpinnerPlugin,
|
|
12
11
|
} from '../../../testUtils.js'
|
|
13
12
|
|
|
13
|
+
// import { LogTracer, Logger, setTracer } from '@gcorevideo/utils'
|
|
14
|
+
|
|
15
|
+
// setTracer(new LogTracer('SourceController.test'))
|
|
16
|
+
// Logger.enable('*')
|
|
17
|
+
|
|
14
18
|
const MOCK_SOURCES = [
|
|
15
19
|
{
|
|
16
20
|
source: 'http://0eab.cdn.globo.com/1932-1447.mpd',
|
|
@@ -85,8 +89,6 @@ describe('SourceController', () => {
|
|
|
85
89
|
code: PlaybackErrorCode.MediaSourceUnavailable,
|
|
86
90
|
})
|
|
87
91
|
nextPlayback = createMockPlayback()
|
|
88
|
-
vi.spyOn(nextPlayback, 'consent')
|
|
89
|
-
vi.spyOn(nextPlayback, 'play')
|
|
90
92
|
core.activePlayback = nextPlayback
|
|
91
93
|
})
|
|
92
94
|
it('should load the next source after a delay', async () => {
|
|
@@ -101,7 +103,7 @@ describe('SourceController', () => {
|
|
|
101
103
|
await clock.tickAsync(1000)
|
|
102
104
|
expect(nextPlayback.play).not.toHaveBeenCalled()
|
|
103
105
|
await clock.tickAsync(500) // TODO check randomness
|
|
104
|
-
expect(
|
|
106
|
+
expect(core.activeContainer.play).toHaveBeenCalled()
|
|
105
107
|
})
|
|
106
108
|
it('should not call consent', async () => {
|
|
107
109
|
await clock.tickAsync(1500)
|
|
@@ -151,8 +153,6 @@ describe('SourceController', () => {
|
|
|
151
153
|
code: PlaybackErrorCode.MediaSourceUnavailable,
|
|
152
154
|
})
|
|
153
155
|
nextPlayback = createMockPlayback()
|
|
154
|
-
vi.spyOn(nextPlayback, 'consent')
|
|
155
|
-
vi.spyOn(nextPlayback, 'play')
|
|
156
156
|
core.activePlayback = nextPlayback
|
|
157
157
|
})
|
|
158
158
|
it('should sync with the spinner before reloading the source', async () => {
|
|
@@ -234,8 +234,6 @@ describe('SourceController', () => {
|
|
|
234
234
|
})
|
|
235
235
|
await clock.tickAsync(1)
|
|
236
236
|
nextPlayback = createMockPlayback()
|
|
237
|
-
vi.spyOn(nextPlayback, 'consent')
|
|
238
|
-
vi.spyOn(nextPlayback, 'play')
|
|
239
237
|
core.activePlayback = nextPlayback
|
|
240
238
|
})
|
|
241
239
|
it('should run handler only once', async () => {
|
|
@@ -248,5 +246,27 @@ describe('SourceController', () => {
|
|
|
248
246
|
)
|
|
249
247
|
})
|
|
250
248
|
})
|
|
249
|
+
describe('when playback was started with autoPlay', () => {
|
|
250
|
+
beforeEach(async () => {
|
|
251
|
+
core = createMockCore({
|
|
252
|
+
sources: MOCK_SOURCES,
|
|
253
|
+
})
|
|
254
|
+
const _ = new SourceController(core)
|
|
255
|
+
core.emit('core:ready')
|
|
256
|
+
core.emit('core:active:container:changed')
|
|
257
|
+
core.activeContainer.actionsMetadata.playEvent = {
|
|
258
|
+
autoPlay: true,
|
|
259
|
+
}
|
|
260
|
+
core.activePlayback.emit('playback:error', {
|
|
261
|
+
code: PlaybackErrorCode.MediaSourceUnavailable,
|
|
262
|
+
})
|
|
263
|
+
await clock.tickAsync(1500)
|
|
264
|
+
})
|
|
265
|
+
it('should call play with autoPlay metadata', () => {
|
|
266
|
+
expect(core.activeContainer.play).toHaveBeenCalledWith({
|
|
267
|
+
autoPlay: true,
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
})
|
|
251
271
|
})
|
|
252
272
|
})
|
package/src/testUtils.ts
CHANGED
|
@@ -42,7 +42,10 @@ export function createSpinnerPlugin() {
|
|
|
42
42
|
})
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export function createMockPlayback(
|
|
45
|
+
export function createMockPlayback(
|
|
46
|
+
name = 'mock',
|
|
47
|
+
options: Record<string, unknown> = {},
|
|
48
|
+
) {
|
|
46
49
|
const emitter = new Events()
|
|
47
50
|
return Object.assign(emitter, {
|
|
48
51
|
name,
|
|
@@ -87,6 +90,7 @@ export function createMockContainer(
|
|
|
87
90
|
const el = playback.el
|
|
88
91
|
const emitter = new Events()
|
|
89
92
|
return Object.assign(emitter, {
|
|
93
|
+
actionsMetadata: {},
|
|
90
94
|
el,
|
|
91
95
|
playback,
|
|
92
96
|
options: {
|