@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
|
@@ -1,68 +1,64 @@
|
|
|
1
1
|
import { Events, template, UICorePlugin } from '@clappr/core';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { reportError, trace } from '@gcorevideo/utils';
|
|
3
|
+
import { CLAPPR_VERSION } from '../build.js';
|
|
4
|
+
import buttonHtml from '../../../assets/level-selector/button.ejs';
|
|
5
|
+
import listHtml from '../../../assets/level-selector/list.ejs';
|
|
5
6
|
import hdIcon from '../../../assets/icons/new/hd.svg';
|
|
6
7
|
import arrowRightIcon from '../../../assets/icons/new/arrow-right.svg';
|
|
7
8
|
import arrowLeftIcon from '../../../assets/icons/new/arrow-left.svg';
|
|
8
9
|
import checkIcon from '../../../assets/icons/new/check.svg';
|
|
9
|
-
import '../../../assets/
|
|
10
|
-
import { trace } from '../../trace/index.js';
|
|
11
|
-
assert(process.env.CLAPPR_VERSION, 'CLAPPR_VERSION is required');
|
|
12
|
-
const CLAPPR_VERSION = process.env.CLAPPR_VERSION;
|
|
13
|
-
// assert(process.env.VERSION, 'VERSION is required');
|
|
14
|
-
// const VERSION: string = process.env.VERSION;
|
|
15
|
-
// import Player from '../../Player';
|
|
16
|
-
// import LogManager from '../../utils/LogManager';
|
|
10
|
+
import '../../../assets/level-selector/style.scss';
|
|
17
11
|
const T = 'plugins.level_selector';
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
12
|
+
const VERSION = '2.18.3';
|
|
13
|
+
/**
|
|
14
|
+
* Allows to control the quality level of the playback.
|
|
15
|
+
* @beta
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The plugin is rendered as a button in the gear menu.
|
|
19
|
+
* When clicked, it shows a list of quality levels to choose from.
|
|
20
|
+
*
|
|
21
|
+
* Configuration options:
|
|
22
|
+
*
|
|
23
|
+
* - `labels`: The labels to show in the level selector. [vertical resolution]: string
|
|
24
|
+
* - `restrictResolution`: The maximum resolution to allow in the level selector.
|
|
25
|
+
* - `title`: The title to show in the level selector.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* {
|
|
30
|
+
* levelSelector: {
|
|
31
|
+
* restrictResolution: 360,
|
|
32
|
+
* labels: { 360: '360p', 720: '720p' },
|
|
33
|
+
* },
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export class LevelSelector extends UICorePlugin {
|
|
40
38
|
levels = [];
|
|
41
39
|
levelLabels = [];
|
|
42
40
|
removeAuto = false;
|
|
41
|
+
isHd = false;
|
|
42
|
+
isOpen = false;
|
|
43
|
+
buttonTemplate = null;
|
|
44
|
+
listTemplate = null;
|
|
43
45
|
get name() {
|
|
44
46
|
return 'level_selector';
|
|
45
47
|
}
|
|
46
48
|
get supportedVersion() {
|
|
47
49
|
return { min: CLAPPR_VERSION };
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// get template() {
|
|
53
|
-
// return template(pluginHtml);
|
|
54
|
-
// }
|
|
51
|
+
static get version() {
|
|
52
|
+
return VERSION;
|
|
53
|
+
}
|
|
55
54
|
get attributes() {
|
|
56
55
|
return {
|
|
57
|
-
|
|
58
|
-
'data-level-selector': ''
|
|
56
|
+
class: this.name,
|
|
57
|
+
'data-level-selector': '',
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
60
|
currentText = 'Auto';
|
|
62
61
|
selectedLevelId = -1;
|
|
63
|
-
// constructor(core) {
|
|
64
|
-
// super(core);
|
|
65
|
-
// }
|
|
66
62
|
get events() {
|
|
67
63
|
return {
|
|
68
64
|
'click .gear-sub-menu_btn': 'onLevelSelect',
|
|
@@ -71,41 +67,40 @@ export default class LevelSelector extends UICorePlugin {
|
|
|
71
67
|
};
|
|
72
68
|
}
|
|
73
69
|
bindEvents() {
|
|
74
|
-
this.listenTo(this.core, Events.CORE_READY, this.bindPlaybackEvents);
|
|
70
|
+
this.listenTo(this.core, Events.CORE_READY, () => this.bindPlaybackEvents());
|
|
75
71
|
this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
|
|
76
|
-
// this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_RENDERED, this.render);
|
|
77
72
|
this.listenTo(this.core, 'gear:rendered', this.render);
|
|
78
|
-
// this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_HIDE, this.hideSelectLevelMenu);
|
|
79
73
|
}
|
|
80
74
|
unBindEvents() {
|
|
81
|
-
this.stopListening(this.core, Events.CORE_READY, this.bindPlaybackEvents);
|
|
75
|
+
this.stopListening(this.core, Events.CORE_READY, () => this.bindPlaybackEvents());
|
|
82
76
|
this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.reload);
|
|
83
|
-
// this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_RENDERED);
|
|
84
77
|
this.stopListening(this.core, 'gear:rendered', this.render);
|
|
85
|
-
// this.stopListening(this.core.mediaControl, Events.MEDIACONTROL_HIDE);
|
|
86
78
|
}
|
|
87
79
|
bindPlaybackEvents() {
|
|
88
|
-
// this.currentLevel = {};
|
|
89
|
-
this.currentLevel = NO_LEVEL;
|
|
90
80
|
this.removeAuto = false;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.listenTo(
|
|
94
|
-
this.listenTo(
|
|
95
|
-
this.listenTo(
|
|
96
|
-
this.listenTo(
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
this.isHd = false;
|
|
82
|
+
const activePlayback = this.core.activePlayback;
|
|
83
|
+
this.listenTo(activePlayback, Events.PLAYBACK_LEVELS_AVAILABLE, (levels) => this.fillLevels(levels));
|
|
84
|
+
this.listenTo(activePlayback, Events.PLAYBACK_LEVEL_SWITCH_START, this.onLevelSwitchStart);
|
|
85
|
+
this.listenTo(activePlayback, Events.PLAYBACK_LEVEL_SWITCH_END, this.onLevelSwitchEnd);
|
|
86
|
+
this.listenTo(activePlayback, Events.PLAYBACK_BITRATE, this.updateCurrentLevel);
|
|
87
|
+
this.listenTo(activePlayback, Events.PLAYBACK_STOP, this.onStop);
|
|
88
|
+
this.listenTo(activePlayback, Events.PLAYBACK_HIGHDEFINITIONUPDATE, (isHd) => {
|
|
89
|
+
this.isHd = isHd;
|
|
90
|
+
this.deferRender();
|
|
91
|
+
});
|
|
92
|
+
if (activePlayback?.levels?.length > 0) {
|
|
93
|
+
this.fillLevels(activePlayback.levels);
|
|
94
|
+
}
|
|
99
95
|
}
|
|
100
96
|
onStop() {
|
|
97
|
+
trace(`${T} onStop`);
|
|
101
98
|
const currentPlayback = this.core.activePlayback;
|
|
102
99
|
this.listenToOnce(currentPlayback, Events.PLAYBACK_PLAY, () => {
|
|
103
|
-
trace(`${T} PLAYBACK_PLAY`, {
|
|
104
|
-
playbackType: currentPlayback.getPlaybackType(),
|
|
105
|
-
});
|
|
100
|
+
trace(`${T} on PLAYBACK_PLAY after stop`, { selectedLevelId: this.selectedLevelId });
|
|
106
101
|
if (currentPlayback.getPlaybackType() === 'live') {
|
|
107
102
|
if (this.selectedLevelId !== -1) {
|
|
108
|
-
currentPlayback.currentLevel = this.
|
|
103
|
+
currentPlayback.currentLevel = this.selectedLevelId;
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
106
|
});
|
|
@@ -119,109 +114,123 @@ export default class LevelSelector extends UICorePlugin {
|
|
|
119
114
|
if (!this.core.activeContainer) {
|
|
120
115
|
return false;
|
|
121
116
|
}
|
|
122
|
-
const
|
|
123
|
-
if (!
|
|
117
|
+
const activePlayback = this.core.activePlayback;
|
|
118
|
+
if (!activePlayback) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const supportsCurrentLevel = 'currentLevel' in activePlayback;
|
|
122
|
+
if (!supportsCurrentLevel) {
|
|
124
123
|
return false;
|
|
125
124
|
}
|
|
126
|
-
// TODO typeof currentPlayback.currentLevel === 'number' should it be
|
|
127
|
-
const respondsToCurrentLevel = currentPlayback.currentLevel !== undefined;
|
|
128
125
|
// Only care if we have at least 2 to choose from
|
|
129
|
-
|
|
130
|
-
return respondsToCurrentLevel && hasLevels;
|
|
126
|
+
return !!(this.levels && this.levels.length > 1);
|
|
131
127
|
}
|
|
132
128
|
render() {
|
|
133
|
-
if (this.shouldRender()) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
if (!this.shouldRender()) {
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
this.renderButton();
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
renderButton() {
|
|
136
|
+
if (!this.buttonTemplate) {
|
|
137
|
+
this.buttonTemplate = template(buttonHtml);
|
|
138
|
+
}
|
|
139
|
+
if (!this.isOpen) {
|
|
140
|
+
const html = this.buttonTemplate?.({
|
|
141
|
+
arrowRightIcon,
|
|
137
142
|
currentText: this.currentText,
|
|
143
|
+
isHd: this.isHd,
|
|
138
144
|
hdIcon,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.core.mediaControl.$el
|
|
142
|
-
|
|
145
|
+
});
|
|
146
|
+
this.$el.html(html);
|
|
147
|
+
this.core.mediaControl.$el
|
|
148
|
+
?.find('.gear-options-list [data-quality]')
|
|
149
|
+
.html(this.el);
|
|
143
150
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
.find('[data-level-selector-select="-1"]')
|
|
149
|
-
.parent()
|
|
150
|
-
.remove();
|
|
151
|
+
}
|
|
152
|
+
renderDropdown() {
|
|
153
|
+
if (!this.listTemplate) {
|
|
154
|
+
this.listTemplate = template(listHtml);
|
|
151
155
|
}
|
|
152
|
-
|
|
156
|
+
const html = this.listTemplate({
|
|
157
|
+
arrowLeftIcon,
|
|
158
|
+
checkIcon,
|
|
159
|
+
labels: this.levelLabels,
|
|
160
|
+
levels: this.levels,
|
|
161
|
+
maxLevel: this.maxLevel,
|
|
162
|
+
removeAuto: this.removeAuto,
|
|
163
|
+
});
|
|
164
|
+
this.$el.html(html);
|
|
165
|
+
this.core.mediaControl.$el?.find('.gear-wrapper').html(this.el);
|
|
166
|
+
}
|
|
167
|
+
get maxLevel() {
|
|
168
|
+
const maxRes = this.core.options.levelSelector?.restrictResolution;
|
|
169
|
+
return maxRes
|
|
170
|
+
? this.levels.findIndex((level) => level.height === maxRes)
|
|
171
|
+
: -1;
|
|
153
172
|
}
|
|
154
|
-
fillLevels(levels
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// Remove quality selector if it's not HLS
|
|
160
|
-
if (initialLevel !== -1) {
|
|
173
|
+
fillLevels(levels) {
|
|
174
|
+
const maxResolution = this.core.options.levelSelector?.restrictResolution;
|
|
175
|
+
this.levels = levels;
|
|
176
|
+
this.makeLevelsLabels();
|
|
177
|
+
if (maxResolution) {
|
|
161
178
|
this.removeAuto = true;
|
|
179
|
+
// TODO account for vertical resolutions, i.e, normalize the resolution to the width
|
|
180
|
+
const initialLevel = levels
|
|
181
|
+
.filter((level) => level.height <= maxResolution)
|
|
182
|
+
.pop();
|
|
183
|
+
this.setLevel(initialLevel?.level ?? 0);
|
|
162
184
|
}
|
|
163
|
-
|
|
164
|
-
// this.selectedLevelId = initialLevel;
|
|
165
|
-
// }
|
|
166
|
-
this.levels = levels;
|
|
167
|
-
this.configureLevelsLabels();
|
|
168
|
-
this.render();
|
|
185
|
+
this.deferRender();
|
|
169
186
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const labels = this.core.options.pluginSettings?.level_selector?.labels;
|
|
187
|
+
makeLevelsLabels() {
|
|
188
|
+
const labels = this.core.options.levelSelector?.labels ?? {};
|
|
173
189
|
this.levelLabels = [];
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.levelLabels.push(label);
|
|
180
|
-
}
|
|
190
|
+
for (let i = 0; i < this.levels.length; i++) {
|
|
191
|
+
const level = this.levels[i];
|
|
192
|
+
const ll = level.width > level.height ? level.height : level.width;
|
|
193
|
+
const label = labels[ll] || `${ll}p`;
|
|
194
|
+
this.levelLabels.push(label);
|
|
181
195
|
}
|
|
182
|
-
trace('${T} configureLevelsLabels leave', { levelLabels: this.levelLabels });
|
|
183
196
|
}
|
|
184
197
|
findLevelBy(id) {
|
|
185
|
-
return this.levels.find((level) => level.
|
|
198
|
+
return this.levels.find((level) => level.level === id);
|
|
186
199
|
}
|
|
187
200
|
onLevelSelect(event) {
|
|
188
|
-
const selectedLevel = event.currentTarget?.dataset?.id;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// event.stopPropagation();
|
|
193
|
-
// return false;
|
|
201
|
+
const selectedLevel = parseInt(event.currentTarget?.dataset?.id ?? '-1', 10);
|
|
202
|
+
this.setLevel(selectedLevel);
|
|
203
|
+
event.stopPropagation();
|
|
204
|
+
return false;
|
|
194
205
|
}
|
|
195
206
|
goBack() {
|
|
207
|
+
trace(`${T} goBack`);
|
|
208
|
+
this.isOpen = false;
|
|
196
209
|
this.core.trigger('gear:refresh');
|
|
210
|
+
this.deferRender();
|
|
197
211
|
}
|
|
198
|
-
|
|
212
|
+
setLevel(index) {
|
|
213
|
+
trace(`${T} setIndexLevel`, { index });
|
|
199
214
|
this.selectedLevelId = index;
|
|
200
|
-
if (this.core.activePlayback) {
|
|
201
|
-
|
|
215
|
+
if (!this.core.activePlayback) {
|
|
216
|
+
return;
|
|
202
217
|
}
|
|
203
|
-
if (this.core.activePlayback.currentLevel
|
|
204
|
-
return
|
|
218
|
+
if (this.core.activePlayback.currentLevel === this.selectedLevelId) {
|
|
219
|
+
return;
|
|
205
220
|
}
|
|
206
221
|
this.core.activePlayback.currentLevel = this.selectedLevelId;
|
|
207
222
|
try {
|
|
208
|
-
this.updateText(this.selectedLevelId);
|
|
209
223
|
this.highlightCurrentLevel();
|
|
210
224
|
}
|
|
211
225
|
catch (error) {
|
|
212
|
-
// LogManager.exception(error);
|
|
213
226
|
reportError(error);
|
|
214
227
|
}
|
|
228
|
+
this.deferRender();
|
|
215
229
|
}
|
|
216
230
|
onShowLevelSelectMenu() {
|
|
217
|
-
|
|
218
|
-
this
|
|
219
|
-
|
|
220
|
-
labels: this.levelLabels,
|
|
221
|
-
arrowLeftIcon,
|
|
222
|
-
checkIcon,
|
|
223
|
-
}));
|
|
224
|
-
this.core.mediaControl.$el?.find('.gear-wrapper').html(this.el);
|
|
231
|
+
trace(`${T} onShowLevelSelectMenu`);
|
|
232
|
+
this.isOpen = true;
|
|
233
|
+
this.renderDropdown();
|
|
225
234
|
this.highlightCurrentLevel();
|
|
226
235
|
}
|
|
227
236
|
allLevelElements() {
|
|
@@ -231,57 +240,62 @@ export default class LevelSelector extends UICorePlugin {
|
|
|
231
240
|
return this.$(`ul.gear-sub-menu a[data-id="${id}"]`).parent();
|
|
232
241
|
}
|
|
233
242
|
getTitle() {
|
|
234
|
-
return (this.core.options.
|
|
243
|
+
return (this.core.options.levelSelector || {}).title;
|
|
235
244
|
}
|
|
236
|
-
|
|
237
|
-
|
|
245
|
+
onLevelSwitchStart() {
|
|
246
|
+
this.core.activePlayback.trigger('playback:level:select:start');
|
|
238
247
|
this.levelElement(this.selectedLevelId).addClass('changing');
|
|
239
248
|
}
|
|
240
|
-
|
|
241
|
-
if (this.core.activePlayback) {
|
|
242
|
-
this.core.activePlayback.trigger('playback:level:select:end', {
|
|
243
|
-
label: this.getLevelLabel(this.selectedLevelId)
|
|
244
|
-
});
|
|
245
|
-
}
|
|
249
|
+
onLevelSwitchEnd() {
|
|
246
250
|
this.levelElement(this.selectedLevelId).removeClass('changing');
|
|
247
|
-
// Player.player.trigger('stopLevelSwitch');
|
|
248
251
|
}
|
|
249
252
|
updateText(level) {
|
|
250
253
|
if (level === undefined || isNaN(level)) {
|
|
251
254
|
return;
|
|
252
255
|
}
|
|
253
256
|
this.currentText = this.getLevelLabel(level);
|
|
257
|
+
this.deferRender();
|
|
254
258
|
}
|
|
255
259
|
getLevelLabel(id) {
|
|
256
260
|
if (id === -1) {
|
|
257
261
|
return 'Auto';
|
|
258
262
|
}
|
|
259
|
-
const index = this.levels.findIndex((l) => l.
|
|
263
|
+
const index = this.levels.findIndex((l) => l.level === id);
|
|
260
264
|
if (index < 0) {
|
|
261
265
|
return 'Auto';
|
|
262
266
|
}
|
|
263
|
-
return this.levelLabels[index]
|
|
267
|
+
return this.levelLabels[index] ?? formatLevelLabel(this.levels[index]);
|
|
264
268
|
}
|
|
265
269
|
updateCurrentLevel(info) {
|
|
266
|
-
trace(
|
|
267
|
-
const level = this.findLevelBy(info.level);
|
|
268
|
-
this.currentLevel = level ? level : null;
|
|
270
|
+
trace(`${T} updateCurrentLevel`, { info });
|
|
269
271
|
this.highlightCurrentLevel();
|
|
270
|
-
// Player.player.trigger('updateCurrentLevel', info);
|
|
271
272
|
}
|
|
272
273
|
highlightCurrentLevel() {
|
|
273
|
-
trace(
|
|
274
|
+
trace(`${T} highlightCurrentLevel`, {
|
|
275
|
+
selectedLevelId: this.selectedLevelId,
|
|
276
|
+
});
|
|
274
277
|
this.allLevelElements().removeClass('current');
|
|
275
278
|
this.allLevelElements().find('a').removeClass('gcore-skin-active');
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
currentLevelElement.find('a').addClass('gcore-skin-active');
|
|
280
|
-
}
|
|
279
|
+
const currentLevelElement = this.levelElement(this.selectedLevelId);
|
|
280
|
+
currentLevelElement.addClass('current');
|
|
281
|
+
currentLevelElement.find('a').addClass('gcore-skin-active');
|
|
281
282
|
this.updateText(this.selectedLevelId);
|
|
282
283
|
}
|
|
284
|
+
deferRender = debounce(() => this.render(), 0);
|
|
283
285
|
}
|
|
284
286
|
function formatLevelLabel(level) {
|
|
285
|
-
const h = level.
|
|
287
|
+
const h = level.width > level.height ? level.height : level.width;
|
|
286
288
|
return `${h}p`;
|
|
287
289
|
}
|
|
290
|
+
function debounce(fn, wait) {
|
|
291
|
+
let timerId = null;
|
|
292
|
+
return function () {
|
|
293
|
+
if (timerId !== null) {
|
|
294
|
+
clearTimeout(timerId);
|
|
295
|
+
}
|
|
296
|
+
timerId = setTimeout(() => {
|
|
297
|
+
timerId = null;
|
|
298
|
+
fn();
|
|
299
|
+
}, wait);
|
|
300
|
+
};
|
|
301
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UIContainerPlugin, Container } from '@clappr/core';
|
|
2
|
+
import '../../../assets/logo/styles/logo.scss';
|
|
3
|
+
export declare class Logo extends UIContainerPlugin {
|
|
4
|
+
private hasStartedPlaying;
|
|
5
|
+
private $logoContainer;
|
|
6
|
+
get name(): string;
|
|
7
|
+
get supportedVersion(): {
|
|
8
|
+
min: string;
|
|
9
|
+
};
|
|
10
|
+
get template(): any;
|
|
11
|
+
get attributes(): {
|
|
12
|
+
class: string;
|
|
13
|
+
'data-logo': string;
|
|
14
|
+
};
|
|
15
|
+
private get shouldRender();
|
|
16
|
+
bindEvents(): void;
|
|
17
|
+
stopListening(): this;
|
|
18
|
+
private onPlay;
|
|
19
|
+
private onStop;
|
|
20
|
+
private update;
|
|
21
|
+
constructor(container: Container);
|
|
22
|
+
render(): this;
|
|
23
|
+
private setLogoImgAttrs;
|
|
24
|
+
private setLogoWidth;
|
|
25
|
+
private setPosition;
|
|
26
|
+
private setStyles;
|
|
27
|
+
private setStyle;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Logo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logo.d.ts","sourceRoot":"","sources":["../../../src/plugins/logo/Logo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAyB,SAAS,EAAE,MAAM,cAAc,CAAC;AAOnF,OAAO,uCAAuC,CAAC;AAe/C,qBAAa,IAAK,SAAQ,iBAAiB;IACzC,OAAO,CAAC,iBAAiB,CAAS;IAElC,OAAO,CAAC,cAAc,CAA4B;IAElD,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB;;MAEnB;IAED,IAAI,QAAQ,QAEX;IAED,IAAa,UAAU;;;MAKtB;IAED,OAAO,KAAK,YAAY,GAEvB;IAEQ,UAAU;IAQV,aAAa;IAMtB,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,MAAM;gBAYF,SAAS,EAAE,SAAS;IAYvB,MAAM;IAaf,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,YAAY;IA6DpB,OAAO,CAAC,WAAW;IAuCnB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,QAAQ;CAKjB"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { UIContainerPlugin, Events, template as t } from '@clappr/core';
|
|
2
|
+
import { CLAPPR_VERSION } from '../build.js';
|
|
3
|
+
import { calculateSize } from './utils/index.js';
|
|
4
|
+
import logoHTML from '../../../assets/logo/templates/logo.ejs';
|
|
5
|
+
import '../../../assets/logo/styles/logo.scss';
|
|
6
|
+
export class Logo extends UIContainerPlugin {
|
|
7
|
+
hasStartedPlaying = false;
|
|
8
|
+
$logoContainer = null;
|
|
9
|
+
get name() {
|
|
10
|
+
return 'logo';
|
|
11
|
+
}
|
|
12
|
+
get supportedVersion() {
|
|
13
|
+
return { min: CLAPPR_VERSION };
|
|
14
|
+
}
|
|
15
|
+
get template() {
|
|
16
|
+
return t(logoHTML);
|
|
17
|
+
}
|
|
18
|
+
get attributes() {
|
|
19
|
+
return {
|
|
20
|
+
'class': 'player-logo',
|
|
21
|
+
'data-logo': ''
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
get shouldRender() {
|
|
25
|
+
return !!this.options.logo && !!this.options.logo.path;
|
|
26
|
+
}
|
|
27
|
+
bindEvents() {
|
|
28
|
+
window.addEventListener('resize', this.setPosition);
|
|
29
|
+
this.listenTo(this.container, Events.CONTAINER_RESIZE, this.setPosition);
|
|
30
|
+
this.listenTo(this.container, Events.CONTAINER_STOP, this.onStop);
|
|
31
|
+
this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay);
|
|
32
|
+
this.listenTo(this.container, Events.CONTAINER_LOADEDMETADATA, this.setPosition);
|
|
33
|
+
}
|
|
34
|
+
stopListening() {
|
|
35
|
+
window.removeEventListener('resize', this.setPosition);
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
return super.stopListening();
|
|
38
|
+
}
|
|
39
|
+
onPlay() {
|
|
40
|
+
this.hasStartedPlaying = true;
|
|
41
|
+
this.setPosition();
|
|
42
|
+
}
|
|
43
|
+
onStop() {
|
|
44
|
+
this.hasStartedPlaying = false;
|
|
45
|
+
this.update();
|
|
46
|
+
}
|
|
47
|
+
update() {
|
|
48
|
+
if (!this.shouldRender) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!this.hasStartedPlaying) {
|
|
52
|
+
this.$el.hide();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.$el.show();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
constructor(container) {
|
|
59
|
+
super(container);
|
|
60
|
+
this.setPosition = this.setPosition.bind(this);
|
|
61
|
+
this.hasStartedPlaying = false;
|
|
62
|
+
if (!this.options.logo) {
|
|
63
|
+
this.disable();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.render();
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
if (!this.shouldRender) {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
this.$el.html(this.template());
|
|
73
|
+
this.setLogoImgAttrs();
|
|
74
|
+
this.container.$el.append(this.$el.get(0));
|
|
75
|
+
this.update();
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
setLogoImgAttrs() {
|
|
79
|
+
const { logo: { path: imgUrl, width = 60, height = 60 } } = this.options;
|
|
80
|
+
this.$logoContainer = this.$el.find('.clappr-logo');
|
|
81
|
+
const $logo = this.$logoContainer.find('.clappr-logo-img');
|
|
82
|
+
$logo.attr({
|
|
83
|
+
'src': `${imgUrl}`,
|
|
84
|
+
'style': `width: ${width}px;height: ${height}px;`
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
setLogoWidth(size) {
|
|
88
|
+
let { logo: { width = 60, height = 60, objectFit = 'contain' } } = this.options;
|
|
89
|
+
const $logo = this.$logoContainer.find('.clappr-logo-img');
|
|
90
|
+
// TODO size must always be defined
|
|
91
|
+
if (size) {
|
|
92
|
+
const logoWidthTimes = Math.floor(size.width / width);
|
|
93
|
+
const logoHeightTimes = Math.floor(size.height / height);
|
|
94
|
+
if (logoHeightTimes < 4) {
|
|
95
|
+
let maxTimes = logoHeightTimes;
|
|
96
|
+
if (logoWidthTimes < 4) {
|
|
97
|
+
maxTimes = logoWidthTimes < logoHeightTimes ? logoWidthTimes : logoHeightTimes;
|
|
98
|
+
}
|
|
99
|
+
switch (maxTimes) {
|
|
100
|
+
case 0:
|
|
101
|
+
case 1:
|
|
102
|
+
maxTimes = 2;
|
|
103
|
+
break;
|
|
104
|
+
case 2:
|
|
105
|
+
maxTimes = 1.5;
|
|
106
|
+
break;
|
|
107
|
+
case 3:
|
|
108
|
+
maxTimes = 1;
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
width /= maxTimes;
|
|
114
|
+
height /= maxTimes;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
if (logoWidthTimes < 4) {
|
|
118
|
+
let maxTimes = 1;
|
|
119
|
+
switch (logoWidthTimes) {
|
|
120
|
+
case 0:
|
|
121
|
+
case 1:
|
|
122
|
+
maxTimes = 2;
|
|
123
|
+
break;
|
|
124
|
+
case 2:
|
|
125
|
+
maxTimes = 1.5;
|
|
126
|
+
break;
|
|
127
|
+
case 3:
|
|
128
|
+
maxTimes = 1;
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
width /= maxTimes;
|
|
134
|
+
height /= maxTimes;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
$logo.attr({
|
|
139
|
+
'style': `width: ${width}px;height: ${height}px;object-fit: ${objectFit}`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
setPosition() {
|
|
143
|
+
if (!this.shouldRender) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const $el = this.container.$el;
|
|
147
|
+
const targetRect = $el.get(0).getBoundingClientRect();
|
|
148
|
+
const $video = $el.find('video[data-html5-video]');
|
|
149
|
+
if (!$video.get(0)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const { videoWidth, videoHeight } = $video.get(0);
|
|
153
|
+
const dimensions = calculateSize({
|
|
154
|
+
dom: {
|
|
155
|
+
width: targetRect.width,
|
|
156
|
+
height: targetRect.height
|
|
157
|
+
},
|
|
158
|
+
media: {
|
|
159
|
+
width: videoWidth,
|
|
160
|
+
height: videoHeight
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
const { logo } = this.options;
|
|
164
|
+
const { letterboxing: { vertical, horizontal } } = dimensions;
|
|
165
|
+
if (dimensions.media && dimensions.media.width && dimensions.media.height) {
|
|
166
|
+
this.setLogoWidth({ width: dimensions.media.width, height: dimensions.media.height });
|
|
167
|
+
}
|
|
168
|
+
const el = this.$logoContainer.get(0);
|
|
169
|
+
this.setStyles(logo, ['top', 'bottom'], el, vertical);
|
|
170
|
+
this.setStyles(logo, ['left', 'right'], el, horizontal);
|
|
171
|
+
this.update();
|
|
172
|
+
}
|
|
173
|
+
setStyles(opts, props, el, value) {
|
|
174
|
+
props.forEach(p => this.setStyle(opts, p, el, value));
|
|
175
|
+
}
|
|
176
|
+
setStyle(opts, p, el, value) {
|
|
177
|
+
if (opts[p]) {
|
|
178
|
+
el.style[p] = `${opts[p] + value}px`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|