@gcorevideo/player 2.18.3 → 2.19.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/assets/audio-selector/style.scss +156 -0
- package/assets/audio-selector/track-selector.ejs +12 -0
- package/assets/big-mute-button/big-mute-button.ejs +3 -0
- package/assets/big-mute-button/big-mute-button.scss +57 -0
- package/assets/bottom-gear/bottomgear.ejs +12 -0
- package/assets/bottom-gear/gear-sub-menu.scss +95 -0
- package/assets/bottom-gear/gear.scss +79 -0
- package/assets/clappr-nerd-stats/button.ejs +4 -0
- package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +212 -0
- package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +488 -0
- package/assets/clappr-nerd-stats/options-list.ejs +9 -0
- package/assets/clappr-nerd-stats/settings.ejs +12 -0
- package/assets/clappr-nerd-stats/speedtest/speedtest.worker.js +775 -0
- package/assets/clips/clips.scss +3 -0
- package/assets/context-menu/context_menu.ejs +8 -0
- package/assets/context-menu/context_menu.scss +31 -0
- package/assets/dvr-controls/dvr_controls.scss +136 -0
- package/assets/dvr-controls/index.ejs +2 -0
- package/assets/error-screen/error_screen.ejs +13 -0
- package/assets/error-screen/error_screen.scss +40 -0
- package/assets/icons/new/arrow-left.svg +5 -0
- package/assets/icons/new/arrow-right.svg +5 -0
- package/assets/icons/new/check.svg +5 -0
- package/assets/icons/new/close.svg +12 -0
- package/assets/icons/new/full.svg +8 -0
- package/assets/icons/new/fullscreen-off.svg +14 -0
- package/assets/icons/new/fullscreen-on.svg +14 -0
- package/assets/icons/new/gear-hd.svg +16 -0
- package/assets/icons/new/gear.svg +12 -0
- package/assets/icons/new/hd.svg +8 -0
- package/assets/icons/new/pause.svg +5 -0
- package/assets/icons/new/pip.svg +5 -0
- package/assets/icons/new/play.svg +10 -0
- package/assets/icons/new/replayleft.svg +5 -0
- package/assets/icons/new/replayright.svg +5 -0
- package/assets/icons/new/speed.svg +5 -0
- package/assets/icons/new/stats.svg +3 -0
- package/assets/icons/new/stop.svg +3 -0
- package/assets/icons/new/subtitles-off.svg +5 -0
- package/assets/icons/new/subtitles-on.svg +6 -0
- package/assets/icons/new/volume-max.svg +5 -0
- package/assets/icons/new/volume-min.svg +5 -0
- package/assets/icons/new/volume-off.svg +5 -0
- package/assets/icons/old/cardboard.svg +4 -0
- package/assets/icons/old/close-share.svg +13 -0
- package/assets/icons/old/close.svg +13 -0
- package/assets/icons/old/fb.svg +13 -0
- package/assets/icons/old/fullscreen.svg +12 -0
- package/assets/icons/old/language.svg +1 -0
- package/assets/icons/old/pause.svg +12 -0
- package/assets/icons/old/play.svg +12 -0
- package/assets/icons/old/quality-arrow.svg +13 -0
- package/assets/icons/old/reload.svg +4 -0
- package/assets/icons/old/share.svg +13 -0
- package/assets/icons/old/sound-off.svg +15 -0
- package/assets/icons/old/sound-on.svg +15 -0
- package/assets/icons/old/streams.svg +3 -0
- package/assets/icons/old/twitter.svg +13 -0
- package/assets/icons/old/wn.svg +15 -0
- package/assets/icons/standard/01-play.svg +3 -0
- package/assets/icons/standard/02-pause.svg +3 -0
- package/assets/icons/standard/03-stop.svg +3 -0
- package/assets/icons/standard/04-volume.svg +3 -0
- package/assets/icons/standard/05-mute.svg +3 -0
- package/assets/icons/standard/06-expand.svg +3 -0
- package/assets/icons/standard/07-shrink.svg +3 -0
- package/assets/icons/standard/08-hd.svg +3 -0
- package/assets/icons/standard/09-cc.svg +8 -0
- package/assets/icons/standard/10-reload.svg +4 -0
- package/assets/level-selector/button.ejs +8 -0
- package/assets/level-selector/list.ejs +22 -0
- package/assets/level-selector/style.scss +4 -0
- package/assets/logo/styles/logo.scss +10 -0
- package/assets/logo/templates/logo.ejs +3 -0
- package/assets/media-control/closed-hand.cur +0 -0
- package/assets/media-control/container.scss +57 -0
- package/assets/media-control/media-control.ejs +133 -0
- package/assets/media-control/media-control.scss +390 -0
- package/assets/media-control/plugins.scss +94 -0
- package/assets/media-control/width270.scss +50 -0
- package/assets/media-control/width370.scss +263 -0
- package/assets/multi-camera/multicamera.ejs +29 -0
- package/assets/multi-camera/style.scss +176 -0
- package/assets/picture-in-picture/button.ejs +3 -0
- package/assets/picture-in-picture/button.scss +11 -0
- package/assets/playback-rate/button.ejs +6 -0
- package/assets/playback-rate/list.ejs +14 -0
- package/assets/playback-rate/playback-rate-selector.ejs +9 -0
- package/assets/poster/poster.ejs +1 -0
- package/assets/poster/poster.scss +32 -0
- package/assets/seek-time/seek-time.html +2 -0
- package/assets/seek-time/seek-time.scss +38 -0
- package/assets/share/share.ejs +37 -0
- package/assets/share/style.scss +104 -0
- package/assets/skip-time/skip-time.ejs +8 -0
- package/assets/skip-time/style.scss +24 -0
- package/assets/spinner-three-bounce/spinner.ejs +3 -0
- package/assets/spinner-three-bounce/spinner.scss +44 -0
- package/assets/style/main.scss +50 -0
- package/assets/style/theme.scss +42 -0
- package/assets/style/variables.scss +7 -0
- package/assets/subtitles/combobox copy.ejs +16 -0
- package/assets/subtitles/combobox.ejs +16 -0
- package/assets/subtitles/string.ejs +3 -0
- package/assets/subtitles/style.scss +99 -0
- package/assets/thumbnails/scrub-thumbnails.ejs +10 -0
- package/assets/thumbnails/style.scss +75 -0
- package/assets/vast-ads/style.scss +112 -0
- package/assets/video360/button.ejs +1 -0
- package/assets/video360/style.scss +8 -0
- package/build/vite-raw-plugin.js +18 -0
- package/dist/index.js +1 -1
- package/dist/plugins/index.css +2164 -0
- package/dist/plugins/index.js/index.plugins.js +40837 -0
- package/dist/plugins/index.plugins.js +40837 -0
- package/lib/index.core.d.ts +15 -0
- package/lib/index.core.d.ts.map +1 -0
- package/lib/index.core.js +14 -0
- package/lib/index.d.ts +2 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -14
- package/lib/index.plugins.d.ts +38 -0
- package/lib/index.plugins.d.ts.map +1 -0
- package/lib/index.plugins.js +40 -0
- package/lib/plugins/audio-selector/AudioSelector.d.ts +3 -3
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +6 -12
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +2 -2
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +7 -12
- package/lib/plugins/bottom-gear/BottomGear.d.ts +4 -3
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +11 -16
- package/lib/plugins/build.d.ts +2 -0
- package/lib/plugins/build.d.ts.map +1 -0
- package/lib/plugins/build.js +1 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +44 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +294 -0
- package/lib/plugins/clappr-nerd-stats/formatter.d.ts +8 -0
- package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/formatter.js +91 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts +54 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +335 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +9 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.js +154 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +6 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.js +1 -0
- package/lib/plugins/clappr-nerd-stats/types.d.ts +4 -0
- package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/types.js +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +56 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.js +332 -0
- package/lib/plugins/clappr-stats/types.d.ts +50 -0
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/types.js +5 -0
- package/lib/plugins/clappr-stats/utils.d.ts +3 -0
- package/lib/plugins/clappr-stats/utils.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/utils.js +40 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts +2 -2
- package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +4 -6
- package/lib/plugins/clips/Clips.d.ts +23 -0
- package/lib/plugins/clips/Clips.d.ts.map +1 -0
- package/lib/plugins/clips/Clips.js +109 -0
- package/lib/plugins/context-menu/ContextMenu.d.ts +36 -0
- package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -0
- package/lib/plugins/context-menu/ContextMenu.js +102 -0
- package/lib/plugins/disable-controls/DisableControls.d.ts +1 -1
- package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -1
- package/lib/plugins/disable-controls/DisableControls.js +3 -5
- package/lib/plugins/dvr-controls/DVRControls.d.ts +4 -4
- package/lib/plugins/dvr-controls/DVRControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DVRControls.js +5 -4
- package/lib/plugins/error-screen/ErrorScreen.d.ts +44 -0
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -0
- package/lib/plugins/error-screen/ErrorScreen.js +179 -0
- package/lib/plugins/favicon/Favicon.d.ts +24 -0
- package/lib/plugins/favicon/Favicon.d.ts.map +1 -0
- package/lib/plugins/favicon/Favicon.js +106 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +30 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.js +114 -0
- package/lib/plugins/index.d.ts +38 -0
- package/lib/plugins/index.d.ts.map +1 -0
- package/lib/plugins/index.js +40 -0
- package/lib/plugins/kibo/index.d.ts +23 -0
- package/lib/plugins/kibo/index.d.ts.map +1 -0
- package/lib/plugins/kibo/index.js +199 -0
- package/lib/plugins/level-selector/LevelSelector.d.ts +48 -17
- package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
- package/lib/plugins/level-selector/LevelSelector.js +169 -155
- package/lib/plugins/logo/Logo.d.ts +29 -0
- package/lib/plugins/logo/Logo.d.ts.map +1 -0
- package/lib/plugins/logo/Logo.js +181 -0
- package/lib/plugins/logo/utils/index.d.ts +22 -0
- package/lib/plugins/logo/utils/index.d.ts.map +1 -0
- package/lib/plugins/logo/utils/index.js +32 -0
- package/lib/plugins/media-control/MediaControl.d.ts +20 -25
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +136 -106
- package/lib/plugins/multi-camera/MultiCamera.d.ts +59 -0
- package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -0
- package/lib/plugins/multi-camera/MultiCamera.js +353 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +20 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.js +68 -0
- package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -0
- package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -0
- package/lib/plugins/playback-rate/PlaybackRate.js +205 -0
- package/lib/plugins/poster/Poster.d.ts +18 -17
- package/lib/plugins/poster/Poster.d.ts.map +1 -1
- package/lib/plugins/poster/Poster.js +83 -37
- package/lib/plugins/seek-time/SeekTime.d.ts +38 -0
- package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -0
- package/lib/plugins/seek-time/SeekTime.js +153 -0
- package/lib/plugins/share/Share.d.ts +38 -0
- package/lib/plugins/share/Share.d.ts.map +1 -0
- package/lib/plugins/share/Share.js +122 -0
- package/lib/plugins/skip-time/SkipTime.d.ts +28 -0
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -0
- package/lib/plugins/skip-time/SkipTime.js +86 -0
- package/lib/plugins/source-controller/SourceController.d.ts +41 -0
- package/lib/plugins/source-controller/SourceController.d.ts.map +1 -0
- package/lib/plugins/source-controller/SourceController.js +199 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +26 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +117 -0
- package/lib/plugins/statistics/Statistics.d.ts +52 -0
- package/lib/plugins/statistics/Statistics.d.ts.map +1 -0
- package/lib/plugins/statistics/Statistics.js +130 -0
- package/lib/plugins/subtitles/Subtitles.d.ts +61 -0
- package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -0
- package/lib/plugins/subtitles/Subtitles.js +354 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts +47 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -0
- package/lib/plugins/thumbnails/Thumbnails.js +414 -0
- package/lib/plugins/types.d.ts +8 -0
- package/lib/plugins/types.d.ts.map +1 -0
- package/lib/plugins/types.js +1 -0
- package/lib/plugins/utils.d.ts +5 -0
- package/lib/plugins/utils.d.ts.map +1 -0
- package/lib/plugins/utils.js +68 -0
- package/lib/plugins/vast-ads/VastAds.d.ts +72 -0
- package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -0
- package/lib/plugins/vast-ads/VastAds.js +686 -0
- package/lib/plugins/vast-ads/loaderxml.d.ts +32 -0
- package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -0
- package/lib/plugins/vast-ads/loaderxml.js +226 -0
- package/lib/plugins/vast-ads/roll.d.ts +60 -0
- package/lib/plugins/vast-ads/roll.d.ts.map +1 -0
- package/lib/plugins/vast-ads/roll.js +415 -0
- package/lib/plugins/vast-ads/rollmanager.d.ts +62 -0
- package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -0
- package/lib/plugins/vast-ads/rollmanager.js +347 -0
- package/lib/plugins/vast-ads/sctemanager.d.ts +18 -0
- package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -0
- package/lib/plugins/vast-ads/sctemanager.js +116 -0
- package/lib/plugins/vast-ads/types.d.ts +12 -0
- package/lib/plugins/vast-ads/types.d.ts.map +1 -0
- package/lib/plugins/vast-ads/types.js +1 -0
- package/lib/plugins/vast-ads/urlhandler.d.ts +4 -0
- package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -0
- package/lib/plugins/vast-ads/urlhandler.js +30 -0
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts +6 -0
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -0
- package/lib/plugins/vast-ads/xmlhttprequest.js +39 -0
- package/lib/plugins/vast-ads/xmlmerge.d.ts +12 -0
- package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -0
- package/lib/plugins/vast-ads/xmlmerge.js +82 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts +21 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -0
- package/lib/plugins/volume-fade/VolumeFade.js +90 -0
- package/package.json +10 -2
- package/rollup.config.js +32 -2
- package/src/index.core.ts +15 -0
- package/src/index.plugins.ts +42 -0
- package/src/index.ts +2 -15
- package/src/plugins/audio-selector/AudioSelector.ts +370 -0
- package/src/plugins/big-mute-button/BigMuteButton.ts +187 -0
- package/src/plugins/bottom-gear/BottomGear.ts +122 -0
- package/src/plugins/build.ts +1 -0
- package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +369 -0
- package/src/plugins/clappr-nerd-stats/formatter.ts +109 -0
- package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +414 -0
- package/src/plugins/clappr-nerd-stats/speedtest/index.ts +183 -0
- package/src/plugins/clappr-nerd-stats/speedtest/types.ts +5 -0
- package/src/plugins/clappr-nerd-stats/types.ts +3 -0
- package/src/plugins/clappr-stats/ClapprStats.ts +441 -0
- package/src/plugins/clappr-stats/types.ts +52 -0
- package/src/plugins/clappr-stats/utils.ts +42 -0
- package/src/plugins/click-to-pause/ClickToPause.ts +93 -0
- package/src/plugins/clips/Clips.ts +152 -0
- package/src/plugins/context-menu/ContextMenu.ts +134 -0
- package/src/plugins/disable-controls/DisableControls.ts +81 -0
- package/src/plugins/dvr-controls/DvrControls.ts +131 -0
- package/src/plugins/error-screen/ErrorScreen.ts +241 -0
- package/src/plugins/favicon/Favicon.ts +137 -0
- package/src/plugins/ga-events/GaEvents.js +395 -0
- package/src/plugins/ga-events/ga-tracking.js +46 -0
- package/src/plugins/google-analytics/GoogleAnalytics.ts +147 -0
- package/src/plugins/index.ts +42 -0
- package/src/plugins/kibo/index.ts +244 -0
- package/src/plugins/level-selector/LevelSelector.ts +400 -0
- package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +72 -0
- package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +11 -0
- package/src/plugins/logo/Logo.ts +233 -0
- package/src/plugins/logo/utils/index.ts +46 -0
- package/src/plugins/media-control/MediaControl.ts +1383 -0
- package/src/plugins/multi-camera/MultiCamera copy.xts +414 -0
- package/src/plugins/multi-camera/MultiCamera.ts +426 -0
- package/src/plugins/picture-in-picture/PictureInPicture.ts +87 -0
- package/src/plugins/playback-rate/PlaybackRate.ts +269 -0
- package/src/plugins/poster/Poster.ts +298 -0
- package/src/plugins/seek-time/SeekTime.ts +191 -0
- package/src/plugins/share/Share.ts +148 -0
- package/src/plugins/skip-time/SkipTime.ts +109 -0
- package/src/plugins/source-controller/SourceController.ts +239 -0
- package/src/plugins/source-controller/__tests__/SourceController.test.ts +230 -0
- package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +135 -0
- package/src/plugins/statistics/Statistics copy.xts +296 -0
- package/src/plugins/statistics/Statistics.ts +207 -0
- package/src/plugins/subtitles/Subtitles.ts +505 -0
- package/src/plugins/thumbnails/Thumbnails.ts +530 -0
- package/src/plugins/types.ts +7 -0
- package/src/plugins/typings/globals.d.ts +10 -0
- package/src/plugins/typings/parse-srt.d.ts +14 -0
- package/src/plugins/typings/workers.d.ts +3 -0
- package/src/plugins/utils.ts +77 -0
- package/src/plugins/vast-ads/VastAds.ts +915 -0
- package/src/plugins/vast-ads/loaderxml.ts +260 -0
- package/src/plugins/vast-ads/roll.ts +492 -0
- package/src/plugins/vast-ads/rollmanager.ts +403 -0
- package/src/plugins/vast-ads/sctemanager.ts +134 -0
- package/src/plugins/vast-ads/types.ts +14 -0
- package/src/plugins/vast-ads/urlhandler.ts +37 -0
- package/src/plugins/vast-ads/xmlhttprequest.ts +44 -0
- package/src/plugins/vast-ads/xmlmerge.ts +96 -0
- package/src/plugins/video360/VRControls.js +104 -0
- package/src/plugins/video360/VREffect.js +422 -0
- package/src/plugins/video360/Video360.js +979 -0
- package/src/plugins/video360/orbit-oriention-controls.js +1002 -0
- package/src/plugins/video360/utils.js +49 -0
- package/src/plugins/volume-fade/VolumeFade.ts +109 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import { Events, Playback, UICorePlugin, Utils, template } from '@clappr/core';
|
|
6
|
+
import { TimeUpdate } from '../..//playback.types';
|
|
7
|
+
|
|
8
|
+
import { CLAPPR_VERSION } from '../build.js';
|
|
9
|
+
|
|
10
|
+
import seekTimeHTML from '../../../assets/seek-time/seek-time.html';
|
|
11
|
+
import '../../../assets/seek-time/seek-time.scss';
|
|
12
|
+
import { ZeptoResult } from '../types.js';
|
|
13
|
+
|
|
14
|
+
const { formatTime } = Utils;
|
|
15
|
+
|
|
16
|
+
export class SeekTime extends UICorePlugin {
|
|
17
|
+
get name() {
|
|
18
|
+
return 'seek_time';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get supportedVersion() {
|
|
22
|
+
return { min: CLAPPR_VERSION };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get template() {
|
|
26
|
+
return template(seekTimeHTML);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override get attributes() {
|
|
30
|
+
return {
|
|
31
|
+
'class': 'seek-time',
|
|
32
|
+
'data-seek-time': ''
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get mediaControl() {
|
|
37
|
+
return this.core.mediaControl;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get mediaControlContainer() {
|
|
41
|
+
return this.mediaControl.container;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get isLiveStreamWithDvr() {
|
|
45
|
+
return this.mediaControlContainer &&
|
|
46
|
+
this.mediaControlContainer.getPlaybackType() === Playback.LIVE &&
|
|
47
|
+
this.mediaControlContainer.isDvrEnabled();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get durationShown() {
|
|
51
|
+
return !this.isLiveStreamWithDvr;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private hoveringOverSeekBar = false;
|
|
55
|
+
|
|
56
|
+
private hoverPosition = 0;
|
|
57
|
+
|
|
58
|
+
private displayedDuration: string | null = null;
|
|
59
|
+
|
|
60
|
+
private displayedSeekTime: string| null = null;
|
|
61
|
+
|
|
62
|
+
private duration = 0;
|
|
63
|
+
// private firstFragDateTime = 0;
|
|
64
|
+
|
|
65
|
+
private rendered = false;
|
|
66
|
+
|
|
67
|
+
private $durationEl: ZeptoResult | null = null;
|
|
68
|
+
|
|
69
|
+
private $seekTimeEl: ZeptoResult | null = null;
|
|
70
|
+
|
|
71
|
+
override bindEvents() {
|
|
72
|
+
this.listenTo(this.mediaControl, Events.MEDIACONTROL_RENDERED, this.render);
|
|
73
|
+
this.listenTo(this.mediaControl, Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR, this.showTime);
|
|
74
|
+
this.listenTo(this.mediaControl, Events.MEDIACONTROL_MOUSELEAVE_SEEKBAR, this.hideTime);
|
|
75
|
+
this.listenTo(this.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.onContainerChanged);
|
|
76
|
+
if (this.mediaControlContainer) {
|
|
77
|
+
this.listenTo(this.mediaControlContainer, Events.CONTAINER_PLAYBACKDVRSTATECHANGED, this.update);
|
|
78
|
+
this.listenTo(this.mediaControlContainer, Events.CONTAINER_TIMEUPDATE, this.updateDuration);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private onContainerChanged() {
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
this.stopListening();
|
|
85
|
+
this.bindEvents();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private updateDuration(timeProgress: TimeUpdate) {
|
|
89
|
+
this.duration = timeProgress.total;
|
|
90
|
+
// this.firstFragDateTime = timeProgress.firstFragDateTime;
|
|
91
|
+
this.update();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private showTime(event: MouseEvent) {
|
|
95
|
+
this.hoveringOverSeekBar = true;
|
|
96
|
+
this.calculateHoverPosition(event);
|
|
97
|
+
this.update();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private hideTime() {
|
|
101
|
+
this.hoveringOverSeekBar = false;
|
|
102
|
+
this.update();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private calculateHoverPosition(event: MouseEvent) {
|
|
106
|
+
const offset = event.pageX - this.mediaControl.$seekBarContainer.offset().left;
|
|
107
|
+
|
|
108
|
+
// proportion into the seek bar that the mouse is hovered over 0-1
|
|
109
|
+
this.hoverPosition = Math.min(1, Math.max(offset/this.mediaControl.$seekBarContainer.width(), 0));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getSeekTime() {
|
|
113
|
+
let seekTime;
|
|
114
|
+
|
|
115
|
+
if (this.isLiveStreamWithDvr) {
|
|
116
|
+
seekTime = this.duration - this.hoverPosition * this.duration;
|
|
117
|
+
} else {
|
|
118
|
+
seekTime = this.hoverPosition * this.duration;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return { seekTime };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
update() {
|
|
125
|
+
if (!this.rendered) {
|
|
126
|
+
// update() is always called after a render
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!this.shouldBeVisible()) {
|
|
130
|
+
this.$el.hide();
|
|
131
|
+
this.$el.css('left', '-100%');
|
|
132
|
+
} else {
|
|
133
|
+
const seekTime = this.getSeekTime();
|
|
134
|
+
let currentSeekTime = formatTime(seekTime.seekTime, false);
|
|
135
|
+
|
|
136
|
+
if (this.isLiveStreamWithDvr) {
|
|
137
|
+
currentSeekTime = `-${currentSeekTime}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// only update dom if necessary, ie time actually changed
|
|
141
|
+
if (currentSeekTime !== this.displayedSeekTime) {
|
|
142
|
+
this.$seekTimeEl.text(currentSeekTime);
|
|
143
|
+
this.displayedSeekTime = currentSeekTime;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (this.durationShown) {
|
|
147
|
+
this.$durationEl.show();
|
|
148
|
+
const currentDuration = formatTime(this.duration, false);
|
|
149
|
+
|
|
150
|
+
if (currentDuration !== this.displayedDuration) {
|
|
151
|
+
this.$durationEl.text(currentDuration);
|
|
152
|
+
this.displayedDuration = currentDuration;
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
this.$durationEl.hide();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// the element must be unhidden before its width is requested, otherwise it's width will be reported as 0
|
|
159
|
+
this.$el.show();
|
|
160
|
+
const containerWidth = this.mediaControl.$seekBarContainer.width();
|
|
161
|
+
const elWidth = this.$el.width();
|
|
162
|
+
let elLeftPos = this.hoverPosition * containerWidth;
|
|
163
|
+
|
|
164
|
+
elLeftPos -= elWidth / 2;
|
|
165
|
+
elLeftPos = Math.max(0, Math.min(elLeftPos, containerWidth - elWidth));
|
|
166
|
+
this.$el.css('left', elLeftPos);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
shouldBeVisible() {
|
|
171
|
+
return this.mediaControlContainer &&
|
|
172
|
+
this.mediaControlContainer.settings.seekEnabled &&
|
|
173
|
+
this.hoveringOverSeekBar &&
|
|
174
|
+
this.hoverPosition !== null &&
|
|
175
|
+
this.duration !== null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
override render() {
|
|
179
|
+
this.rendered = true;
|
|
180
|
+
this.displayedDuration = null;
|
|
181
|
+
this.displayedSeekTime = null;
|
|
182
|
+
this.$el.html(this.template());
|
|
183
|
+
this.$el.hide();
|
|
184
|
+
this.mediaControl.$el.append(this.el);
|
|
185
|
+
this.$seekTimeEl = this.$el.find('[data-seek-time]');
|
|
186
|
+
this.$durationEl = this.$el.find('[data-duration]');
|
|
187
|
+
this.$durationEl.hide();
|
|
188
|
+
this.update();
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Container, Events, UICorePlugin, template } from '@clappr/core';
|
|
2
|
+
|
|
3
|
+
import { CLAPPR_VERSION } from '../build.js';
|
|
4
|
+
|
|
5
|
+
import pluginHtml from '../../../assets/share/share.ejs';
|
|
6
|
+
import '../../../assets/share/style.scss';
|
|
7
|
+
import shareIcon from '../../../assets/icons/old/share.svg';
|
|
8
|
+
import closeIcon from '../../../assets/icons/old/close-share.svg';
|
|
9
|
+
import fbIcon from '../../../assets/icons/old/fb.svg';
|
|
10
|
+
import twIcon from '../../../assets/icons/old/twitter.svg';
|
|
11
|
+
|
|
12
|
+
export class Share extends UICorePlugin {
|
|
13
|
+
private hide = false;
|
|
14
|
+
|
|
15
|
+
private container: Container | null = null;
|
|
16
|
+
|
|
17
|
+
get name() {
|
|
18
|
+
return 'share';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get supportedVersion() {
|
|
22
|
+
return { min: CLAPPR_VERSION };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get template() {
|
|
26
|
+
return template(pluginHtml);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override get attributes() {
|
|
30
|
+
return {
|
|
31
|
+
'class': this.name + '_plugin',
|
|
32
|
+
'data-share': ''
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override get events() {
|
|
37
|
+
return {
|
|
38
|
+
'click [data-share-button]': 'onShareShow',
|
|
39
|
+
'click [data-share-close]': 'onShareHide',
|
|
40
|
+
'click [data-share-fb]': 'onShareFB',
|
|
41
|
+
'click [data-share-tw]': 'onShareTW',
|
|
42
|
+
'click [data-share-link]': 'onShareLinkClick',
|
|
43
|
+
'click [data-share-embed]': 'onShareEmbedClick'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override bindEvents() {
|
|
48
|
+
this.listenTo(this.core, Events.CORE_READY, this.onReady);
|
|
49
|
+
// this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
|
|
50
|
+
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_RENDERED, this.render);
|
|
51
|
+
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_HIDE, this.hideShare);
|
|
52
|
+
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_SHOW, this.showShare);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
unBindEvents() {
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
this.stopListening(this.core, Events.CORE_READY);
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
// this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED);
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_RENDERED);
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_HIDE);
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_SHOW);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
canShowShare() {
|
|
69
|
+
this.hide = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private onReady() {
|
|
73
|
+
this.hide = true;
|
|
74
|
+
this.container = this.core.activeContainer;
|
|
75
|
+
if (this.container) {
|
|
76
|
+
this.listenTo(this.container, 'container:settingsupdate', this.canShowShare);
|
|
77
|
+
}
|
|
78
|
+
this.hideShare();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override render() {
|
|
82
|
+
this.$el.html(this.template({
|
|
83
|
+
'url':this.options.shareURL,
|
|
84
|
+
'embed': this.options.embed,
|
|
85
|
+
'embed_title': this.core.i18n.t('embed_title'),
|
|
86
|
+
'share_title': this.core.i18n.t('share_title'),
|
|
87
|
+
'link_title': this.core.i18n.t('link_title'),
|
|
88
|
+
'social_title': this.core.i18n.t('social_title'),
|
|
89
|
+
}));
|
|
90
|
+
this.core.mediaControl.$el.append(this.el);
|
|
91
|
+
this.$el.find('.share-container').hide();
|
|
92
|
+
this.initializeIcons();
|
|
93
|
+
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
hideShare() {
|
|
98
|
+
this.$el.addClass('share-hide');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
showShare() {
|
|
102
|
+
if (this.hide) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.$el.removeClass('share-hide');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
initializeIcons() {
|
|
109
|
+
this.$el.find('button.media-control-button[data-share-button]')
|
|
110
|
+
.addClass('gcore-skin-button-color')
|
|
111
|
+
.append(shareIcon);
|
|
112
|
+
this.$el.find('div.share-container-header--close').append(closeIcon);
|
|
113
|
+
this.$el.find('div.share-container-header--socialicon_fb').append(fbIcon);
|
|
114
|
+
this.$el.find('div.share-container-header--socialicon_tw').append(twIcon);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
onShareShow() {
|
|
118
|
+
this.$el.find('.share-container').show();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
onShareHide() {
|
|
122
|
+
this.$el.find('.share-container').hide();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
onShareFB() {
|
|
126
|
+
if (this.options.shareURL) {
|
|
127
|
+
const url = 'https://www.facebook.com/sharer.php?u='+this.options.shareURL;
|
|
128
|
+
|
|
129
|
+
window.open(url, '_blank');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onShareTW() {
|
|
134
|
+
if (this.options.shareURL) {
|
|
135
|
+
const url = 'https://twitter.com/intent/tweet?url='+this.options.shareURL;
|
|
136
|
+
|
|
137
|
+
window.open(url, '_blank');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onShareLinkClick() {
|
|
142
|
+
this.$el.find('.share-container-header--link')[0].setSelectionRange(0, this.options.shareURL.length);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
onShareEmbedClick() {
|
|
146
|
+
this.$el.find('.share-container-header--embed')[0].setSelectionRange(0, this.options.embed.length);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { UICorePlugin as UICorePluginOriginal, Browser, Playback, Events, template } from '@clappr/core';
|
|
2
|
+
|
|
3
|
+
import { CLAPPR_VERSION } from '../build.js';
|
|
4
|
+
|
|
5
|
+
import pluginHtml from '../../../assets/skip-time/skip-time.ejs';
|
|
6
|
+
import '../../../assets/skip-time/style.scss';
|
|
7
|
+
|
|
8
|
+
type Position = 'mid' | 'left' | 'right';
|
|
9
|
+
|
|
10
|
+
export class SkipTime extends UICorePluginOriginal {
|
|
11
|
+
get name() {
|
|
12
|
+
return 'skip_time';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get supportedVersion() {
|
|
16
|
+
return { min: CLAPPR_VERSION };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get container() {
|
|
20
|
+
return this.core && this.core.activeContainer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get template() {
|
|
24
|
+
return template(pluginHtml);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override get attributes() {
|
|
28
|
+
return {
|
|
29
|
+
'class': this.name + '_plugin',
|
|
30
|
+
'data-skip-time': ''
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private position: Position = 'mid';
|
|
35
|
+
|
|
36
|
+
override get events() {
|
|
37
|
+
return {
|
|
38
|
+
'click [data-skip-left]': 'setBack',
|
|
39
|
+
'click [data-skip-mid]': 'setMidClick',
|
|
40
|
+
'click [data-skip-right]': 'setForward',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override bindEvents() {
|
|
45
|
+
this.listenTo(this.core, Events.CORE_READY, this.render);
|
|
46
|
+
if (!this.container) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.listenTo(this.container, Events.CONTAINER_DBLCLICK, this.handleRewindClicks);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setBack() {
|
|
53
|
+
this.position = 'left';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
handleRewindClicks() {
|
|
57
|
+
if (this.core.getPlaybackType() === Playback.LIVE && !this.container.isDvrEnabled()) {
|
|
58
|
+
this.toggleFullscreen();
|
|
59
|
+
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (Browser.isMobile) {
|
|
63
|
+
if (this.position === 'left') {
|
|
64
|
+
const seekPos = this.container.getCurrentTime() - 10;
|
|
65
|
+
|
|
66
|
+
if (seekPos < 0) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.container.seek(seekPos);
|
|
70
|
+
} else if (this.position === 'right') {
|
|
71
|
+
const seekPos = this.container.getCurrentTime() + 30;
|
|
72
|
+
|
|
73
|
+
if (seekPos > this.container.getDuration()) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.container.seek(seekPos);
|
|
78
|
+
} else {
|
|
79
|
+
this.toggleFullscreen();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setMidClick() {
|
|
85
|
+
this.position = 'mid';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setForward() {
|
|
89
|
+
this.position = 'right';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
toggleFullscreen() {
|
|
93
|
+
this.trigger(Events.MEDIACONTROL_FULLSCREEN, this.name);
|
|
94
|
+
this.container.fullscreen();
|
|
95
|
+
this.core.toggleFullscreen();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
override render() {
|
|
99
|
+
this.$el.html(template(pluginHtml));
|
|
100
|
+
|
|
101
|
+
if (this.core.activeContainer) {
|
|
102
|
+
this.core.activeContainer.$el.append(this.el);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.bindEvents();
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Events as ClapprEvents,
|
|
3
|
+
CorePlugin,
|
|
4
|
+
type Core as ClapprCore,
|
|
5
|
+
} from '@clappr/core'
|
|
6
|
+
import {
|
|
7
|
+
type PlaybackError,
|
|
8
|
+
PlaybackErrorCode,
|
|
9
|
+
} from '../..//playback.types'
|
|
10
|
+
import {
|
|
11
|
+
type PlayerMediaSourceDesc,
|
|
12
|
+
} from '../..//types'
|
|
13
|
+
import { trace } from '@gcorevideo/utils'
|
|
14
|
+
|
|
15
|
+
import { CLAPPR_VERSION } from '../build'
|
|
16
|
+
|
|
17
|
+
const T = 'plugins.source_controller'
|
|
18
|
+
|
|
19
|
+
const INITIAL_RETRY_DELAY = 1000
|
|
20
|
+
|
|
21
|
+
const MAX_RETRY_DELAY = 5000
|
|
22
|
+
|
|
23
|
+
const RETRY_DELAY_BLUR = 500
|
|
24
|
+
|
|
25
|
+
const VERSION = '0.0.1'
|
|
26
|
+
|
|
27
|
+
type SyncFn = (cb: () => void) => void
|
|
28
|
+
|
|
29
|
+
function noSync(cb: () => void) {
|
|
30
|
+
queueMicrotask(cb)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This plugin is responsible for managing the automatic failover between sources.
|
|
35
|
+
* @beta
|
|
36
|
+
* @remarks
|
|
37
|
+
* Have a look at the {@link https://miro.com/app/board/uXjVLiN15tY=/?share_link_id=390327585787 | source failover diagram} for the details
|
|
38
|
+
* on how sources ordering and selection works.
|
|
39
|
+
*
|
|
40
|
+
* This plugin does not expose any public methods apart from required by the Clappr plugin interface.
|
|
41
|
+
* It is supposed to work autonomously.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { SourceController } from '@gcorevideo/player-plugins'
|
|
46
|
+
*
|
|
47
|
+
* Player.registerPlugin(SourceController)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export class SourceController extends CorePlugin {
|
|
51
|
+
/*
|
|
52
|
+
* The Logic itself is quite simple:
|
|
53
|
+
* * Here is the short diagram:
|
|
54
|
+
*
|
|
55
|
+
* sources_list:
|
|
56
|
+
* - a.mpd | +--------------------+
|
|
57
|
+
* - b.m3u8 |--->| init |
|
|
58
|
+
* - ... | |--------------------|
|
|
59
|
+
* | current_source = 0 |
|
|
60
|
+
* +--------------------+
|
|
61
|
+
* |
|
|
62
|
+
* | source = a.mpd
|
|
63
|
+
* | playback = dash.js
|
|
64
|
+
* v
|
|
65
|
+
* +------------------+
|
|
66
|
+
* +-->| load source |
|
|
67
|
+
* | +---------|--------+
|
|
68
|
+
* | v
|
|
69
|
+
* | +------------------+
|
|
70
|
+
* | | play |
|
|
71
|
+
* | +---------|--------+
|
|
72
|
+
* | |
|
|
73
|
+
* | v
|
|
74
|
+
* | +-----------------------+
|
|
75
|
+
* | | on playback_error |
|
|
76
|
+
* | |-----------------------|
|
|
77
|
+
* | | current_source = |
|
|
78
|
+
* | | (current_source + 1) |
|
|
79
|
+
* | | % len sources_list |
|
|
80
|
+
* | | |
|
|
81
|
+
* | | delay 1..3s |
|
|
82
|
+
* | +---------------|-------+
|
|
83
|
+
* | |
|
|
84
|
+
* | source=b.m3u8 |
|
|
85
|
+
* | playback=hls.js |
|
|
86
|
+
* +-------------------+
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
private sourcesList: PlayerMediaSourceDesc[] = []
|
|
90
|
+
|
|
91
|
+
private currentSourceIndex = 0
|
|
92
|
+
|
|
93
|
+
private sourcesDelay: Record<string, number> = {}
|
|
94
|
+
|
|
95
|
+
private active = false
|
|
96
|
+
|
|
97
|
+
private sync: SyncFn = noSync
|
|
98
|
+
|
|
99
|
+
get name() {
|
|
100
|
+
return 'source_controller'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get supportedVersion() {
|
|
104
|
+
return { min: CLAPPR_VERSION }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
constructor(core: ClapprCore) {
|
|
108
|
+
super(core)
|
|
109
|
+
this.sourcesList = this.core.options.sources
|
|
110
|
+
if (this.core.options.source !== undefined) {
|
|
111
|
+
// prevent Clappr from loading all sources simultaneously
|
|
112
|
+
this.core.options.sources = [this.core.options.source]
|
|
113
|
+
} else {
|
|
114
|
+
this.core.options.sources = this.core.options.sources.slice(0, 1)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
121
|
+
override bindEvents() {
|
|
122
|
+
super.bindEvents()
|
|
123
|
+
|
|
124
|
+
this.listenTo(this.core, ClapprEvents.CORE_READY, () => this.onReady())
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private onReady() {
|
|
128
|
+
trace(`${T} onReady`, {
|
|
129
|
+
retrying: this.active,
|
|
130
|
+
})
|
|
131
|
+
const spinner = this.core.activeContainer?.getPlugin('spinner')
|
|
132
|
+
if (spinner) {
|
|
133
|
+
this.sync = (cb: () => void) => {
|
|
134
|
+
spinner.once('spinner:sync', cb)
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
this.sync = noSync
|
|
138
|
+
}
|
|
139
|
+
this.bindContainerEventListeners()
|
|
140
|
+
if (this.active) {
|
|
141
|
+
this.core.activeContainer?.getPlugin('poster_custom')?.disable()
|
|
142
|
+
spinner?.show()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private bindContainerEventListeners() {
|
|
147
|
+
trace(`${T} bindContainerEventListeners`, {
|
|
148
|
+
activePlayback: this.core.activePlayback?.name,
|
|
149
|
+
})
|
|
150
|
+
this.core.activePlayback.on(
|
|
151
|
+
ClapprEvents.PLAYBACK_ERROR,
|
|
152
|
+
(error: PlaybackError) => {
|
|
153
|
+
trace(`${T} on PLAYBACK_ERROR`, {
|
|
154
|
+
error: {
|
|
155
|
+
code: error?.code,
|
|
156
|
+
description: error?.description,
|
|
157
|
+
level: error?.level,
|
|
158
|
+
},
|
|
159
|
+
retrying: this.active,
|
|
160
|
+
currentSource: this.sourcesList[this.currentSourceIndex],
|
|
161
|
+
})
|
|
162
|
+
switch (error.code) {
|
|
163
|
+
case PlaybackErrorCode.MediaSourceUnavailable:
|
|
164
|
+
this.core.activeContainer?.getPlugin('poster_custom')?.disable()
|
|
165
|
+
this.retryPlayback()
|
|
166
|
+
break
|
|
167
|
+
// TODO handle other errors
|
|
168
|
+
default:
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
)
|
|
173
|
+
this.core.activePlayback.on(ClapprEvents.PLAYBACK_PLAY, () => {
|
|
174
|
+
trace(`${T} on PLAYBACK_PLAY`, {
|
|
175
|
+
currentSource: this.sourcesList[this.currentSourceIndex],
|
|
176
|
+
retrying: this.active,
|
|
177
|
+
})
|
|
178
|
+
if (this.active) {
|
|
179
|
+
this.reset()
|
|
180
|
+
// TODO make poster reset its state on enable
|
|
181
|
+
this.core.activeContainer?.getPlugin('poster_custom')?.enable()
|
|
182
|
+
this.core.activeContainer?.getPlugin('spinner')?.hide()
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private reset() {
|
|
188
|
+
this.active = false
|
|
189
|
+
this.sourcesDelay = {}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private retryPlayback() {
|
|
193
|
+
trace(`${T} retryPlayback enter`, {
|
|
194
|
+
currentSourceIndex: this.currentSourceIndex,
|
|
195
|
+
currentSource: this.sourcesList[this.currentSourceIndex],
|
|
196
|
+
sourcesList: this.sourcesList,
|
|
197
|
+
})
|
|
198
|
+
this.active = true
|
|
199
|
+
this.getNextMediaSource().then((nextSource: PlayerMediaSourceDesc) => {
|
|
200
|
+
trace(`${T} retryPlayback syncing...`, {
|
|
201
|
+
nextSource,
|
|
202
|
+
})
|
|
203
|
+
const rnd = RETRY_DELAY_BLUR * Math.random()
|
|
204
|
+
this.sync(() => {
|
|
205
|
+
trace(`${T} retryPlayback loading...`, {
|
|
206
|
+
nextSource,
|
|
207
|
+
})
|
|
208
|
+
this.core.load(nextSource.source, nextSource.mimeType)
|
|
209
|
+
trace(`${T} retryPlayback loaded`, {
|
|
210
|
+
nextSource,
|
|
211
|
+
})
|
|
212
|
+
setTimeout(() => {
|
|
213
|
+
// this.core.activePlayback.consent()
|
|
214
|
+
this.core.activePlayback.play()
|
|
215
|
+
trace(`${T} retryPlayback playing`)
|
|
216
|
+
}, rnd)
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private getNextMediaSource(): Promise<PlayerMediaSourceDesc> {
|
|
222
|
+
return new Promise((resolve) => {
|
|
223
|
+
this.sourcesDelay[this.currentSourceIndex] = Math.min(
|
|
224
|
+
MAX_RETRY_DELAY,
|
|
225
|
+
(this.sourcesDelay[this.currentSourceIndex] || INITIAL_RETRY_DELAY) * 2,
|
|
226
|
+
)
|
|
227
|
+
this.currentSourceIndex =
|
|
228
|
+
(this.currentSourceIndex + 1) % this.sourcesList.length
|
|
229
|
+
const delay =
|
|
230
|
+
this.sourcesDelay[this.currentSourceIndex] || INITIAL_RETRY_DELAY
|
|
231
|
+
const s = this.sourcesList[this.currentSourceIndex]
|
|
232
|
+
setTimeout(() => resolve(s), delay)
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static get version() {
|
|
237
|
+
return VERSION
|
|
238
|
+
}
|
|
239
|
+
}
|