@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,369 @@
|
|
|
1
|
+
import { UICorePlugin, Events, template, Core, Container } from '@clappr/core';
|
|
2
|
+
import { reportError } from '@gcorevideo/utils';
|
|
3
|
+
import Mousetrap from 'mousetrap';
|
|
4
|
+
|
|
5
|
+
import { CLAPPR_VERSION } from '../build.js';
|
|
6
|
+
import { ClapprStatsEvents, Metrics as BaseMetrics } from '../clappr-stats/types.js';
|
|
7
|
+
import { newMetrics as newBaseMetrics } from '../clappr-stats/utils.js';
|
|
8
|
+
import Formatter from './formatter.js';
|
|
9
|
+
import {
|
|
10
|
+
clearSpeedTestResults,
|
|
11
|
+
configureSpeedTest,
|
|
12
|
+
drawSpeedTestResults,
|
|
13
|
+
initSpeedTest,
|
|
14
|
+
startSpeedtest,
|
|
15
|
+
stopSpeedtest,
|
|
16
|
+
} from './speedtest/index.js';
|
|
17
|
+
import { CustomMetrics } from './speedtest/types.js';
|
|
18
|
+
import { ZeptoResult } from '../types.js';
|
|
19
|
+
|
|
20
|
+
import '../../../assets/clappr-nerd-stats/clappr-nerd-stats.scss';
|
|
21
|
+
import pluginHtml from '../../../assets/clappr-nerd-stats/clappr-nerd-stats.ejs';
|
|
22
|
+
import buttonHtml from '../../../assets/clappr-nerd-stats/button.ejs';
|
|
23
|
+
import statsIcon from '../../../assets/icons/new/stats.svg';
|
|
24
|
+
|
|
25
|
+
const qualityClasses = [
|
|
26
|
+
'speedtest-quality-value-1',
|
|
27
|
+
'speedtest-quality-value-2',
|
|
28
|
+
'speedtest-quality-value-3',
|
|
29
|
+
'speedtest-quality-value-4',
|
|
30
|
+
'speedtest-quality-value-5'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const getDownloadQuality = (speedValue: number): number => {
|
|
34
|
+
if (speedValue < 3) {
|
|
35
|
+
return 1;
|
|
36
|
+
} else if (speedValue < 7) {
|
|
37
|
+
return 2;
|
|
38
|
+
} else if (speedValue < 13) {
|
|
39
|
+
return 3;
|
|
40
|
+
} else if (speedValue < 25) {
|
|
41
|
+
return 4;
|
|
42
|
+
} else {
|
|
43
|
+
return 5;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const getPingQuality = (pingValue: number): number => {
|
|
48
|
+
if (pingValue < 20) {
|
|
49
|
+
return 5;
|
|
50
|
+
} else if (pingValue < 50) {
|
|
51
|
+
return 4;
|
|
52
|
+
} else if (pingValue < 100) {
|
|
53
|
+
return 3;
|
|
54
|
+
} else if (pingValue < 150) {
|
|
55
|
+
return 2;
|
|
56
|
+
} else {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const generateQualityHtml = (quality: number): string => {
|
|
62
|
+
const html = [];
|
|
63
|
+
const qualityClassName = qualityClasses[quality - 1];
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < qualityClasses.length; i++) {
|
|
66
|
+
if (i < quality) {
|
|
67
|
+
html.push(`<div class="speedtest-quality-content-item ${qualityClassName}"></div>`);
|
|
68
|
+
} else {
|
|
69
|
+
html.push('<div class="speedtest-quality-content-item"></div>');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return html.join('');
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const drawSummary = (customMetrics: CustomMetrics, vodContainer: ZeptoResult, liveContainer: ZeptoResult) => {
|
|
77
|
+
const { connectionSpeed, ping } = customMetrics;
|
|
78
|
+
|
|
79
|
+
if (!connectionSpeed || !ping) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const downloadQuality = getDownloadQuality(connectionSpeed);
|
|
83
|
+
const pingQuality = getPingQuality(ping);
|
|
84
|
+
const liveQuality = Math.min(downloadQuality, pingQuality);
|
|
85
|
+
const vodHtml = generateQualityHtml(downloadQuality);
|
|
86
|
+
const liveHtml = generateQualityHtml(liveQuality);
|
|
87
|
+
|
|
88
|
+
vodContainer.html(vodHtml);
|
|
89
|
+
liveContainer.html(liveHtml);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
type IconPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
93
|
+
|
|
94
|
+
type Metrics = BaseMetrics & {
|
|
95
|
+
general: {
|
|
96
|
+
displayResolution?: string;
|
|
97
|
+
volume?: number;
|
|
98
|
+
},
|
|
99
|
+
custom: CustomMetrics & {
|
|
100
|
+
vodQuality?: string;
|
|
101
|
+
liveQuality?: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// const T = 'plugins.clappr_nerd_stats';
|
|
106
|
+
|
|
107
|
+
export class ClapprNerdStats extends UICorePlugin {
|
|
108
|
+
private container: Container | null = null;
|
|
109
|
+
|
|
110
|
+
private customMetrics: CustomMetrics = {
|
|
111
|
+
connectionSpeed: 0,
|
|
112
|
+
ping: 0,
|
|
113
|
+
jitter: 0,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private metrics: Metrics = newMetrics();
|
|
117
|
+
|
|
118
|
+
private showing = false;
|
|
119
|
+
|
|
120
|
+
private shortcut: string[];
|
|
121
|
+
|
|
122
|
+
private iconPosition: IconPosition;
|
|
123
|
+
|
|
124
|
+
get name() {
|
|
125
|
+
return 'clappr_nerd_stats';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
get supportedVersion() {
|
|
129
|
+
return { min: CLAPPR_VERSION };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get template() {
|
|
133
|
+
return template(pluginHtml);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
override get attributes() {
|
|
137
|
+
return {
|
|
138
|
+
'data-clappr-nerd-stats': '',
|
|
139
|
+
'class': 'clappr-nerd-stats'
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override get events() {
|
|
144
|
+
return {
|
|
145
|
+
'click [data-show-stats-button]': 'showOrHide',
|
|
146
|
+
'click [data-close-button]': 'hide',
|
|
147
|
+
'click [data-refresh-button]': 'refreshSpeedTest',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
get statsBoxElem() {
|
|
152
|
+
return '.clappr-nerd-stats[data-clappr-nerd-stats] .stats-box';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
get statsBoxWidthThreshold() {
|
|
156
|
+
return 720;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
get playerWidth() {
|
|
160
|
+
return this.core.$el.width();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
get playerHeight() {
|
|
164
|
+
return this.core.$el.height();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
constructor(core: Core) {
|
|
168
|
+
super(core);
|
|
169
|
+
this.shortcut = core.options.clapprNerdStats?.shortcut ?? ['command+shift+s', 'ctrl+shift+s'];
|
|
170
|
+
this.iconPosition = core.options.clapprNerdStats?.iconPosition ?? 'bottom-right';
|
|
171
|
+
this.customMetrics = {
|
|
172
|
+
connectionSpeed: 0,
|
|
173
|
+
ping: 0,
|
|
174
|
+
jitter: 0,
|
|
175
|
+
};
|
|
176
|
+
configureSpeedTest(core.options.clapprNerdStats?.speedTestServers ?? []);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
override bindEvents() {
|
|
180
|
+
this.listenToOnce(this.core, Events.CORE_READY, this.init);
|
|
181
|
+
this.listenTo(this.core, 'gear:rendered', this.addToBottomGear);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private init() {
|
|
185
|
+
this.container = this.core.activeContainer;
|
|
186
|
+
const clapprStats = this.container?.getPlugin('clappr_stats');
|
|
187
|
+
|
|
188
|
+
if (!clapprStats) {
|
|
189
|
+
reportError({
|
|
190
|
+
message: 'clappr_stats plugin is not available',
|
|
191
|
+
});
|
|
192
|
+
console.error('clappr-stats not available. Please, include it as a plugin of your Clappr instance.\n' +
|
|
193
|
+
'For more info, visit: https://github.com/clappr/clappr-stats.');
|
|
194
|
+
this.disable();
|
|
195
|
+
} else {
|
|
196
|
+
Mousetrap.bind(this.shortcut, () => this.showOrHide());
|
|
197
|
+
this.listenTo(this.core, Events.CORE_RESIZE, this.onPlayerResize);
|
|
198
|
+
// TODO: fix
|
|
199
|
+
this.listenTo(clapprStats, ClapprStatsEvents.REPORT_EVENT, this.updateMetrics);
|
|
200
|
+
clapprStats.setUpdateMetrics(this.updateMetrics.bind(this));
|
|
201
|
+
this.updateMetrics(clapprStats.exportMetrics());
|
|
202
|
+
this.render();
|
|
203
|
+
// this.$el.find('.speed-test-button').on('click', this.onSpeedTestClick.bind(this));
|
|
204
|
+
// this.$el.find('.close-speed-test').on('click', this.closeSpeedTest.bind(this));
|
|
205
|
+
// this.$el.find('.speed-test').hide();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private showOrHide(event?: MouseEvent) {
|
|
210
|
+
if (this.showing) {
|
|
211
|
+
this.hide(event);
|
|
212
|
+
} else {
|
|
213
|
+
this.show(event);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private show(event?: MouseEvent) {
|
|
218
|
+
this.core.$el.find(this.statsBoxElem).show();
|
|
219
|
+
this.showing = true;
|
|
220
|
+
if (event) {
|
|
221
|
+
event.stopPropagation();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
this.refreshSpeedTest();
|
|
225
|
+
initSpeedTest(this.customMetrics).then(() => {
|
|
226
|
+
startSpeedtest();
|
|
227
|
+
}).catch(e => {
|
|
228
|
+
reportError(e);
|
|
229
|
+
this.disable();
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private hide(event?: MouseEvent) {
|
|
234
|
+
this.core.$el.find(this.statsBoxElem).hide();
|
|
235
|
+
this.showing = false;
|
|
236
|
+
if (event) {
|
|
237
|
+
event.stopPropagation();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
stopSpeedtest();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private onPlayerResize() {
|
|
244
|
+
this.setStatsBoxSize();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private addGeneralMetrics() {
|
|
248
|
+
this.metrics.general = {
|
|
249
|
+
displayResolution: (this.playerWidth + 'x' + this.playerHeight),
|
|
250
|
+
volume: this.container?.volume
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private addCustomMetrics() {
|
|
255
|
+
this.metrics.custom = this.customMetrics;
|
|
256
|
+
const videoQualityNames = ['SD (480p)', 'HD (720p)', 'Full HD (1080p)', '2K (1440p)', '4K (2160p)'];
|
|
257
|
+
const { connectionSpeed, ping } = this.customMetrics;
|
|
258
|
+
|
|
259
|
+
if (!connectionSpeed || !ping) {
|
|
260
|
+
const calculatingText = 'Calculating... Please wait.';
|
|
261
|
+
|
|
262
|
+
this.metrics.custom.vodQuality = calculatingText;
|
|
263
|
+
this.metrics.custom.liveQuality = calculatingText;
|
|
264
|
+
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const downloadQuality = getDownloadQuality(connectionSpeed);
|
|
268
|
+
const pingQuality = getPingQuality(ping);
|
|
269
|
+
const liveQuality = Math.min(downloadQuality, pingQuality);
|
|
270
|
+
|
|
271
|
+
const prefix = 'Optimal for ';
|
|
272
|
+
|
|
273
|
+
this.metrics.custom.vodQuality = prefix + videoQualityNames[downloadQuality - 1];
|
|
274
|
+
this.metrics.custom.liveQuality = prefix + videoQualityNames[liveQuality - 1];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private updateMetrics(metrics: BaseMetrics) {
|
|
278
|
+
Object.assign(this.metrics, metrics);
|
|
279
|
+
this.addGeneralMetrics();
|
|
280
|
+
this.addCustomMetrics();
|
|
281
|
+
|
|
282
|
+
const scrollTop = this.core.$el.find(this.statsBoxElem).scrollTop();
|
|
283
|
+
|
|
284
|
+
this.$el.html(this.template({
|
|
285
|
+
metrics: Formatter.format(this.metrics),
|
|
286
|
+
iconPosition: this.iconPosition
|
|
287
|
+
}));
|
|
288
|
+
this.setStatsBoxSize();
|
|
289
|
+
drawSpeedTestResults();
|
|
290
|
+
drawSummary(
|
|
291
|
+
this.metrics?.custom,
|
|
292
|
+
this.$el.find('.speedtest-quality-content[data-streaming-type="vod"]'),
|
|
293
|
+
this.$el.find('.speedtest-quality-content[data-streaming-type="live"]')
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
this.core.$el.find(this.statsBoxElem).scrollTop(scrollTop);
|
|
297
|
+
|
|
298
|
+
if (!this.showing) {
|
|
299
|
+
this.hide();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private setStatsBoxSize() {
|
|
304
|
+
if (this.playerWidth >= this.statsBoxWidthThreshold) {
|
|
305
|
+
this.$el.find(this.statsBoxElem).addClass('wide');
|
|
306
|
+
this.$el.find(this.statsBoxElem).removeClass('narrow');
|
|
307
|
+
} else {
|
|
308
|
+
this.$el.find(this.statsBoxElem).removeClass('wide');
|
|
309
|
+
this.$el.find(this.statsBoxElem).addClass('narrow');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
override render() {
|
|
314
|
+
this.core.$el.append(this.$el[0]);
|
|
315
|
+
this.hide();
|
|
316
|
+
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private addToBottomGear() {
|
|
321
|
+
this.core.mediaControl.$el?.find('.gear-options-list [data-nerd]').html(buttonHtml);
|
|
322
|
+
|
|
323
|
+
// this.core.$el.append(optionsList);
|
|
324
|
+
const $button = this.core.$el.find('.nerd-button');
|
|
325
|
+
|
|
326
|
+
$button.find('.stats-icon').html(statsIcon);
|
|
327
|
+
|
|
328
|
+
$button.on('click', () => {
|
|
329
|
+
// $optionsList.remove();
|
|
330
|
+
this.showOrHide();
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private clearCustomMetrics() {
|
|
335
|
+
const clapprStats = this.container?.getPlugin('clappr_stats');
|
|
336
|
+
|
|
337
|
+
this.customMetrics.connectionSpeed = 0;
|
|
338
|
+
this.customMetrics.ping = 0;
|
|
339
|
+
this.customMetrics.jitter = 0;
|
|
340
|
+
|
|
341
|
+
if (clapprStats) {
|
|
342
|
+
this.updateMetrics(clapprStats.exportMetrics());
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
private refreshSpeedTest() {
|
|
347
|
+
stopSpeedtest();
|
|
348
|
+
setTimeout(() => {
|
|
349
|
+
this.clearCustomMetrics();
|
|
350
|
+
clearSpeedTestResults();
|
|
351
|
+
drawSpeedTestResults();
|
|
352
|
+
}, 200);
|
|
353
|
+
setTimeout(() => {
|
|
354
|
+
startSpeedtest();
|
|
355
|
+
}, 800);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function newMetrics(): Metrics {
|
|
360
|
+
return {
|
|
361
|
+
...newBaseMetrics(),
|
|
362
|
+
general: {},
|
|
363
|
+
custom: {
|
|
364
|
+
connectionSpeed: 0,
|
|
365
|
+
ping: 0,
|
|
366
|
+
jitter: 0,
|
|
367
|
+
},
|
|
368
|
+
}
|
|
369
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import humanFormat, { ScaleLike } from 'human-format';
|
|
2
|
+
import type { MetricsKind, MetricsType } from './types';
|
|
3
|
+
|
|
4
|
+
const timeScale = new humanFormat.Scale({
|
|
5
|
+
ms: 1,
|
|
6
|
+
sec: 1000,
|
|
7
|
+
min: 60000,
|
|
8
|
+
hours: 3600000
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const percentScale = new humanFormat.Scale({
|
|
12
|
+
'%': 1
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
type FormatParams = {
|
|
16
|
+
scale?: ScaleLike;
|
|
17
|
+
unit?: 'bps';
|
|
18
|
+
decimals?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const formattingTemplate: Record<MetricsKind, Partial<Record<MetricsType, FormatParams>>> = {
|
|
22
|
+
general: {
|
|
23
|
+
volume: {
|
|
24
|
+
scale: percentScale
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
timers: {
|
|
28
|
+
startup: {
|
|
29
|
+
scale: timeScale
|
|
30
|
+
},
|
|
31
|
+
watch: {
|
|
32
|
+
scale: timeScale
|
|
33
|
+
},
|
|
34
|
+
pause: {
|
|
35
|
+
scale: timeScale
|
|
36
|
+
},
|
|
37
|
+
buffering: {
|
|
38
|
+
scale: timeScale
|
|
39
|
+
},
|
|
40
|
+
session: {
|
|
41
|
+
scale: timeScale
|
|
42
|
+
},
|
|
43
|
+
latency: {
|
|
44
|
+
scale: timeScale
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
extra: {
|
|
48
|
+
buffersize: {
|
|
49
|
+
scale: timeScale
|
|
50
|
+
},
|
|
51
|
+
duration: {
|
|
52
|
+
scale: timeScale
|
|
53
|
+
},
|
|
54
|
+
currentTime: {
|
|
55
|
+
scale: timeScale
|
|
56
|
+
},
|
|
57
|
+
bitrateWeightedMean: {
|
|
58
|
+
unit: 'bps'
|
|
59
|
+
},
|
|
60
|
+
bitrateMostUsed: {
|
|
61
|
+
unit: 'bps'
|
|
62
|
+
},
|
|
63
|
+
bandwidth: {
|
|
64
|
+
unit: 'bps'
|
|
65
|
+
},
|
|
66
|
+
watchedPercentage: {
|
|
67
|
+
scale: percentScale
|
|
68
|
+
},
|
|
69
|
+
bufferingPercentage: {
|
|
70
|
+
scale: percentScale
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type MetricsValue = number | string;
|
|
76
|
+
type Metrics = Partial<Record<MetricsKind, Partial<Record<MetricsType, MetricsValue>>>>;
|
|
77
|
+
|
|
78
|
+
export default class Formatter {
|
|
79
|
+
static format(metrics: Metrics): Metrics {
|
|
80
|
+
const formattedMetrics: Metrics = {};
|
|
81
|
+
|
|
82
|
+
Object.entries(metrics).forEach(([type, mm]) => {
|
|
83
|
+
const fmt: Partial<Record<MetricsType, MetricsValue>> = {};
|
|
84
|
+
formattedMetrics[type as MetricsKind] = fmt;
|
|
85
|
+
const typeTemplate = formattingTemplate[type as MetricsKind];
|
|
86
|
+
|
|
87
|
+
Object.entries(mm).forEach(([name, value]) => {
|
|
88
|
+
// const value = mm[name];
|
|
89
|
+
|
|
90
|
+
if (typeTemplate && typeTemplate[name as MetricsType] && (typeof value === 'number') && !isNaN(value)) {
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
const templateScale = typeTemplate[name as MetricsType].scale || 'SI';
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
const templateUnit = typeTemplate[name as MetricsType].unit || '';
|
|
95
|
+
|
|
96
|
+
fmt[name as MetricsType] = humanFormat(value, {
|
|
97
|
+
scale: templateScale,
|
|
98
|
+
unit: templateUnit,
|
|
99
|
+
decimals: 2
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
fmt[name as MetricsType] = value;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return formattedMetrics;
|
|
108
|
+
}
|
|
109
|
+
}
|