@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,11 +1,11 @@
|
|
|
1
1
|
import { Events, template, UICorePlugin, Utils } from '@clappr/core'
|
|
2
2
|
import { trace } from '@gcorevideo/utils'
|
|
3
|
+
import assert from 'assert'
|
|
3
4
|
|
|
4
5
|
import { CLAPPR_VERSION } from '../../build.js'
|
|
5
|
-
import { ZeptoResult } from '../../types.js'
|
|
6
6
|
|
|
7
7
|
import volumeMuteIcon from '../../../assets/icons/new/volume-off.svg'
|
|
8
|
-
import
|
|
8
|
+
import templateHtml from '../../../assets/big-mute-button/big-mute-button.ejs'
|
|
9
9
|
import '../../../assets/big-mute-button/big-mute-button.scss'
|
|
10
10
|
|
|
11
11
|
const T = 'plugins.big_mute_button'
|
|
@@ -13,18 +13,23 @@ const T = 'plugins.big_mute_button'
|
|
|
13
13
|
// TODO rewrite as a container plugin
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* `PLUGIN` that displays a big mute button over the video when it's muted.
|
|
17
|
-
* Once pressed, it unmutes the video.
|
|
16
|
+
* `PLUGIN` that displays a big mute button over the video when it's being played muted.
|
|
18
17
|
* @beta
|
|
18
|
+
* @remarks
|
|
19
|
+
* When pressed, it unmutes the video.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { BigMuteButton } from '@gcorevideo/player'
|
|
23
|
+
* Player.registerPlugin(BigMuteButton)
|
|
24
|
+
* ```
|
|
19
25
|
*/
|
|
20
26
|
export class BigMuteButton extends UICorePlugin {
|
|
21
|
-
private
|
|
27
|
+
private autoPlay = false
|
|
22
28
|
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
private $bigMuteBtnContainer: ZeptoResult | null = null
|
|
29
|
+
private hidden = false
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
// TODO get back to the ads-related logic later
|
|
32
|
+
private _adIsPlaying = false
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
35
|
* @internal
|
|
@@ -40,15 +45,14 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
40
45
|
return { min: CLAPPR_VERSION }
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
private static readonly template = template(
|
|
48
|
+
private static readonly template = template(templateHtml)
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
51
|
* @internal
|
|
47
52
|
*/
|
|
48
53
|
override get events() {
|
|
49
54
|
return {
|
|
50
|
-
|
|
51
|
-
'click .big-mute-icon-wrapper': 'destroyBigMuteBtn',
|
|
55
|
+
click: 'clicked',
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -57,156 +61,128 @@ export class BigMuteButton extends UICorePlugin {
|
|
|
57
61
|
*/
|
|
58
62
|
override bindEvents() {
|
|
59
63
|
this.listenTo(this.core, Events.CORE_READY, this.onCoreReady)
|
|
60
|
-
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
61
|
-
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
62
|
-
trace(`${T} bindEvents`, {
|
|
63
|
-
mediacontrol: !!this.core.mediaControl,
|
|
64
|
-
})
|
|
65
|
-
// TOOD use core.getPlugin('media_control')
|
|
66
64
|
this.listenTo(
|
|
67
|
-
this.core
|
|
68
|
-
Events.
|
|
69
|
-
this.
|
|
65
|
+
this.core,
|
|
66
|
+
Events.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
67
|
+
this.onContainerChanged,
|
|
70
68
|
)
|
|
69
|
+
this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
|
|
70
|
+
this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
private onCoreReady() {
|
|
73
|
+
private onCoreReady() {}
|
|
74
|
+
|
|
75
|
+
private onContainerChanged() {
|
|
74
76
|
this.listenTo(
|
|
75
77
|
this.core.activeContainer,
|
|
76
78
|
Events.CONTAINER_VOLUME,
|
|
77
79
|
this.onContainerVolume,
|
|
78
80
|
)
|
|
79
|
-
this.listenTo(
|
|
80
|
-
this.core.activeContainer,
|
|
81
|
-
Events.CONTAINER_READY,
|
|
82
|
-
this.onContainerStart,
|
|
83
|
-
)
|
|
84
81
|
this.listenTo(
|
|
85
82
|
this.core.activePlayback,
|
|
86
83
|
Events.PLAYBACK_ENDED,
|
|
87
84
|
this.onPlaybackEnded,
|
|
88
85
|
)
|
|
86
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PLAY, this.onPlay)
|
|
87
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_STOP, this.onStop)
|
|
88
|
+
this.listenTo(this.core.activeContainer, Events.CONTAINER_PAUSE, this.onPause)
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
private
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
private onPlay(_: string, { autoPlay }: { autoPlay?: boolean }) {
|
|
92
|
+
const container = this.core.activeContainer
|
|
93
|
+
const { volume } = container
|
|
94
|
+
const { wasMuted } = this.options
|
|
95
|
+
if (autoPlay) {
|
|
96
|
+
this.autoPlay = true
|
|
97
|
+
}
|
|
98
|
+
trace(`${T} onPlay`, {
|
|
99
|
+
autoPlay: this.autoPlay,
|
|
100
|
+
wasMuted,
|
|
101
|
+
volume,
|
|
102
|
+
})
|
|
103
|
+
if (this.autoPlay && !wasMuted && volume === 0) {
|
|
104
|
+
this.mount()
|
|
105
|
+
} else {
|
|
106
|
+
this.destroy()
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
private
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
private onStop(_: string, { ui }: { ui?: boolean }) {
|
|
111
|
+
trace(`${T} onStop`, { ui })
|
|
112
|
+
if (ui) {
|
|
113
|
+
this.destroy()
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
|
|
103
|
-
private
|
|
104
|
-
this.
|
|
117
|
+
private onPause() {
|
|
118
|
+
this.destroy()
|
|
105
119
|
}
|
|
106
120
|
|
|
107
|
-
private
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
trace(`${T} mediaControlRendered`, {
|
|
111
|
-
container: !!container,
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
if (container) {
|
|
115
|
-
this.listenTo(container.playback, Events.PLAYBACK_PLAY, () => {
|
|
116
|
-
trace(`${T} PLAYBACK_PLAY`)
|
|
117
|
-
this.render()
|
|
118
|
-
})
|
|
121
|
+
private onContainerVolume(value: number) {
|
|
122
|
+
if (value !== 0) {
|
|
123
|
+
this.destroy()
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
|
|
127
|
+
private onPlaybackEnded() {
|
|
128
|
+
this.hide()
|
|
129
|
+
}
|
|
130
|
+
|
|
122
131
|
private onStartAd() {
|
|
123
132
|
this._adIsPlaying = true
|
|
124
|
-
|
|
125
|
-
this.$bigMuteBtnContainer.addClass('hide')
|
|
126
|
-
}
|
|
133
|
+
this.hide()
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
private onFinishAd() {
|
|
130
137
|
this._adIsPlaying = false
|
|
131
|
-
|
|
132
|
-
this.$bigMuteBtnContainer.removeClass('hide')
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
private shouldRender() {
|
|
137
|
-
const container = this.core.activeContainer
|
|
138
|
-
|
|
139
|
-
if (!container) {
|
|
140
|
-
return false
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const { autoPlay, wasMuted } = this.options
|
|
144
|
-
const volume = container.volume
|
|
145
|
-
|
|
146
|
-
trace(`${T} shouldRender`, {
|
|
147
|
-
autoPlay,
|
|
148
|
-
wasMuted,
|
|
149
|
-
volume,
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
return autoPlay && !wasMuted && volume === 0
|
|
138
|
+
this.show()
|
|
153
139
|
}
|
|
154
140
|
|
|
155
141
|
/**
|
|
156
142
|
* @internal
|
|
157
143
|
*/
|
|
158
144
|
override render() {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
163
|
-
this.$el.html(BigMuteButton.template())
|
|
164
|
-
|
|
165
|
-
this.$bigMuteBtnContainer = this.$el.find(
|
|
166
|
-
'.big-mute-icon-wrapper[data-big-mute]',
|
|
167
|
-
)
|
|
168
|
-
this._adIsPlaying && this.$bigMuteBtnContainer.addClass('hide')
|
|
145
|
+
trace(`${T} render`)
|
|
146
|
+
this.$el.html(BigMuteButton.template())
|
|
147
|
+
this.$el.find('#gplayer-big-mute-icon').append(volumeMuteIcon)
|
|
169
148
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const container = this.core.activeContainer
|
|
174
|
-
|
|
175
|
-
container.$el.append(this.$el.get(0))
|
|
176
|
-
}
|
|
149
|
+
// TODO
|
|
150
|
+
// this._adIsPlaying && this.hide()
|
|
177
151
|
|
|
178
152
|
return this
|
|
179
153
|
}
|
|
180
154
|
|
|
181
|
-
private
|
|
182
|
-
this.
|
|
183
|
-
this
|
|
155
|
+
private mount() {
|
|
156
|
+
this.core.activeContainer.$el.append(this.$el)
|
|
157
|
+
this.show()
|
|
184
158
|
}
|
|
185
159
|
|
|
186
|
-
private
|
|
187
|
-
this.
|
|
188
|
-
|
|
189
|
-
this.$bigMuteBtnContainer.removeClass('hide')
|
|
190
|
-
}
|
|
160
|
+
private hide() {
|
|
161
|
+
this.hidden = true
|
|
162
|
+
this.$el.find('#gplayer-big-mute-button')?.addClass('hide')
|
|
191
163
|
}
|
|
192
164
|
|
|
193
|
-
private
|
|
194
|
-
this.
|
|
195
|
-
|
|
196
|
-
if (e && e.stopPropagation) {
|
|
197
|
-
e.stopPropagation()
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this.destroy()
|
|
165
|
+
private show() {
|
|
166
|
+
this.hidden = false
|
|
167
|
+
this.$el.find('#gplayer-big-mute-button')?.removeClass('hide')
|
|
201
168
|
}
|
|
202
169
|
|
|
203
170
|
private clicked(e: MouseEvent) {
|
|
171
|
+
trace(`${T} clicked`)
|
|
172
|
+
const mediaControl = this.core.getPlugin('media_control')
|
|
173
|
+
// TODO delegate to media_control plugin
|
|
204
174
|
const localVolume = Utils.Config.restore('volume')
|
|
205
175
|
const volume = !isNaN(localVolume) ? localVolume : 100
|
|
176
|
+
const unmuted = volume === 0 ? 100 : volume
|
|
206
177
|
|
|
207
|
-
|
|
208
|
-
|
|
178
|
+
if (mediaControl) {
|
|
179
|
+
mediaControl.setVolume(unmuted)
|
|
180
|
+
} else {
|
|
181
|
+
this.core.activeContainer.setVolume(unmuted)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
e.stopPropagation?.()
|
|
209
185
|
|
|
210
|
-
this.
|
|
186
|
+
this.destroy()
|
|
211
187
|
}
|
|
212
188
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { beforeEach, describe, it, expect } from 'vitest'
|
|
2
|
+
import { Events } from '@clappr/core'
|
|
3
|
+
|
|
4
|
+
import { BigMuteButton } from '../BigMuteButton.js'
|
|
5
|
+
import { createMockCore } from '../../../testUtils.js'
|
|
6
|
+
|
|
7
|
+
// import { Logger, LogTracer, setTracer } from '@gcorevideo/utils'
|
|
8
|
+
|
|
9
|
+
// setTracer(new LogTracer('BigMuteButton.test'))
|
|
10
|
+
// Logger.enable('*')
|
|
11
|
+
|
|
12
|
+
describe('BigMuteButton', () => {
|
|
13
|
+
let core: any
|
|
14
|
+
let bmb: BigMuteButton
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
core = createMockCore({})
|
|
17
|
+
bmb = new BigMuteButton(core)
|
|
18
|
+
})
|
|
19
|
+
describe('basically', () => {
|
|
20
|
+
it('should render', () => {
|
|
21
|
+
expect(bmb.$el.html()).toMatchSnapshot()
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
describe('when container starts playing', () => {
|
|
25
|
+
describe.each([
|
|
26
|
+
['muted autoplay', 0, { autoPlay: true }, true],
|
|
27
|
+
['audible autoplay', 50, { autoPlay: true }, false],
|
|
28
|
+
['muted not autoplay', 0, {}, false],
|
|
29
|
+
['audible not autoplay', 50, {}, false],
|
|
30
|
+
])('%s', (_, volume, playMetadata, shouldMount) => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
|
|
33
|
+
core.activeContainer.volume = volume
|
|
34
|
+
core.activeContainer.emit(
|
|
35
|
+
Events.CONTAINER_PLAY,
|
|
36
|
+
'Container',
|
|
37
|
+
playMetadata,
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
it(`should ${shouldMount ? 'mount' : 'not mount'} to container`, () => {
|
|
41
|
+
expect(
|
|
42
|
+
core.activeContainer.$el.find('#gplayer-big-mute-button').length,
|
|
43
|
+
).toBe(shouldMount ? 1 : 0)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
describe('when playback is stopped', () => {
|
|
48
|
+
describe.each([
|
|
49
|
+
['from ui', { ui: true }, true],
|
|
50
|
+
['algorithmically', {}, false],
|
|
51
|
+
])('%s', (_, stopMetadata, shouldUnmount) => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
|
|
54
|
+
core.activeContainer.volume = 0
|
|
55
|
+
core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', {
|
|
56
|
+
autoPlay: true,
|
|
57
|
+
})
|
|
58
|
+
core.activeContainer.emit(
|
|
59
|
+
Events.CONTAINER_STOP,
|
|
60
|
+
'Container',
|
|
61
|
+
stopMetadata,
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
it(`should ${shouldUnmount ? 'unmount' : 'not unmount'}`, () => {
|
|
65
|
+
expect(
|
|
66
|
+
core.activeContainer.$el.find('#gplayer-big-mute-button').length,
|
|
67
|
+
).toBe(shouldUnmount ? 0 : 1)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
describe('when playback is paused', () => {
|
|
72
|
+
beforeEach(() => {
|
|
73
|
+
core.emit(Events.CORE_ACTIVE_CONTAINER_CHANGED)
|
|
74
|
+
core.activeContainer.volume = 0
|
|
75
|
+
core.activeContainer.emit(Events.CONTAINER_PLAY, 'Container', {
|
|
76
|
+
autoPlay: true,
|
|
77
|
+
})
|
|
78
|
+
core.activeContainer.emit(Events.CONTAINER_PAUSE, 'Container')
|
|
79
|
+
})
|
|
80
|
+
it('should unmount', () => {
|
|
81
|
+
expect(
|
|
82
|
+
core.activeContainer.$el.find('#gplayer-big-mute-button').length,
|
|
83
|
+
).toBe(0)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`BigMuteButton > basically > should render 1`] = `
|
|
4
|
+
"<div class="big-mute-icon-wrapper" data-big-mute="" id="gplayer-big-mute-button">
|
|
5
|
+
<div class="big-mute-icon gcore-skin-border-color" data-big-mute-icon="" id="gplayer-big-mute-icon">/assets/icons/new/volume-off.svg</div>
|
|
6
|
+
</div>
|
|
7
|
+
"
|
|
8
|
+
`;
|
|
@@ -20,7 +20,11 @@ import { isFullscreen } from '../utils/fullscreen.js'
|
|
|
20
20
|
|
|
21
21
|
// const T = 'plugins.clappr_stats'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Config options for the {@link ClapprStats} plugin
|
|
25
|
+
* @beta
|
|
26
|
+
*/
|
|
27
|
+
export interface ClapprStatsSettings {
|
|
24
28
|
/**
|
|
25
29
|
* The interval in milliseconds of periodic measurements.
|
|
26
30
|
* The plugin will emit a {@link ClapprStatsEvents.REPORT} event with the collected metrics at the specified interval.
|
|
@@ -85,7 +85,7 @@ export class ClickToPause extends ContainerPlugin {
|
|
|
85
85
|
const isPlaying = this.container && this.container.isPlaying()
|
|
86
86
|
|
|
87
87
|
if (isPlaying) {
|
|
88
|
-
useStop ? this.container.stop() : this.container.pause()
|
|
88
|
+
useStop ? this.container.stop({ ui: true }) : this.container.pause()
|
|
89
89
|
} else {
|
|
90
90
|
this.container.play()
|
|
91
91
|
}
|
|
@@ -17,7 +17,7 @@ const T = 'plugins.clips'
|
|
|
17
17
|
*/
|
|
18
18
|
export interface ClipsPluginSettings {
|
|
19
19
|
/**
|
|
20
|
-
* The compiled text of the clips description, one clip per line in format
|
|
20
|
+
* The compiled text of the clips description, one clip per line in format:
|
|
21
21
|
* `HH:MM:SS text` or `MM:SS text` or `SS text`
|
|
22
22
|
*/
|
|
23
23
|
text: string
|
|
@@ -123,7 +123,8 @@ export class Clips extends UICorePlugin {
|
|
|
123
123
|
* @returns The text of the clip at the given time
|
|
124
124
|
*/
|
|
125
125
|
getText(time: TimeValue): string | undefined {
|
|
126
|
-
return this.clips.find((clip) => clip.start <= time && clip.end >= time)
|
|
126
|
+
return this.clips.find((clip) => clip.start <= time && clip.end >= time)
|
|
127
|
+
?.text
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
private onCoreReady() {
|
|
@@ -4,7 +4,6 @@ import { $, Container, Core, CorePlugin, Events } from '@clappr/core'
|
|
|
4
4
|
|
|
5
5
|
import { generateSessionId } from './utils'
|
|
6
6
|
import { CLAPPR_VERSION } from '../../build.js'
|
|
7
|
-
import { CoreOptions } from 'src/internal.types'
|
|
8
7
|
|
|
9
8
|
const CMCD_KEYS = [
|
|
10
9
|
'br',
|
|
@@ -28,15 +27,16 @@ const CMCD_KEYS = [
|
|
|
28
27
|
]
|
|
29
28
|
|
|
30
29
|
/**
|
|
30
|
+
* Config options for the {@link CmcdConfig} plugin
|
|
31
31
|
* @beta
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
33
|
+
export interface CmcdConfigOptions {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* `sid` value. If ommitted, a random UUID will be generated
|
|
36
36
|
*/
|
|
37
|
-
sessionId
|
|
37
|
+
sessionId?: string
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* `cid` value.
|
|
40
40
|
* If ommitted, the pathname part of the first source URL will be used
|
|
41
41
|
*/
|
|
42
42
|
contentId?: string
|
|
@@ -45,11 +45,23 @@ export type CmcdConfigPluginSettings = {
|
|
|
45
45
|
// const T = 'plugins.cmcd'
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* A `PLUGIN` that configures CMCD for playback
|
|
48
|
+
* A `PLUGIN` that configures {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf | CMCD} for playback
|
|
49
49
|
* @beta
|
|
50
50
|
* @remarks
|
|
51
|
-
* Configuration options
|
|
52
|
-
*
|
|
51
|
+
* Configuration options - {@link CmcdConfigOptions}.
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { CmcdConfig } from '@gcorevideo/player'
|
|
55
|
+
* Player.registerPlugin(CmcdConfig)
|
|
56
|
+
*
|
|
57
|
+
* const player = new Player({
|
|
58
|
+
* source: 'https://example.com/video.mp4',
|
|
59
|
+
* cmcd: {
|
|
60
|
+
* sessionId: '1234567890',
|
|
61
|
+
* contentId: 'f572d396fae9206628714fb2ce00f72e94f2258f',
|
|
62
|
+
* },
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
53
65
|
*/
|
|
54
66
|
export class CmcdConfig extends CorePlugin {
|
|
55
67
|
private sid: string
|
|
@@ -57,16 +69,22 @@ export class CmcdConfig extends CorePlugin {
|
|
|
57
69
|
private cid = ''
|
|
58
70
|
|
|
59
71
|
/**
|
|
60
|
-
* @
|
|
72
|
+
* @internal
|
|
61
73
|
*/
|
|
62
74
|
get name() {
|
|
63
75
|
return 'cmcd'
|
|
64
76
|
}
|
|
65
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
66
81
|
get version() {
|
|
67
82
|
return '0.1.0'
|
|
68
83
|
}
|
|
69
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
70
88
|
get supportedVersion() {
|
|
71
89
|
return CLAPPR_VERSION
|
|
72
90
|
}
|
|
@@ -78,7 +96,7 @@ export class CmcdConfig extends CorePlugin {
|
|
|
78
96
|
}
|
|
79
97
|
|
|
80
98
|
/**
|
|
81
|
-
* @
|
|
99
|
+
* @internal
|
|
82
100
|
*/
|
|
83
101
|
override bindEvents() {
|
|
84
102
|
this.listenTo(this.core, Events.CORE_CONTAINERS_CREATED, () =>
|
|
@@ -86,6 +104,11 @@ export class CmcdConfig extends CorePlugin {
|
|
|
86
104
|
)
|
|
87
105
|
}
|
|
88
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Returns the current `sid` and `cid` values.
|
|
109
|
+
* Useful when the auto-generated values need to be known.
|
|
110
|
+
* @returns `sid` and `cid` values
|
|
111
|
+
*/
|
|
89
112
|
exportIds(): { sid: string; cid: string } {
|
|
90
113
|
return {
|
|
91
114
|
sid: this.sid,
|
|
@@ -123,23 +146,6 @@ export class CmcdConfig extends CorePlugin {
|
|
|
123
146
|
}
|
|
124
147
|
}
|
|
125
148
|
|
|
126
|
-
private updateHlsjsSettings(
|
|
127
|
-
options: CoreOptions,
|
|
128
|
-
{ cid, sid }: { cid: string; sid: string },
|
|
129
|
-
) {
|
|
130
|
-
$.extend(true, options, {
|
|
131
|
-
playback: {
|
|
132
|
-
hlsjsConfig: {
|
|
133
|
-
cmcd: {
|
|
134
|
-
includeKeys: CMCD_KEYS,
|
|
135
|
-
sessionId: sid,
|
|
136
|
-
contentId: cid,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
|
|
143
149
|
private generateContentId() {
|
|
144
150
|
return new URL(
|
|
145
151
|
this.core.options.source ?? this.core.options.sources[0].source,
|
|
@@ -136,6 +136,10 @@ const LEFT_ORDER = [
|
|
|
136
136
|
'dvr',
|
|
137
137
|
]
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Extended events for the {@link MediaControl} plugin
|
|
141
|
+
* @beta
|
|
142
|
+
*/
|
|
139
143
|
export enum ExtendedEvents {
|
|
140
144
|
MEDIACONTROL_VOLUME = 'mediacontrol:volume',
|
|
141
145
|
MEDIACONTROL_MENU_COLLAPSE = 'mediacontrol:menu:collapse',
|
|
@@ -557,6 +561,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
557
561
|
this.updateVolumeUI()
|
|
558
562
|
}
|
|
559
563
|
|
|
564
|
+
// TODO check if CONTAINER_SETTINGSUPDATE handler is sufficient
|
|
560
565
|
private onLoadedMetadata() {
|
|
561
566
|
const video = this.core.activePlayback?.el
|
|
562
567
|
|
|
@@ -718,7 +723,7 @@ export class MediaControl extends UICorePlugin {
|
|
|
718
723
|
}
|
|
719
724
|
|
|
720
725
|
private togglePlayStop() {
|
|
721
|
-
this.container.isPlaying() ? this.container.stop() : this.container.play()
|
|
726
|
+
this.container.isPlaying() ? this.container.stop({ ui: true }) : this.container.play()
|
|
722
727
|
}
|
|
723
728
|
|
|
724
729
|
private startSeekDrag(event: MouseEvent) {
|
|
@@ -19,7 +19,11 @@ import posterHTML from '../../../assets/poster/poster.ejs'
|
|
|
19
19
|
import playIcon from '../../../assets/icons/new/play.svg'
|
|
20
20
|
import { PlaybackError } from '../../playback.types.js'
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Config options for the {@link Poster} plugin
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export interface PosterPluginSettings {
|
|
23
27
|
/**
|
|
24
28
|
* Custom CSS background
|
|
25
29
|
*/
|
|
@@ -33,7 +37,7 @@ export type PosterPluginSettings = {
|
|
|
33
37
|
*/
|
|
34
38
|
url?: string
|
|
35
39
|
/**
|
|
36
|
-
* Whether to show the poster after playback has ended
|
|
40
|
+
* Whether to show the poster after playback has ended, by default `true`
|
|
37
41
|
*/
|
|
38
42
|
showOnVideoEnd?: boolean
|
|
39
43
|
}
|