@gcorevideo/player 2.20.1 → 2.20.4
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/core.js +30 -6
- package/dist/index.css +1572 -1572
- package/dist/index.js +343 -226
- package/dist/player.d.ts +280 -52
- package/dist/plugins/index.css +619 -619
- package/dist/plugins/index.js +1468 -1351
- package/docs/api/player.audioselector.md +1 -251
- package/docs/api/player.bigmutebutton.md +1 -156
- package/docs/api/player.clapprstats.exportmetrics.md +4 -0
- package/docs/api/player.clapprstats.md +7 -223
- package/docs/api/player.clapprstats.setupdatemetrics.md +2 -0
- package/docs/api/player.clicktopause.md +5 -113
- package/docs/api/player.clipsplugin.gettext.md +9 -0
- package/docs/api/player.clipsplugin.md +10 -94
- package/docs/api/player.clipspluginsettings.md +57 -0
- package/docs/api/player.clipspluginsettings.text.md +13 -0
- package/docs/api/player.contextmenu._constructor_.md +6 -3
- package/docs/api/player.contextmenu.md +13 -256
- package/docs/api/{player.audioselector.bindevents.md → player.contextmenupluginsettings.label.md} +3 -7
- package/docs/api/player.contextmenupluginsettings.md +98 -0
- package/docs/api/{player.audioselector.attributes.md → player.contextmenupluginsettings.preventshowcontextmenu.md} +3 -6
- package/docs/api/{player.audioselector.reload.md → player.contextmenupluginsettings.url.md} +3 -7
- package/docs/api/player.dvrcontrols.md +1 -1
- package/docs/api/player.errorscreen.md +0 -2
- package/docs/api/player.favicon._constructor_.md +3 -0
- package/docs/api/player.favicon.bindevents.md +3 -0
- package/docs/api/player.favicon.configure.md +3 -0
- package/docs/api/player.favicon.destroy.md +3 -0
- package/docs/api/player.favicon.disable.md +3 -0
- package/docs/api/player.favicon.md +18 -1
- package/docs/api/player.favicon.name.md +3 -0
- package/docs/api/player.favicon.supportedversion.md +3 -0
- package/docs/api/player.gearevents.md +4 -1
- package/docs/api/player.googleanalytics._constructor_.md +3 -0
- package/docs/api/player.googleanalytics.addeventlisteners.md +3 -0
- package/docs/api/player.googleanalytics.embedscript.md +3 -0
- package/docs/api/player.googleanalytics.md +42 -1
- package/docs/api/player.googleanalytics.name.md +3 -0
- package/docs/api/player.googleanalytics.onbufferfull.md +3 -0
- package/docs/api/player.googleanalytics.onbuffering.md +3 -0
- package/docs/api/player.googleanalytics.ondvr.md +3 -0
- package/docs/api/player.googleanalytics.onended.md +3 -0
- package/docs/api/player.googleanalytics.onerror.md +3 -0
- package/docs/api/player.googleanalytics.onfullscreen.md +3 -0
- package/docs/api/player.googleanalytics.onhd.md +3 -0
- package/docs/api/player.googleanalytics.onpause.md +3 -0
- package/docs/api/player.googleanalytics.onplay.md +3 -0
- package/docs/api/player.googleanalytics.onready.md +3 -0
- package/docs/api/player.googleanalytics.onseek.md +3 -0
- package/docs/api/player.googleanalytics.onstop.md +3 -0
- package/docs/api/player.googleanalytics.onvolumechanged.md +3 -0
- package/docs/api/player.googleanalytics.push.md +3 -0
- package/docs/api/player.googleanalytics.supportedversion.md +3 -0
- package/docs/api/player.initeventdata.event.md +3 -0
- package/docs/api/player.initeventdata.md +7 -0
- package/docs/api/player.logo._constructor_.md +3 -0
- package/docs/api/player.logo.attributes.md +3 -0
- package/docs/api/player.logo.bindevents.md +3 -0
- package/docs/api/player.logo.md +20 -1
- package/docs/api/player.logo.name.md +3 -0
- package/docs/api/player.logo.render.md +3 -0
- package/docs/api/player.logo.stoplistening.md +3 -0
- package/docs/api/player.logo.supportedversion.md +3 -0
- package/docs/api/player.logo.template.md +3 -0
- package/docs/api/player.md +73 -21
- package/docs/api/player.mediacontrolelement.md +1 -1
- package/docs/api/player.multicamera._constructor_.md +3 -0
- package/docs/api/player.multicamera.activebyid.md +3 -0
- package/docs/api/player.multicamera.attributes.md +3 -0
- package/docs/api/player.multicamera.bindevents.md +3 -0
- package/docs/api/player.multicamera.events.md +3 -0
- package/docs/api/player.multicamera.getcameraslist.md +3 -0
- package/docs/api/player.multicamera.getcurrentcamera.md +3 -0
- package/docs/api/player.multicamera.md +30 -1
- package/docs/api/player.multicamera.name.md +3 -0
- package/docs/api/player.multicamera.render.md +3 -0
- package/docs/api/player.multicamera.supportedversion.md +3 -0
- package/docs/api/player.multicamera.template.md +3 -0
- package/docs/api/player.multicamera.unbindevents.md +3 -0
- package/docs/api/player.multicamera.version.md +3 -0
- package/docs/api/player.seektime.attributes.md +3 -0
- package/docs/api/player.seektime.bindevents.md +3 -0
- package/docs/api/player.seektime.durationshown.md +3 -0
- package/docs/api/player.seektime.getseektime.md +3 -0
- package/docs/api/player.seektime.islivestreamwithdvr.md +3 -0
- package/docs/api/player.seektime.md +31 -0
- package/docs/api/player.seektime.mediacontrol.md +3 -0
- package/docs/api/player.seektime.mediacontrolcontainer.md +3 -0
- package/docs/api/player.seektime.name.md +3 -0
- package/docs/api/player.seektime.render.md +3 -0
- package/docs/api/player.seektime.shouldbevisible.md +3 -0
- package/docs/api/player.seektime.supportedversion.md +3 -0
- package/docs/api/player.seektime.template.md +3 -0
- package/docs/api/player.seektime.update.md +3 -0
- package/docs/api/player.share.md +2 -0
- package/docs/api/player.skiptime.md +2 -0
- package/docs/api/player.stalleventdata.count.md +3 -0
- package/docs/api/player.stalleventdata.event.md +3 -0
- package/docs/api/player.stalleventdata.md +8 -3
- package/docs/api/player.stalleventdata.time.md +3 -0
- package/docs/api/player.stalleventdata.total_ms.md +3 -0
- package/docs/api/player.starteventdata.event.md +3 -0
- package/docs/api/player.starteventdata.md +7 -0
- package/docs/api/player.telemetryevent.md +11 -0
- package/docs/api/player.telemetryeventdata.md +3 -0
- package/docs/api/player.telemetrypluginsettings.md +4 -1
- package/docs/api/player.telemetrypluginsettings.send.md +3 -0
- package/docs/api/player.telemetryrecord.md +3 -0
- package/docs/api/player.thumbnails.md +21 -139
- package/docs/api/player.thumbnailspluginsettings.md +23 -0
- package/docs/api/player.volumefade.md +1 -0
- package/docs/api/player.volumefadeevents.md +7 -0
- package/docs/api/player.watcheventdata.event.md +3 -0
- package/docs/api/player.watcheventdata.md +7 -0
- package/docs/api/player.zeptoresult.md +1 -0
- package/lib/Player.d.ts +5 -3
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +30 -6
- package/lib/index.plugins.d.ts +0 -1
- package/lib/index.plugins.d.ts.map +1 -1
- package/lib/index.plugins.js +0 -1
- package/lib/internal.types.d.ts +7 -7
- package/lib/internal.types.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.d.ts +28 -6
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +52 -22
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +18 -2
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +21 -16
- package/lib/plugins/bottom-gear/BottomGear.d.ts +1 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +31 -8
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/ClapprStats.js +24 -0
- package/lib/plugins/clappr-stats/types.d.ts +12 -0
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -1
- package/lib/plugins/clappr-stats/types.js +3 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts +13 -1
- package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +14 -4
- package/lib/plugins/clips/Clips.d.ts +34 -2
- package/lib/plugins/clips/Clips.d.ts.map +1 -1
- package/lib/plugins/clips/Clips.js +51 -22
- package/lib/plugins/context-menu/ContextMenu.d.ts +44 -13
- package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -1
- package/lib/plugins/context-menu/ContextMenu.js +48 -36
- package/lib/plugins/dvr-controls/DvrControls.d.ts +1 -3
- package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DvrControls.js +11 -28
- package/lib/plugins/error-screen/ErrorScreen.d.ts +0 -1
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -1
- package/lib/plugins/error-screen/ErrorScreen.js +0 -1
- package/lib/plugins/favicon/Favicon.d.ts +4 -0
- package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
- package/lib/plugins/favicon/Favicon.js +4 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +4 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -1
- package/lib/plugins/google-analytics/GoogleAnalytics.js +5 -1
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.d.ts.map +1 -1
- package/lib/plugins/index.js +0 -1
- package/lib/plugins/logo/Logo.d.ts +4 -0
- package/lib/plugins/logo/Logo.d.ts.map +1 -1
- package/lib/plugins/logo/Logo.js +4 -0
- package/lib/plugins/media-control/MediaControl.d.ts +1 -1
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +3 -1
- package/lib/plugins/multi-camera/MultiCamera.d.ts +4 -0
- package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
- package/lib/plugins/multi-camera/MultiCamera.js +6 -2
- package/lib/plugins/seek-time/SeekTime.d.ts +4 -0
- package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -1
- package/lib/plugins/seek-time/SeekTime.js +6 -2
- package/lib/plugins/share/Share.d.ts +3 -0
- package/lib/plugins/share/Share.d.ts.map +1 -1
- package/lib/plugins/share/Share.js +4 -1
- package/lib/plugins/skip-time/SkipTime.d.ts +3 -0
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
- package/lib/plugins/skip-time/SkipTime.js +3 -0
- package/lib/plugins/telemetry/Telemetry.d.ts +18 -0
- package/lib/plugins/telemetry/Telemetry.d.ts.map +1 -1
- package/lib/plugins/telemetry/Telemetry.js +1 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts +48 -3
- package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -1
- package/lib/plugins/thumbnails/Thumbnails.js +52 -18
- package/lib/plugins/volume-fade/VolumeFade.d.ts +5 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -1
- package/lib/plugins/volume-fade/VolumeFade.js +5 -0
- package/lib/types.d.ts +9 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/utils/types.d.ts +1 -0
- package/lib/utils/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/release_notes +297 -0
- package/src/Player.ts +101 -46
- package/src/__tests__/Player.test.ts +23 -1
- package/src/index.plugins.ts +0 -1
- package/src/internal.types.ts +86 -79
- package/src/plugins/audio-selector/AudioSelector.ts +227 -154
- package/src/plugins/big-mute-button/BigMuteButton.ts +100 -79
- package/src/plugins/bottom-gear/BottomGear.ts +1 -0
- package/src/plugins/clappr-stats/ClapprStats.ts +32 -8
- package/src/plugins/clappr-stats/types.ts +13 -0
- package/src/plugins/click-to-pause/ClickToPause.ts +47 -36
- package/src/plugins/clips/Clips.ts +127 -71
- package/src/plugins/context-menu/ContextMenu.ts +109 -76
- package/src/plugins/dvr-controls/DvrControls.ts +11 -30
- package/src/plugins/error-screen/ErrorScreen.ts +0 -1
- package/src/plugins/favicon/Favicon.ts +4 -0
- package/src/plugins/google-analytics/GoogleAnalytics.ts +5 -1
- package/src/plugins/index.ts +0 -1
- package/src/plugins/logo/Logo.ts +4 -0
- package/src/plugins/media-control/MediaControl.ts +4 -1
- package/src/plugins/multi-camera/MultiCamera.ts +6 -2
- package/src/plugins/seek-time/SeekTime.ts +6 -2
- package/src/plugins/share/Share.ts +4 -1
- package/src/plugins/skip-time/SkipTime.ts +3 -0
- package/src/plugins/telemetry/Telemetry.ts +18 -0
- package/src/plugins/thumbnails/Thumbnails.ts +268 -194
- package/src/plugins/volume-fade/VolumeFade.ts +5 -0
- package/src/types.ts +11 -1
- package/src/utils/types.ts +1 -0
- package/temp/player.api.json +627 -2468
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/api/player.audioselector.events.md +0 -17
- package/docs/api/player.audioselector.hideselecttrackmenu.md +0 -18
- package/docs/api/player.audioselector.name.md +0 -14
- package/docs/api/player.audioselector.onshowlevelselectmenu.md +0 -18
- package/docs/api/player.audioselector.render.md +0 -18
- package/docs/api/player.audioselector.supportedversion.md +0 -16
- package/docs/api/player.audioselector.template.md +0 -14
- package/docs/api/player.audioselector.togglecontextmenu.md +0 -18
- package/docs/api/player.audioselector.unbindevents.md +0 -18
- package/docs/api/player.audioselector.version.md +0 -14
- package/docs/api/player.bigmutebutton.bindevents.md +0 -18
- package/docs/api/player.bigmutebutton.events.md +0 -17
- package/docs/api/player.bigmutebutton.name.md +0 -14
- package/docs/api/player.bigmutebutton.render.md +0 -18
- package/docs/api/player.bigmutebutton.supportedversion.md +0 -16
- package/docs/api/player.bigmutebutton.template.md +0 -14
- package/docs/api/player.clapprstats._buildreport.md +0 -18
- package/docs/api/player.clapprstats._defaultreport.md +0 -52
- package/docs/api/player.clapprstats._playbackname.md +0 -14
- package/docs/api/player.clapprstats._playbacktype.md +0 -14
- package/docs/api/player.clapprstats.bindevents.md +0 -18
- package/docs/api/player.clapprstats.destroy.md +0 -18
- package/docs/api/player.clapprstats.name.md +0 -14
- package/docs/api/player.clapprstats.onfirstplaying.md +0 -18
- package/docs/api/player.clapprstats.playafterpause.md +0 -18
- package/docs/api/player.clapprstats.starttimers.md +0 -18
- package/docs/api/player.clapprstats.stopreporting.md +0 -18
- package/docs/api/player.clapprstats.supportedversion.md +0 -16
- package/docs/api/player.clicktopause.bindevents.md +0 -15
- package/docs/api/player.clicktopause.config.md +0 -11
- package/docs/api/player.clicktopause.name.md +0 -11
- package/docs/api/player.clicktopause.supportedversion.md +0 -13
- package/docs/api/player.clipsplugin.attributes.md +0 -13
- package/docs/api/player.clipsplugin.bindevents.md +0 -15
- package/docs/api/player.clipsplugin.makesvg.md +0 -49
- package/docs/api/player.clipsplugin.name.md +0 -11
- package/docs/api/player.clipsplugin.unbindevents.md +0 -15
- package/docs/api/player.contextmenu.attributes.md +0 -13
- package/docs/api/player.contextmenu.bindevents.md +0 -15
- package/docs/api/player.contextmenu.destroy.md +0 -15
- package/docs/api/player.contextmenu.events.md +0 -13
- package/docs/api/player.contextmenu.exposeversion.md +0 -14
- package/docs/api/player.contextmenu.label.md +0 -11
- package/docs/api/player.contextmenu.mediacontrol.md +0 -11
- package/docs/api/player.contextmenu.name.md +0 -11
- package/docs/api/player.contextmenu.render.md +0 -15
- package/docs/api/player.contextmenu.supportedversion.md +0 -13
- package/docs/api/player.contextmenu.template.md +0 -11
- package/docs/api/player.contextmenu.url.md +0 -11
- package/docs/api/player.disablecontrols.bindevents.md +0 -15
- package/docs/api/player.disablecontrols.container.md +0 -11
- package/docs/api/player.disablecontrols.md +0 -138
- package/docs/api/player.disablecontrols.name.md +0 -11
- package/docs/api/player.disablecontrols.supportedversion.md +0 -13
- package/docs/api/player.disablecontrols.unbindevents.md +0 -15
- package/docs/api/player.thumbnails.attributes.md +0 -13
- package/docs/api/player.thumbnails.bindevents.md +0 -15
- package/docs/api/player.thumbnails.name.md +0 -11
- package/docs/api/player.thumbnails.settext.md +0 -49
- package/docs/api/player.thumbnails.supportedversion.md +0 -13
- package/docs/api/player.thumbnails.template.md +0 -11
- package/src/plugins/disable-controls/DisableControls.ts +0 -81
- package/src/plugins/ga-events/GaEvents.js +0 -395
- package/src/plugins/ga-events/ga-tracking.js +0 -46
|
@@ -1,82 +1,115 @@
|
|
|
1
|
-
import { UICorePlugin, Events, template, $, Container } from '@clappr/core'
|
|
2
|
-
import { reportError, trace } from '@gcorevideo/utils'
|
|
3
|
-
import parseSRT, { type ParsedSRT } from 'parse-srt'
|
|
4
|
-
|
|
5
|
-
import { TimeValue } from '../../playback.types.js'
|
|
6
|
-
|
|
7
|
-
import { CLAPPR_VERSION } from '../../build.js'
|
|
8
|
-
|
|
9
|
-
import pluginHtml from '../../../assets/thumbnails/scrub-thumbnails.ejs'
|
|
10
|
-
import '../../../assets/thumbnails/style.scss'
|
|
11
|
-
import { ZeptoResult } from '../../utils/types.js'
|
|
12
|
-
import { getPageX } from '../utils.js'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { UICorePlugin, Events, template, $, Container } from '@clappr/core'
|
|
2
|
+
import { reportError, trace } from '@gcorevideo/utils'
|
|
3
|
+
import parseSRT, { type ParsedSRT } from 'parse-srt'
|
|
4
|
+
|
|
5
|
+
import { TimeValue } from '../../playback.types.js'
|
|
6
|
+
|
|
7
|
+
import { CLAPPR_VERSION } from '../../build.js'
|
|
8
|
+
|
|
9
|
+
import pluginHtml from '../../../assets/thumbnails/scrub-thumbnails.ejs'
|
|
10
|
+
import '../../../assets/thumbnails/style.scss'
|
|
11
|
+
import { ZeptoResult } from '../../utils/types.js'
|
|
12
|
+
import { getPageX } from '../utils.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Plugin configuration options for the thumbnails plugin.
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
export type ThumbnailsPluginSettings = {
|
|
19
|
+
backdropHeight: number
|
|
20
|
+
backdropMaxOpacity: number
|
|
21
|
+
backdropMinOpacity: number
|
|
22
|
+
spotlightHeight: number
|
|
23
|
+
sprite: string
|
|
24
|
+
vtt: string
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
type Thumb = {
|
|
24
|
-
url: string
|
|
25
|
-
time: number
|
|
26
|
-
w: number
|
|
27
|
-
h: number
|
|
28
|
-
x: number
|
|
29
|
-
y: number
|
|
30
|
-
duration?: number
|
|
31
|
-
imageH?: number
|
|
28
|
+
url: string
|
|
29
|
+
time: number
|
|
30
|
+
w: number
|
|
31
|
+
h: number
|
|
32
|
+
x: number
|
|
33
|
+
y: number
|
|
34
|
+
duration?: number
|
|
35
|
+
imageH?: number
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
const T = 'plugins.
|
|
35
|
-
|
|
38
|
+
const T = 'plugins.thumbnails'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Displays the thumbnails of the video when available.
|
|
42
|
+
* @beta
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { Thumbnails } from '@gcorevideo/player'
|
|
46
|
+
*
|
|
47
|
+
* Player.registerPlugin(Thumbnails)
|
|
48
|
+
*
|
|
49
|
+
* new Player({
|
|
50
|
+
* thumbnails: {
|
|
51
|
+
* backdropHeight: 200,
|
|
52
|
+
* backdropMinOpacity: 0.9,
|
|
53
|
+
* backdropMaxOpacity: 0.99,
|
|
54
|
+
* spotlightHeight: 100,
|
|
55
|
+
* vtt: '1\n00:00:00,000 --> 00:00:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,0,100,56\n\n2\n00:00:10,000 --> 00:00:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,0,100,56\n\n3\n00:00:20,000 --> 00:00:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,0,100,56\n\n4\n00:00:30,000 --> 00:00:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,0,100,56\n\n5\n00:00:40,000 --> 00:00:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,0,100,56\n\n6\n00:00:50,000 --> 00:01:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,0,100,56\n\n7\n00:01:00,000 --> 00:01:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,0,100,56\n\n8\n00:01:10,000 --> 00:01:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,56,100,56\n\n9\n00:01:20,000 --> 00:01:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,56,100,56\n\n10\n00:01:30,000 --> 00:01:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,56,100,56\n\n11\n00:01:40,000 --> 00:01:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,56,100,56\n\n12\n00:01:50,000 --> 00:02:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,56,100,56\n\n13\n00:02:00,000 --> 00:02:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,56,100,56\n\n14\n00:02:10,000 --> 00:02:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,56,100,56\n\n15\n00:02:20,000 --> 00:02:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,112,100,56\n\n16\n00:02:30,000 --> 00:02:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,112,100,56\n\n17\n00:02:40,000 --> 00:02:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,112,100,56\n\n18\n00:02:50,000 --> 00:03:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,112,100,56\n\n19\n00:03:00,000 --> 00:03:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,112,100,56\n\n20\n00:03:10,000 --> 00:03:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,112,100,56\n\n21\n00:03:20,000 --> 00:03:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,112,100,56\n\n22\n00:03:30,000 --> 00:03:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,168,100,56\n\n23\n00:03:40,000 --> 00:03:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,168,100,56\n\n24\n00:03:50,000 --> 00:04:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,168,100,56\n\n25\n00:04:00,000 --> 00:04:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,168,100,56\n\n26\n00:04:10,000 --> 00:04:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,168,100,56\n\n27\n00:04:20,000 --> 00:04:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,168,100,56\n\n28\n00:04:30,000 --> 00:04:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,168,100,56\n\n29\n00:04:40,000 --> 00:04:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,224,100,56\n\n30\n00:04:50,000 --> 00:05:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,224,100,56\n\n31\n00:05:00,000 --> 00:05:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,224,100,56\n\n32\n00:05:10,000 --> 00:05:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,224,100,56\n\n33\n00:05:20,000 --> 00:05:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,224,100,56\n\n34\n00:05:30,000 --> 00:05:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,224,100,56\n\n35\n00:05:40,000 --> 00:05:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,224,100,56\n\n36\n00:05:50,000 --> 00:06:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,280,100,56\n\n37\n00:06:00,000 --> 00:06:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,280,100,56\n\n38\n00:06:10,000 --> 00:06:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,280,100,56\n\n39\n00:06:20,000 --> 00:06:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,280,100,56\n\n40\n00:06:30,000 --> 00:06:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,280,100,56\n\n41\n00:06:40,000 --> 00:06:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,280,100,56\n\n42\n00:06:50,000 --> 00:07:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,280,100,56\n\n43\n00:07:00,000 --> 00:07:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=0,336,100,56\n\n44\n00:07:10,000 --> 00:07:20,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=100,336,100,56\n\n45\n00:07:20,000 --> 00:07:30,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=200,336,100,56\n\n46\n00:07:30,000 --> 00:07:40,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=300,336,100,56\n\n47\n00:07:40,000 --> 00:07:50,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=400,336,100,56\n\n48\n00:07:50,000 --> 00:08:00,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=500,336,100,56\n\n49\n00:08:00,000 --> 00:08:10,000\n3dk4NsRt6vWsffEr_sprite.jpg#xywh=600,336,100,56\n',
|
|
56
|
+
* sprite:
|
|
57
|
+
* 'https://static.gvideo.co/videoplatform/sprites/2675/2452164_3dk4NsRt6vWsffEr.mp4_sprite.jpg',
|
|
58
|
+
* },
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
36
62
|
export class Thumbnails extends UICorePlugin {
|
|
37
|
-
private _$spotlight: ZeptoResult | null = null
|
|
63
|
+
private _$spotlight: ZeptoResult | null = null
|
|
38
64
|
|
|
39
|
-
private _$backdrop: ZeptoResult | null = null
|
|
65
|
+
private _$backdrop: ZeptoResult | null = null
|
|
40
66
|
|
|
41
|
-
private $container: ZeptoResult | null = null
|
|
67
|
+
private $container: ZeptoResult | null = null
|
|
42
68
|
|
|
43
|
-
private $img: ZeptoResult | null = null
|
|
69
|
+
private $img: ZeptoResult | null = null
|
|
44
70
|
|
|
45
|
-
private _$carousel: ZeptoResult | null = null
|
|
71
|
+
private _$carousel: ZeptoResult | null = null
|
|
46
72
|
|
|
47
|
-
private $textThumbnail: ZeptoResult | null = null
|
|
73
|
+
private $textThumbnail: ZeptoResult | null = null
|
|
48
74
|
|
|
49
|
-
private _$backdropCarouselImgs: ZeptoResult[] = []
|
|
75
|
+
private _$backdropCarouselImgs: ZeptoResult[] = []
|
|
50
76
|
|
|
51
|
-
private spriteSheetHeight: number = 0
|
|
77
|
+
private spriteSheetHeight: number = 0
|
|
52
78
|
|
|
53
|
-
private _hoverPosition = 0
|
|
79
|
+
private _hoverPosition = 0
|
|
54
80
|
|
|
55
|
-
private _show = false
|
|
81
|
+
private _show = false
|
|
56
82
|
|
|
57
|
-
private _thumbsLoaded = false
|
|
83
|
+
private _thumbsLoaded = false
|
|
58
84
|
|
|
59
|
-
private _oldContainer: Container | null = null
|
|
85
|
+
private _oldContainer: Container | null = null
|
|
60
86
|
|
|
61
|
-
private _thumbs: Thumb[] = []
|
|
87
|
+
private _thumbs: Thumb[] = []
|
|
62
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
63
92
|
get name() {
|
|
64
|
-
return '
|
|
93
|
+
return 'thumbnails'
|
|
65
94
|
}
|
|
66
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
67
99
|
get supportedVersion() {
|
|
68
|
-
return { min: CLAPPR_VERSION }
|
|
100
|
+
return { min: CLAPPR_VERSION }
|
|
69
101
|
}
|
|
70
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
71
106
|
override get attributes() {
|
|
72
107
|
return {
|
|
73
|
-
|
|
74
|
-
}
|
|
108
|
+
class: this.name,
|
|
109
|
+
}
|
|
75
110
|
}
|
|
76
111
|
|
|
77
|
-
|
|
78
|
-
return template(pluginHtml);
|
|
79
|
-
}
|
|
112
|
+
private static readonly template = template(pluginHtml)
|
|
80
113
|
|
|
81
114
|
/*
|
|
82
115
|
* Helper to build the "thumbs" property for a sprite sheet.
|
|
@@ -91,21 +124,21 @@ export class Thumbnails extends UICorePlugin {
|
|
|
91
124
|
*/
|
|
92
125
|
// buildSpriteConfig(vtt, spriteSheetUrl, numThumbs, thumbWidth, thumbHeight, numColumns, timeInterval, startTime) {
|
|
93
126
|
private buildSpriteConfig(vtt: ParsedSRT[], spriteSheetUrl: string): Thumb[] {
|
|
94
|
-
const thumbs: Thumb[] = []
|
|
127
|
+
const thumbs: Thumb[] = []
|
|
95
128
|
// let coor: string[] = [];
|
|
96
129
|
|
|
97
130
|
for (const vt of vtt) {
|
|
98
|
-
const el = vt.text
|
|
131
|
+
const el = vt.text
|
|
99
132
|
// if (el && el.search(/\d*,\d*,\d*,\d*/g) > -1) {
|
|
100
133
|
// el = el.match(/\d*,\d*,\d*,\d*/g)[0];
|
|
101
134
|
// coor = el.split(',');
|
|
102
135
|
// }
|
|
103
136
|
if (el) {
|
|
104
|
-
const m = el.match(/xywh=\d*,\d*,\d*,\d*/g)
|
|
137
|
+
const m = el.match(/xywh=\d*,\d*,\d*,\d*/g)
|
|
105
138
|
if (m) {
|
|
106
|
-
const coor = m[0].split(',')
|
|
107
|
-
const w = parseInt(coor[2], 10)
|
|
108
|
-
const h = parseInt(coor[3], 10)
|
|
139
|
+
const coor = m[0].split(',')
|
|
140
|
+
const w = parseInt(coor[2], 10)
|
|
141
|
+
const h = parseInt(coor[3], 10)
|
|
109
142
|
if (w > 0 && h > 0) {
|
|
110
143
|
thumbs.push({
|
|
111
144
|
url: spriteSheetUrl,
|
|
@@ -114,101 +147,135 @@ export class Thumbnails extends UICorePlugin {
|
|
|
114
147
|
h,
|
|
115
148
|
x: parseInt(coor[0], 10) || 0,
|
|
116
149
|
y: parseInt(coor[1], 10) || 0,
|
|
117
|
-
})
|
|
150
|
+
})
|
|
118
151
|
}
|
|
119
152
|
}
|
|
120
153
|
}
|
|
121
154
|
}
|
|
122
155
|
|
|
123
|
-
return thumbs
|
|
156
|
+
return thumbs
|
|
124
157
|
}
|
|
125
158
|
|
|
126
159
|
// TODO check if seek enabled
|
|
127
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
128
164
|
override bindEvents() {
|
|
129
|
-
this.listenToOnce(this.core, Events.CORE_READY, this._onCoreReady)
|
|
130
|
-
this.listenTo(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
165
|
+
this.listenToOnce(this.core, Events.CORE_READY, this._onCoreReady)
|
|
166
|
+
this.listenTo(
|
|
167
|
+
this.core.mediaControl,
|
|
168
|
+
Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR,
|
|
169
|
+
this._onMouseMove,
|
|
170
|
+
)
|
|
171
|
+
this.listenTo(
|
|
172
|
+
this.core.mediaControl,
|
|
173
|
+
Events.MEDIACONTROL_MOUSELEAVE_SEEKBAR,
|
|
174
|
+
this._onMouseLeave,
|
|
175
|
+
)
|
|
176
|
+
this.listenTo(
|
|
177
|
+
this.core.mediaControl,
|
|
178
|
+
Events.MEDIACONTROL_RENDERED,
|
|
179
|
+
this._init,
|
|
180
|
+
)
|
|
181
|
+
this.listenTo(
|
|
182
|
+
this.core.mediaControl,
|
|
183
|
+
Events.MEDIACONTROL_CONTAINERCHANGED,
|
|
184
|
+
this._onMediaControlContainerChanged,
|
|
185
|
+
)
|
|
134
186
|
}
|
|
135
187
|
|
|
136
188
|
private _bindContainerEvents() {
|
|
137
189
|
if (this._oldContainer) {
|
|
138
|
-
this.stopListening(
|
|
190
|
+
this.stopListening(
|
|
191
|
+
this._oldContainer,
|
|
192
|
+
Events.CONTAINER_TIMEUPDATE,
|
|
193
|
+
this._renderPlugin,
|
|
194
|
+
)
|
|
139
195
|
}
|
|
140
|
-
this._oldContainer = this.core.mediaControl.container
|
|
141
|
-
this.listenTo(
|
|
196
|
+
this._oldContainer = this.core.mediaControl.container
|
|
197
|
+
this.listenTo(
|
|
198
|
+
this.core.mediaControl.container,
|
|
199
|
+
Events.CONTAINER_TIMEUPDATE,
|
|
200
|
+
this._renderPlugin,
|
|
201
|
+
)
|
|
142
202
|
}
|
|
143
203
|
|
|
144
204
|
private _onCoreReady() {
|
|
145
205
|
try {
|
|
146
|
-
if (
|
|
147
|
-
this.
|
|
148
|
-
|
|
149
|
-
|
|
206
|
+
if (
|
|
207
|
+
!this.options.thumbnails ||
|
|
208
|
+
!this.options.thumbnails.sprite ||
|
|
209
|
+
!this.options.thumbnails.vtt
|
|
210
|
+
) {
|
|
211
|
+
this.destroy()
|
|
212
|
+
|
|
213
|
+
return
|
|
150
214
|
}
|
|
151
215
|
} catch (error) {
|
|
152
|
-
reportError(error)
|
|
216
|
+
reportError(error)
|
|
153
217
|
|
|
154
|
-
return
|
|
218
|
+
return
|
|
155
219
|
}
|
|
156
220
|
// TODO options
|
|
157
|
-
const spriteSheet = this.options.thumbnails.sprite
|
|
158
|
-
this._thumbs = this.buildSpriteConfig(
|
|
221
|
+
const spriteSheet = this.options.thumbnails.sprite
|
|
222
|
+
this._thumbs = this.buildSpriteConfig(
|
|
223
|
+
parseSRT(this.options.thumbnails.vtt),
|
|
224
|
+
spriteSheet,
|
|
225
|
+
)
|
|
159
226
|
if (!this._thumbs.length) {
|
|
160
|
-
this.destroy()
|
|
161
|
-
return
|
|
227
|
+
this.destroy()
|
|
228
|
+
return
|
|
162
229
|
}
|
|
163
230
|
this.loadSpriteSheet(spriteSheet).then(() => {
|
|
164
|
-
this._thumbsLoaded = true
|
|
165
|
-
this.core.options.thumbnails.spotlightHeight = this._thumbs[0].h
|
|
166
|
-
this._init()
|
|
231
|
+
this._thumbsLoaded = true
|
|
232
|
+
this.core.options.thumbnails.spotlightHeight = this._thumbs[0].h
|
|
233
|
+
this._init()
|
|
167
234
|
})
|
|
168
235
|
}
|
|
169
236
|
|
|
170
237
|
private async loadSpriteSheet(spriteSheetUrl: string): Promise<void> {
|
|
171
238
|
return new Promise((resolve, reject) => {
|
|
172
|
-
const img = new Image()
|
|
239
|
+
const img = new Image()
|
|
173
240
|
img.onload = () => {
|
|
174
|
-
this.spriteSheetHeight = img.height
|
|
175
|
-
resolve()
|
|
176
|
-
}
|
|
177
|
-
img.onerror = reject
|
|
178
|
-
img.src = spriteSheetUrl
|
|
179
|
-
})
|
|
241
|
+
this.spriteSheetHeight = img.height
|
|
242
|
+
resolve()
|
|
243
|
+
}
|
|
244
|
+
img.onerror = reject
|
|
245
|
+
img.src = spriteSheetUrl
|
|
246
|
+
})
|
|
180
247
|
}
|
|
181
248
|
|
|
182
249
|
private _onMediaControlContainerChanged() {
|
|
183
|
-
this._bindContainerEvents()
|
|
250
|
+
this._bindContainerEvents()
|
|
184
251
|
}
|
|
185
252
|
|
|
186
253
|
private _init() {
|
|
187
254
|
if (!this._thumbsLoaded) {
|
|
188
255
|
// _init() will be called when the thumbs are loaded,
|
|
189
256
|
// and whenever the media control rendered event is fired as just before this the dom elements get wiped in IE (https://github.com/tjenkinson/clappr-thumbnails-plugin/issues/5)
|
|
190
|
-
return
|
|
257
|
+
return
|
|
191
258
|
}
|
|
192
259
|
// Init the backdropCarousel as array to keep reference of thumbnail images
|
|
193
|
-
this._$backdropCarouselImgs = []
|
|
260
|
+
this._$backdropCarouselImgs = []
|
|
194
261
|
// create/recreate the dom elements for the plugin
|
|
195
|
-
this._createElements()
|
|
196
|
-
this._loadBackdrop()
|
|
197
|
-
this._renderPlugin()
|
|
262
|
+
this._createElements()
|
|
263
|
+
this._loadBackdrop()
|
|
264
|
+
this._renderPlugin()
|
|
198
265
|
}
|
|
199
266
|
|
|
200
|
-
private _getOptions():
|
|
267
|
+
private _getOptions(): ThumbnailsPluginSettings {
|
|
201
268
|
if (!('thumbnails' in this.core.options)) {
|
|
202
|
-
throw '
|
|
269
|
+
throw "'thumbnail property missing from options object."
|
|
203
270
|
}
|
|
204
271
|
|
|
205
|
-
return this.core.options.thumbnails
|
|
272
|
+
return this.core.options.thumbnails
|
|
206
273
|
}
|
|
207
274
|
|
|
208
275
|
private _appendElToMediaControl() {
|
|
209
276
|
// insert after the background
|
|
210
|
-
this.core.mediaControl.$el.find('.seek-time').css('bottom', 56)
|
|
211
|
-
this.core.mediaControl.$el.first().after(this.el)
|
|
277
|
+
this.core.mediaControl.$el.find('.seek-time').css('bottom', 56)
|
|
278
|
+
this.core.mediaControl.$el.first().after(this.el)
|
|
212
279
|
}
|
|
213
280
|
|
|
214
281
|
private _onMouseMove(e: MouseEvent) {
|
|
@@ -217,21 +284,25 @@ export class Thumbnails extends UICorePlugin {
|
|
|
217
284
|
// t: typeof e,
|
|
218
285
|
// t2: typeof arguments[1],
|
|
219
286
|
// });
|
|
220
|
-
this._calculateHoverPosition(e)
|
|
221
|
-
this._show = true
|
|
222
|
-
this._renderPlugin()
|
|
287
|
+
this._calculateHoverPosition(e)
|
|
288
|
+
this._show = true
|
|
289
|
+
this._renderPlugin()
|
|
223
290
|
}
|
|
224
291
|
|
|
225
292
|
private _onMouseLeave() {
|
|
226
|
-
this._show = false
|
|
227
|
-
this._renderPlugin()
|
|
293
|
+
this._show = false
|
|
294
|
+
this._renderPlugin()
|
|
228
295
|
}
|
|
229
296
|
|
|
230
297
|
private _calculateHoverPosition(e: MouseEvent) {
|
|
231
|
-
const offset =
|
|
298
|
+
const offset =
|
|
299
|
+
getPageX(e) - this.core.mediaControl.$seekBarContainer.offset().left
|
|
232
300
|
|
|
233
301
|
// proportion into the seek bar that the mouse is hovered over 0-1
|
|
234
|
-
this._hoverPosition = Math.min(
|
|
302
|
+
this._hoverPosition = Math.min(
|
|
303
|
+
1,
|
|
304
|
+
Math.max(offset / this.core.mediaControl.$seekBarContainer.width(), 0),
|
|
305
|
+
)
|
|
235
306
|
}
|
|
236
307
|
|
|
237
308
|
// private _buildThumbsFromOptions() {
|
|
@@ -304,56 +375,56 @@ export class Thumbnails extends UICorePlugin {
|
|
|
304
375
|
// builds a dom element which represents the thumbnail
|
|
305
376
|
// scaled to the provided height
|
|
306
377
|
private _buildImg(thumb: Thumb, height: number) {
|
|
307
|
-
const scaleFactor = height / thumb.h
|
|
378
|
+
const scaleFactor = height / thumb.h
|
|
308
379
|
|
|
309
380
|
if (!this.$img) {
|
|
310
|
-
this.$img = $('<img />').addClass('thumbnail-img').attr('src', thumb.url)
|
|
381
|
+
this.$img = $('<img />').addClass('thumbnail-img').attr('src', thumb.url)
|
|
311
382
|
}
|
|
312
383
|
|
|
313
384
|
// the container will contain the image positioned so that the correct sprite
|
|
314
385
|
// is visible
|
|
315
386
|
if (!this.$container) {
|
|
316
|
-
this.$container = $('<div />').addClass('thumbnail-container')
|
|
387
|
+
this.$container = $('<div />').addClass('thumbnail-container')
|
|
317
388
|
}
|
|
318
389
|
|
|
319
|
-
this.$container.css('width', thumb.w * scaleFactor)
|
|
320
|
-
this.$container.css('height', height)
|
|
390
|
+
this.$container.css('width', thumb.w * scaleFactor)
|
|
391
|
+
this.$container.css('height', height)
|
|
321
392
|
this.$img.css({
|
|
322
393
|
height: this.spriteSheetHeight * scaleFactor,
|
|
323
394
|
left: -1 * thumb.x * scaleFactor,
|
|
324
|
-
top: -1 * thumb.y * scaleFactor
|
|
325
|
-
})
|
|
395
|
+
top: -1 * thumb.y * scaleFactor,
|
|
396
|
+
})
|
|
326
397
|
if (this.$container.find(this.$img).length === 0) {
|
|
327
|
-
this.$container.append(this.$img)
|
|
398
|
+
this.$container.append(this.$img)
|
|
328
399
|
}
|
|
329
400
|
|
|
330
|
-
return this.$container
|
|
401
|
+
return this.$container
|
|
331
402
|
}
|
|
332
403
|
|
|
333
404
|
private _loadBackdrop() {
|
|
334
405
|
if (!this._getOptions().backdropHeight) {
|
|
335
406
|
// disabled
|
|
336
|
-
return
|
|
407
|
+
return
|
|
337
408
|
}
|
|
338
409
|
|
|
339
410
|
// append each of the thumbnails to the backdrop carousel
|
|
340
|
-
const $carousel = this._$carousel
|
|
411
|
+
const $carousel = this._$carousel
|
|
341
412
|
|
|
342
413
|
for (const thumb of this._thumbs) {
|
|
343
|
-
const $img = this._buildImg(thumb, this._getOptions().backdropHeight)
|
|
414
|
+
const $img = this._buildImg(thumb, this._getOptions().backdropHeight)
|
|
344
415
|
|
|
345
416
|
// Keep reference to thumbnail
|
|
346
|
-
this._$backdropCarouselImgs.push($img)
|
|
417
|
+
this._$backdropCarouselImgs.push($img)
|
|
347
418
|
// Add thumbnail to DOM
|
|
348
|
-
$carousel.append($img)
|
|
419
|
+
$carousel.append($img)
|
|
349
420
|
}
|
|
350
421
|
}
|
|
351
422
|
|
|
352
|
-
setText(time: TimeValue) {
|
|
423
|
+
private setText(time: TimeValue) {
|
|
353
424
|
if (this.core.getPlugin('clips')) {
|
|
354
|
-
const txt = this.core.getPlugin('clips').getText(time)
|
|
425
|
+
const txt = this.core.getPlugin('clips').getText(time)
|
|
355
426
|
|
|
356
|
-
this.$textThumbnail.text(txt)
|
|
427
|
+
this.$textThumbnail.text(txt)
|
|
357
428
|
}
|
|
358
429
|
}
|
|
359
430
|
|
|
@@ -362,133 +433,138 @@ export class Thumbnails extends UICorePlugin {
|
|
|
362
433
|
private _updateCarousel() {
|
|
363
434
|
trace(`${T} _updateCarousel`, {
|
|
364
435
|
backdropHeight: this._getOptions().backdropHeight,
|
|
365
|
-
})
|
|
436
|
+
})
|
|
366
437
|
if (!this._getOptions().backdropHeight) {
|
|
367
438
|
// disabled
|
|
368
|
-
return
|
|
439
|
+
return
|
|
369
440
|
}
|
|
370
441
|
|
|
371
|
-
const hoverPosition = this._hoverPosition
|
|
372
|
-
const videoDuration = this.core.mediaControl.container.getDuration()
|
|
373
|
-
const startTimeOffset =
|
|
442
|
+
const hoverPosition = this._hoverPosition
|
|
443
|
+
const videoDuration = this.core.mediaControl.container.getDuration()
|
|
444
|
+
const startTimeOffset =
|
|
445
|
+
this.core.mediaControl.container.getStartTimeOffset()
|
|
374
446
|
// the time into the video at the current hover position
|
|
375
|
-
const hoverTime = startTimeOffset +
|
|
376
|
-
const backdropWidth = this._$backdrop.width()
|
|
377
|
-
const $carousel = this._$carousel
|
|
378
|
-
const carouselWidth = $carousel.width()
|
|
447
|
+
const hoverTime = startTimeOffset + videoDuration * hoverPosition
|
|
448
|
+
const backdropWidth = this._$backdrop.width()
|
|
449
|
+
const $carousel = this._$carousel
|
|
450
|
+
const carouselWidth = $carousel.width()
|
|
379
451
|
|
|
380
452
|
// slide the carousel so that the image on the carousel that is above where the person
|
|
381
453
|
// is hovering maps to that position in time.
|
|
382
454
|
// Thumbnails may not be distributed at even times along the video
|
|
383
|
-
const thumbs = this._thumbs
|
|
455
|
+
const thumbs = this._thumbs
|
|
384
456
|
|
|
385
457
|
// assuming that each thumbnail has the same width
|
|
386
|
-
const thumbWidth = carouselWidth / thumbs.length
|
|
458
|
+
const thumbWidth = carouselWidth / thumbs.length
|
|
387
459
|
|
|
388
460
|
// determine which thumbnail applies to the current time
|
|
389
|
-
const thumbIndex = this._getThumbIndexForTime(hoverTime)
|
|
390
|
-
const thumb = thumbs[thumbIndex]
|
|
391
|
-
let thumbDuration = thumb.duration
|
|
461
|
+
const thumbIndex = this._getThumbIndexForTime(hoverTime)
|
|
462
|
+
const thumb = thumbs[thumbIndex]
|
|
463
|
+
let thumbDuration = thumb.duration
|
|
392
464
|
|
|
393
465
|
if (!thumbDuration) {
|
|
394
466
|
// the last thumbnail duration will be null as it can't be determined
|
|
395
467
|
// e.g the duration of the video may increase over time (live stream)
|
|
396
468
|
// so calculate the duration now so this last thumbnail lasts till the end
|
|
397
|
-
thumbDuration = Math.max(videoDuration + startTimeOffset - thumb.time, 0)
|
|
469
|
+
thumbDuration = Math.max(videoDuration + startTimeOffset - thumb.time, 0)
|
|
398
470
|
}
|
|
399
471
|
|
|
400
472
|
// determine how far accross that thumbnail we are
|
|
401
|
-
const timeIntoThumb = hoverTime - thumb.time
|
|
402
|
-
const positionInThumb = timeIntoThumb / thumbDuration
|
|
403
|
-
const xCoordInThumb = thumbWidth * positionInThumb
|
|
473
|
+
const timeIntoThumb = hoverTime - thumb.time
|
|
474
|
+
const positionInThumb = timeIntoThumb / thumbDuration
|
|
475
|
+
const xCoordInThumb = thumbWidth * positionInThumb
|
|
404
476
|
|
|
405
477
|
// now calculate the position along carousel that we want to be above the hover position
|
|
406
|
-
const xCoordInCarousel =
|
|
478
|
+
const xCoordInCarousel = thumbIndex * thumbWidth + xCoordInThumb
|
|
407
479
|
// and finally the position of the carousel when the hover position is taken in to consideration
|
|
408
|
-
const carouselXCoord = xCoordInCarousel -
|
|
480
|
+
const carouselXCoord = xCoordInCarousel - hoverPosition * backdropWidth
|
|
409
481
|
|
|
410
|
-
$carousel.css('left', -carouselXCoord)
|
|
482
|
+
$carousel.css('left', -carouselXCoord)
|
|
411
483
|
|
|
412
|
-
const maxOpacity = this._getOptions().backdropMaxOpacity || 0.6
|
|
413
|
-
const minOpacity = this._getOptions().backdropMinOpacity || 0.08
|
|
484
|
+
const maxOpacity = this._getOptions().backdropMaxOpacity || 0.6
|
|
485
|
+
const minOpacity = this._getOptions().backdropMinOpacity || 0.08
|
|
414
486
|
|
|
415
487
|
// now update the transparencies so that they fade in around the active one
|
|
416
488
|
for (let i = 0; i < thumbs.length; i++) {
|
|
417
|
-
const thumbXCoord = thumbWidth * i
|
|
418
|
-
let distance = thumbXCoord - xCoordInCarousel
|
|
489
|
+
const thumbXCoord = thumbWidth * i
|
|
490
|
+
let distance = thumbXCoord - xCoordInCarousel
|
|
419
491
|
|
|
420
492
|
if (distance < 0) {
|
|
421
493
|
// adjust so that distance is always a measure away from
|
|
422
494
|
// each side of the active thumbnail
|
|
423
495
|
// at every point on the active thumbnail the distance should
|
|
424
496
|
// be 0
|
|
425
|
-
distance = Math.min(0, distance + thumbWidth)
|
|
497
|
+
distance = Math.min(0, distance + thumbWidth)
|
|
426
498
|
}
|
|
427
499
|
// fade over the width of 2 thumbnails
|
|
428
|
-
const opacity = Math.max(
|
|
500
|
+
const opacity = Math.max(
|
|
501
|
+
maxOpacity - Math.abs(distance) / (2 * thumbWidth),
|
|
502
|
+
minOpacity,
|
|
503
|
+
)
|
|
429
504
|
|
|
430
|
-
this._$backdropCarouselImgs[i].css('opacity', opacity)
|
|
505
|
+
this._$backdropCarouselImgs[i].css('opacity', opacity)
|
|
431
506
|
}
|
|
432
507
|
}
|
|
433
508
|
|
|
434
509
|
private _updateSpotlightThumb() {
|
|
435
510
|
trace(`${T} _updateSpotlightThumb`, {
|
|
436
511
|
spotlightHeight: this._getOptions().spotlightHeight,
|
|
437
|
-
})
|
|
512
|
+
})
|
|
438
513
|
if (!this._getOptions().spotlightHeight) {
|
|
439
514
|
// disabled
|
|
440
|
-
return
|
|
515
|
+
return
|
|
441
516
|
}
|
|
442
517
|
|
|
443
|
-
const hoverPosition = this._hoverPosition
|
|
444
|
-
const videoDuration = this.core.mediaControl.container.getDuration()
|
|
518
|
+
const hoverPosition = this._hoverPosition
|
|
519
|
+
const videoDuration = this.core.mediaControl.container.getDuration()
|
|
445
520
|
// the time into the video at the current hover position
|
|
446
|
-
const startTimeOffset =
|
|
447
|
-
|
|
521
|
+
const startTimeOffset =
|
|
522
|
+
this.core.mediaControl.container.getStartTimeOffset()
|
|
523
|
+
const hoverTime = startTimeOffset + videoDuration * hoverPosition
|
|
448
524
|
|
|
449
|
-
this.setText(hoverTime)
|
|
525
|
+
this.setText(hoverTime)
|
|
450
526
|
|
|
451
527
|
// determine which thumbnail applies to the current time
|
|
452
|
-
const thumbIndex = this._getThumbIndexForTime(hoverTime)
|
|
453
|
-
const thumb = this._thumbs[thumbIndex]
|
|
528
|
+
const thumbIndex = this._getThumbIndexForTime(hoverTime)
|
|
529
|
+
const thumb = this._thumbs[thumbIndex]
|
|
454
530
|
|
|
455
531
|
// update thumbnail
|
|
456
|
-
const $spotlight = this._$spotlight
|
|
532
|
+
const $spotlight = this._$spotlight
|
|
457
533
|
|
|
458
|
-
$spotlight.empty()
|
|
459
|
-
$spotlight.append(this._buildImg(thumb, this._getOptions().spotlightHeight))
|
|
534
|
+
$spotlight.empty()
|
|
535
|
+
$spotlight.append(this._buildImg(thumb, this._getOptions().spotlightHeight))
|
|
460
536
|
|
|
461
|
-
const elWidth = this.$el.width()
|
|
462
|
-
const thumbWidth = $spotlight.width()
|
|
463
|
-
const thumbHeight = $spotlight.height()
|
|
537
|
+
const elWidth = this.$el.width()
|
|
538
|
+
const thumbWidth = $spotlight.width()
|
|
539
|
+
const thumbHeight = $spotlight.height()
|
|
464
540
|
|
|
465
|
-
let spotlightXPos =
|
|
541
|
+
let spotlightXPos = elWidth * hoverPosition - thumbWidth / 2
|
|
466
542
|
|
|
467
543
|
// adjust so the entire thumbnail is always visible
|
|
468
|
-
spotlightXPos = Math.max(Math.min(spotlightXPos, elWidth - thumbWidth), 0)
|
|
544
|
+
spotlightXPos = Math.max(Math.min(spotlightXPos, elWidth - thumbWidth), 0)
|
|
469
545
|
|
|
470
|
-
$spotlight.css('left', spotlightXPos)
|
|
546
|
+
$spotlight.css('left', spotlightXPos)
|
|
471
547
|
|
|
472
|
-
this.$textThumbnail.css('left', spotlightXPos)
|
|
473
|
-
this.$textThumbnail.css('width', thumbWidth)
|
|
474
|
-
this.$textThumbnail.css('bottom', thumbHeight + 1)
|
|
548
|
+
this.$textThumbnail.css('left', spotlightXPos)
|
|
549
|
+
this.$textThumbnail.css('width', thumbWidth)
|
|
550
|
+
this.$textThumbnail.css('bottom', thumbHeight + 1)
|
|
475
551
|
}
|
|
476
552
|
|
|
477
553
|
// returns the thumbnail which represents a time in the video
|
|
478
554
|
// or null if there is no thumbnail that can represent the time
|
|
479
555
|
private _getThumbIndexForTime(time: TimeValue) {
|
|
480
|
-
const thumbs = this._thumbs
|
|
556
|
+
const thumbs = this._thumbs
|
|
481
557
|
|
|
482
558
|
for (let i = thumbs.length - 1; i >= 0; i--) {
|
|
483
|
-
const thumb = thumbs[i]
|
|
559
|
+
const thumb = thumbs[i]
|
|
484
560
|
|
|
485
561
|
if (thumb.time <= time) {
|
|
486
|
-
return i
|
|
562
|
+
return i
|
|
487
563
|
}
|
|
488
564
|
}
|
|
489
565
|
|
|
490
566
|
// stretch the first thumbnail back to the start
|
|
491
|
-
return 0
|
|
567
|
+
return 0
|
|
492
568
|
}
|
|
493
569
|
|
|
494
570
|
private _renderPlugin() {
|
|
@@ -496,35 +572,33 @@ export class Thumbnails extends UICorePlugin {
|
|
|
496
572
|
show: this._show,
|
|
497
573
|
thumbsLoaded: this._thumbsLoaded,
|
|
498
574
|
thumbs: this._thumbs.length,
|
|
499
|
-
})
|
|
575
|
+
})
|
|
500
576
|
if (!this._thumbsLoaded) {
|
|
501
|
-
return
|
|
577
|
+
return
|
|
502
578
|
}
|
|
503
579
|
if (this._show && this._thumbs.length > 0) {
|
|
504
|
-
this.$el.removeClass('hidden')
|
|
505
|
-
this._updateCarousel()
|
|
506
|
-
this._updateSpotlightThumb()
|
|
580
|
+
this.$el.removeClass('hidden')
|
|
581
|
+
this._updateCarousel()
|
|
582
|
+
this._updateSpotlightThumb()
|
|
507
583
|
} else {
|
|
508
|
-
this.$el.addClass('hidden')
|
|
584
|
+
this.$el.addClass('hidden')
|
|
509
585
|
}
|
|
510
586
|
}
|
|
511
587
|
|
|
512
588
|
private _createElements() {
|
|
513
|
-
trace(`${T} _createElements`)
|
|
589
|
+
trace(`${T} _createElements`)
|
|
514
590
|
this.$el.html(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
)
|
|
521
|
-
);
|
|
591
|
+
Thumbnails.template({
|
|
592
|
+
backdropHeight: this._getOptions().backdropHeight,
|
|
593
|
+
spotlightHeight: this._getOptions().spotlightHeight,
|
|
594
|
+
}),
|
|
595
|
+
)
|
|
522
596
|
// cache dom references
|
|
523
|
-
this._$spotlight = this.$el.find('.spotlight')
|
|
524
|
-
this._$backdrop = this.$el.find('.backdrop')
|
|
525
|
-
this._$carousel = this._$backdrop.find('.carousel')
|
|
526
|
-
this.$textThumbnail = this.$el.find('.thumbnails-text')
|
|
527
|
-
this.$el.addClass('hidden')
|
|
528
|
-
this._appendElToMediaControl()
|
|
597
|
+
this._$spotlight = this.$el.find('.spotlight')
|
|
598
|
+
this._$backdrop = this.$el.find('.backdrop')
|
|
599
|
+
this._$carousel = this._$backdrop.find('.carousel')
|
|
600
|
+
this.$textThumbnail = this.$el.find('.thumbnails-text')
|
|
601
|
+
this.$el.addClass('hidden')
|
|
602
|
+
this._appendElToMediaControl()
|
|
529
603
|
}
|
|
530
604
|
}
|