@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.
Files changed (349) hide show
  1. package/assets/audio-selector/style.scss +156 -0
  2. package/assets/audio-selector/track-selector.ejs +12 -0
  3. package/assets/big-mute-button/big-mute-button.ejs +3 -0
  4. package/assets/big-mute-button/big-mute-button.scss +57 -0
  5. package/assets/bottom-gear/bottomgear.ejs +12 -0
  6. package/assets/bottom-gear/gear-sub-menu.scss +95 -0
  7. package/assets/bottom-gear/gear.scss +79 -0
  8. package/assets/clappr-nerd-stats/button.ejs +4 -0
  9. package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +212 -0
  10. package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +488 -0
  11. package/assets/clappr-nerd-stats/options-list.ejs +9 -0
  12. package/assets/clappr-nerd-stats/settings.ejs +12 -0
  13. package/assets/clappr-nerd-stats/speedtest/speedtest.worker.js +775 -0
  14. package/assets/clips/clips.scss +3 -0
  15. package/assets/context-menu/context_menu.ejs +8 -0
  16. package/assets/context-menu/context_menu.scss +31 -0
  17. package/assets/dvr-controls/dvr_controls.scss +136 -0
  18. package/assets/dvr-controls/index.ejs +2 -0
  19. package/assets/error-screen/error_screen.ejs +13 -0
  20. package/assets/error-screen/error_screen.scss +40 -0
  21. package/assets/icons/new/arrow-left.svg +5 -0
  22. package/assets/icons/new/arrow-right.svg +5 -0
  23. package/assets/icons/new/check.svg +5 -0
  24. package/assets/icons/new/close.svg +12 -0
  25. package/assets/icons/new/full.svg +8 -0
  26. package/assets/icons/new/fullscreen-off.svg +14 -0
  27. package/assets/icons/new/fullscreen-on.svg +14 -0
  28. package/assets/icons/new/gear-hd.svg +16 -0
  29. package/assets/icons/new/gear.svg +12 -0
  30. package/assets/icons/new/hd.svg +8 -0
  31. package/assets/icons/new/pause.svg +5 -0
  32. package/assets/icons/new/pip.svg +5 -0
  33. package/assets/icons/new/play.svg +10 -0
  34. package/assets/icons/new/replayleft.svg +5 -0
  35. package/assets/icons/new/replayright.svg +5 -0
  36. package/assets/icons/new/speed.svg +5 -0
  37. package/assets/icons/new/stats.svg +3 -0
  38. package/assets/icons/new/stop.svg +3 -0
  39. package/assets/icons/new/subtitles-off.svg +5 -0
  40. package/assets/icons/new/subtitles-on.svg +6 -0
  41. package/assets/icons/new/volume-max.svg +5 -0
  42. package/assets/icons/new/volume-min.svg +5 -0
  43. package/assets/icons/new/volume-off.svg +5 -0
  44. package/assets/icons/old/cardboard.svg +4 -0
  45. package/assets/icons/old/close-share.svg +13 -0
  46. package/assets/icons/old/close.svg +13 -0
  47. package/assets/icons/old/fb.svg +13 -0
  48. package/assets/icons/old/fullscreen.svg +12 -0
  49. package/assets/icons/old/language.svg +1 -0
  50. package/assets/icons/old/pause.svg +12 -0
  51. package/assets/icons/old/play.svg +12 -0
  52. package/assets/icons/old/quality-arrow.svg +13 -0
  53. package/assets/icons/old/reload.svg +4 -0
  54. package/assets/icons/old/share.svg +13 -0
  55. package/assets/icons/old/sound-off.svg +15 -0
  56. package/assets/icons/old/sound-on.svg +15 -0
  57. package/assets/icons/old/streams.svg +3 -0
  58. package/assets/icons/old/twitter.svg +13 -0
  59. package/assets/icons/old/wn.svg +15 -0
  60. package/assets/icons/standard/01-play.svg +3 -0
  61. package/assets/icons/standard/02-pause.svg +3 -0
  62. package/assets/icons/standard/03-stop.svg +3 -0
  63. package/assets/icons/standard/04-volume.svg +3 -0
  64. package/assets/icons/standard/05-mute.svg +3 -0
  65. package/assets/icons/standard/06-expand.svg +3 -0
  66. package/assets/icons/standard/07-shrink.svg +3 -0
  67. package/assets/icons/standard/08-hd.svg +3 -0
  68. package/assets/icons/standard/09-cc.svg +8 -0
  69. package/assets/icons/standard/10-reload.svg +4 -0
  70. package/assets/level-selector/button.ejs +8 -0
  71. package/assets/level-selector/list.ejs +22 -0
  72. package/assets/level-selector/style.scss +4 -0
  73. package/assets/logo/styles/logo.scss +10 -0
  74. package/assets/logo/templates/logo.ejs +3 -0
  75. package/assets/media-control/closed-hand.cur +0 -0
  76. package/assets/media-control/container.scss +57 -0
  77. package/assets/media-control/media-control.ejs +133 -0
  78. package/assets/media-control/media-control.scss +390 -0
  79. package/assets/media-control/plugins.scss +94 -0
  80. package/assets/media-control/width270.scss +50 -0
  81. package/assets/media-control/width370.scss +263 -0
  82. package/assets/multi-camera/multicamera.ejs +29 -0
  83. package/assets/multi-camera/style.scss +176 -0
  84. package/assets/picture-in-picture/button.ejs +3 -0
  85. package/assets/picture-in-picture/button.scss +11 -0
  86. package/assets/playback-rate/button.ejs +6 -0
  87. package/assets/playback-rate/list.ejs +14 -0
  88. package/assets/playback-rate/playback-rate-selector.ejs +9 -0
  89. package/assets/poster/poster.ejs +1 -0
  90. package/assets/poster/poster.scss +32 -0
  91. package/assets/seek-time/seek-time.html +2 -0
  92. package/assets/seek-time/seek-time.scss +38 -0
  93. package/assets/share/share.ejs +37 -0
  94. package/assets/share/style.scss +104 -0
  95. package/assets/skip-time/skip-time.ejs +8 -0
  96. package/assets/skip-time/style.scss +24 -0
  97. package/assets/spinner-three-bounce/spinner.ejs +3 -0
  98. package/assets/spinner-three-bounce/spinner.scss +44 -0
  99. package/assets/style/main.scss +50 -0
  100. package/assets/style/theme.scss +42 -0
  101. package/assets/style/variables.scss +7 -0
  102. package/assets/subtitles/combobox copy.ejs +16 -0
  103. package/assets/subtitles/combobox.ejs +16 -0
  104. package/assets/subtitles/string.ejs +3 -0
  105. package/assets/subtitles/style.scss +99 -0
  106. package/assets/thumbnails/scrub-thumbnails.ejs +10 -0
  107. package/assets/thumbnails/style.scss +75 -0
  108. package/assets/vast-ads/style.scss +112 -0
  109. package/assets/video360/button.ejs +1 -0
  110. package/assets/video360/style.scss +8 -0
  111. package/build/vite-raw-plugin.js +18 -0
  112. package/dist/index.js +1 -1
  113. package/dist/plugins/index.css +2164 -0
  114. package/dist/plugins/index.js/index.plugins.js +40837 -0
  115. package/dist/plugins/index.plugins.js +40837 -0
  116. package/lib/index.core.d.ts +15 -0
  117. package/lib/index.core.d.ts.map +1 -0
  118. package/lib/index.core.js +14 -0
  119. package/lib/index.d.ts +2 -14
  120. package/lib/index.d.ts.map +1 -1
  121. package/lib/index.js +2 -14
  122. package/lib/index.plugins.d.ts +38 -0
  123. package/lib/index.plugins.d.ts.map +1 -0
  124. package/lib/index.plugins.js +40 -0
  125. package/lib/plugins/audio-selector/AudioSelector.d.ts +3 -3
  126. package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
  127. package/lib/plugins/audio-selector/AudioSelector.js +6 -12
  128. package/lib/plugins/big-mute-button/BigMuteButton.d.ts +2 -2
  129. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  130. package/lib/plugins/big-mute-button/BigMuteButton.js +7 -12
  131. package/lib/plugins/bottom-gear/BottomGear.d.ts +4 -3
  132. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  133. package/lib/plugins/bottom-gear/BottomGear.js +11 -16
  134. package/lib/plugins/build.d.ts +2 -0
  135. package/lib/plugins/build.d.ts.map +1 -0
  136. package/lib/plugins/build.js +1 -0
  137. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +44 -0
  138. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -0
  139. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +294 -0
  140. package/lib/plugins/clappr-nerd-stats/formatter.d.ts +8 -0
  141. package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -0
  142. package/lib/plugins/clappr-nerd-stats/formatter.js +91 -0
  143. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts +54 -0
  144. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -0
  145. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +335 -0
  146. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +9 -0
  147. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -0
  148. package/lib/plugins/clappr-nerd-stats/speedtest/index.js +154 -0
  149. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +6 -0
  150. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -0
  151. package/lib/plugins/clappr-nerd-stats/speedtest/types.js +1 -0
  152. package/lib/plugins/clappr-nerd-stats/types.d.ts +4 -0
  153. package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -0
  154. package/lib/plugins/clappr-nerd-stats/types.js +1 -0
  155. package/lib/plugins/clappr-stats/ClapprStats.d.ts +56 -0
  156. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -0
  157. package/lib/plugins/clappr-stats/ClapprStats.js +332 -0
  158. package/lib/plugins/clappr-stats/types.d.ts +50 -0
  159. package/lib/plugins/clappr-stats/types.d.ts.map +1 -0
  160. package/lib/plugins/clappr-stats/types.js +5 -0
  161. package/lib/plugins/clappr-stats/utils.d.ts +3 -0
  162. package/lib/plugins/clappr-stats/utils.d.ts.map +1 -0
  163. package/lib/plugins/clappr-stats/utils.js +40 -0
  164. package/lib/plugins/click-to-pause/ClickToPause.d.ts +2 -2
  165. package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
  166. package/lib/plugins/click-to-pause/ClickToPause.js +4 -6
  167. package/lib/plugins/clips/Clips.d.ts +23 -0
  168. package/lib/plugins/clips/Clips.d.ts.map +1 -0
  169. package/lib/plugins/clips/Clips.js +109 -0
  170. package/lib/plugins/context-menu/ContextMenu.d.ts +36 -0
  171. package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -0
  172. package/lib/plugins/context-menu/ContextMenu.js +102 -0
  173. package/lib/plugins/disable-controls/DisableControls.d.ts +1 -1
  174. package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -1
  175. package/lib/plugins/disable-controls/DisableControls.js +3 -5
  176. package/lib/plugins/dvr-controls/DVRControls.d.ts +4 -4
  177. package/lib/plugins/dvr-controls/DVRControls.d.ts.map +1 -1
  178. package/lib/plugins/dvr-controls/DVRControls.js +5 -4
  179. package/lib/plugins/error-screen/ErrorScreen.d.ts +44 -0
  180. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -0
  181. package/lib/plugins/error-screen/ErrorScreen.js +179 -0
  182. package/lib/plugins/favicon/Favicon.d.ts +24 -0
  183. package/lib/plugins/favicon/Favicon.d.ts.map +1 -0
  184. package/lib/plugins/favicon/Favicon.js +106 -0
  185. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +30 -0
  186. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -0
  187. package/lib/plugins/google-analytics/GoogleAnalytics.js +114 -0
  188. package/lib/plugins/index.d.ts +38 -0
  189. package/lib/plugins/index.d.ts.map +1 -0
  190. package/lib/plugins/index.js +40 -0
  191. package/lib/plugins/kibo/index.d.ts +23 -0
  192. package/lib/plugins/kibo/index.d.ts.map +1 -0
  193. package/lib/plugins/kibo/index.js +199 -0
  194. package/lib/plugins/level-selector/LevelSelector.d.ts +48 -17
  195. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  196. package/lib/plugins/level-selector/LevelSelector.js +169 -155
  197. package/lib/plugins/logo/Logo.d.ts +29 -0
  198. package/lib/plugins/logo/Logo.d.ts.map +1 -0
  199. package/lib/plugins/logo/Logo.js +181 -0
  200. package/lib/plugins/logo/utils/index.d.ts +22 -0
  201. package/lib/plugins/logo/utils/index.d.ts.map +1 -0
  202. package/lib/plugins/logo/utils/index.js +32 -0
  203. package/lib/plugins/media-control/MediaControl.d.ts +20 -25
  204. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  205. package/lib/plugins/media-control/MediaControl.js +136 -106
  206. package/lib/plugins/multi-camera/MultiCamera.d.ts +59 -0
  207. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -0
  208. package/lib/plugins/multi-camera/MultiCamera.js +353 -0
  209. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +20 -0
  210. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -0
  211. package/lib/plugins/picture-in-picture/PictureInPicture.js +68 -0
  212. package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -0
  213. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -0
  214. package/lib/plugins/playback-rate/PlaybackRate.js +205 -0
  215. package/lib/plugins/poster/Poster.d.ts +18 -17
  216. package/lib/plugins/poster/Poster.d.ts.map +1 -1
  217. package/lib/plugins/poster/Poster.js +83 -37
  218. package/lib/plugins/seek-time/SeekTime.d.ts +38 -0
  219. package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -0
  220. package/lib/plugins/seek-time/SeekTime.js +153 -0
  221. package/lib/plugins/share/Share.d.ts +38 -0
  222. package/lib/plugins/share/Share.d.ts.map +1 -0
  223. package/lib/plugins/share/Share.js +122 -0
  224. package/lib/plugins/skip-time/SkipTime.d.ts +28 -0
  225. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -0
  226. package/lib/plugins/skip-time/SkipTime.js +86 -0
  227. package/lib/plugins/source-controller/SourceController.d.ts +41 -0
  228. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -0
  229. package/lib/plugins/source-controller/SourceController.js +199 -0
  230. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +26 -0
  231. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -0
  232. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +117 -0
  233. package/lib/plugins/statistics/Statistics.d.ts +52 -0
  234. package/lib/plugins/statistics/Statistics.d.ts.map +1 -0
  235. package/lib/plugins/statistics/Statistics.js +130 -0
  236. package/lib/plugins/subtitles/Subtitles.d.ts +61 -0
  237. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -0
  238. package/lib/plugins/subtitles/Subtitles.js +354 -0
  239. package/lib/plugins/thumbnails/Thumbnails.d.ts +47 -0
  240. package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -0
  241. package/lib/plugins/thumbnails/Thumbnails.js +414 -0
  242. package/lib/plugins/types.d.ts +8 -0
  243. package/lib/plugins/types.d.ts.map +1 -0
  244. package/lib/plugins/types.js +1 -0
  245. package/lib/plugins/utils.d.ts +5 -0
  246. package/lib/plugins/utils.d.ts.map +1 -0
  247. package/lib/plugins/utils.js +68 -0
  248. package/lib/plugins/vast-ads/VastAds.d.ts +72 -0
  249. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -0
  250. package/lib/plugins/vast-ads/VastAds.js +686 -0
  251. package/lib/plugins/vast-ads/loaderxml.d.ts +32 -0
  252. package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -0
  253. package/lib/plugins/vast-ads/loaderxml.js +226 -0
  254. package/lib/plugins/vast-ads/roll.d.ts +60 -0
  255. package/lib/plugins/vast-ads/roll.d.ts.map +1 -0
  256. package/lib/plugins/vast-ads/roll.js +415 -0
  257. package/lib/plugins/vast-ads/rollmanager.d.ts +62 -0
  258. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -0
  259. package/lib/plugins/vast-ads/rollmanager.js +347 -0
  260. package/lib/plugins/vast-ads/sctemanager.d.ts +18 -0
  261. package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -0
  262. package/lib/plugins/vast-ads/sctemanager.js +116 -0
  263. package/lib/plugins/vast-ads/types.d.ts +12 -0
  264. package/lib/plugins/vast-ads/types.d.ts.map +1 -0
  265. package/lib/plugins/vast-ads/types.js +1 -0
  266. package/lib/plugins/vast-ads/urlhandler.d.ts +4 -0
  267. package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -0
  268. package/lib/plugins/vast-ads/urlhandler.js +30 -0
  269. package/lib/plugins/vast-ads/xmlhttprequest.d.ts +6 -0
  270. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -0
  271. package/lib/plugins/vast-ads/xmlhttprequest.js +39 -0
  272. package/lib/plugins/vast-ads/xmlmerge.d.ts +12 -0
  273. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -0
  274. package/lib/plugins/vast-ads/xmlmerge.js +82 -0
  275. package/lib/plugins/volume-fade/VolumeFade.d.ts +21 -0
  276. package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -0
  277. package/lib/plugins/volume-fade/VolumeFade.js +90 -0
  278. package/package.json +10 -2
  279. package/rollup.config.js +32 -2
  280. package/src/index.core.ts +15 -0
  281. package/src/index.plugins.ts +42 -0
  282. package/src/index.ts +2 -15
  283. package/src/plugins/audio-selector/AudioSelector.ts +370 -0
  284. package/src/plugins/big-mute-button/BigMuteButton.ts +187 -0
  285. package/src/plugins/bottom-gear/BottomGear.ts +122 -0
  286. package/src/plugins/build.ts +1 -0
  287. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +369 -0
  288. package/src/plugins/clappr-nerd-stats/formatter.ts +109 -0
  289. package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +414 -0
  290. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +183 -0
  291. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +5 -0
  292. package/src/plugins/clappr-nerd-stats/types.ts +3 -0
  293. package/src/plugins/clappr-stats/ClapprStats.ts +441 -0
  294. package/src/plugins/clappr-stats/types.ts +52 -0
  295. package/src/plugins/clappr-stats/utils.ts +42 -0
  296. package/src/plugins/click-to-pause/ClickToPause.ts +93 -0
  297. package/src/plugins/clips/Clips.ts +152 -0
  298. package/src/plugins/context-menu/ContextMenu.ts +134 -0
  299. package/src/plugins/disable-controls/DisableControls.ts +81 -0
  300. package/src/plugins/dvr-controls/DvrControls.ts +131 -0
  301. package/src/plugins/error-screen/ErrorScreen.ts +241 -0
  302. package/src/plugins/favicon/Favicon.ts +137 -0
  303. package/src/plugins/ga-events/GaEvents.js +395 -0
  304. package/src/plugins/ga-events/ga-tracking.js +46 -0
  305. package/src/plugins/google-analytics/GoogleAnalytics.ts +147 -0
  306. package/src/plugins/index.ts +42 -0
  307. package/src/plugins/kibo/index.ts +244 -0
  308. package/src/plugins/level-selector/LevelSelector.ts +400 -0
  309. package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +72 -0
  310. package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +11 -0
  311. package/src/plugins/logo/Logo.ts +233 -0
  312. package/src/plugins/logo/utils/index.ts +46 -0
  313. package/src/plugins/media-control/MediaControl.ts +1383 -0
  314. package/src/plugins/multi-camera/MultiCamera copy.xts +414 -0
  315. package/src/plugins/multi-camera/MultiCamera.ts +426 -0
  316. package/src/plugins/picture-in-picture/PictureInPicture.ts +87 -0
  317. package/src/plugins/playback-rate/PlaybackRate.ts +269 -0
  318. package/src/plugins/poster/Poster.ts +298 -0
  319. package/src/plugins/seek-time/SeekTime.ts +191 -0
  320. package/src/plugins/share/Share.ts +148 -0
  321. package/src/plugins/skip-time/SkipTime.ts +109 -0
  322. package/src/plugins/source-controller/SourceController.ts +239 -0
  323. package/src/plugins/source-controller/__tests__/SourceController.test.ts +230 -0
  324. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +135 -0
  325. package/src/plugins/statistics/Statistics copy.xts +296 -0
  326. package/src/plugins/statistics/Statistics.ts +207 -0
  327. package/src/plugins/subtitles/Subtitles.ts +505 -0
  328. package/src/plugins/thumbnails/Thumbnails.ts +530 -0
  329. package/src/plugins/types.ts +7 -0
  330. package/src/plugins/typings/globals.d.ts +10 -0
  331. package/src/plugins/typings/parse-srt.d.ts +14 -0
  332. package/src/plugins/typings/workers.d.ts +3 -0
  333. package/src/plugins/utils.ts +77 -0
  334. package/src/plugins/vast-ads/VastAds.ts +915 -0
  335. package/src/plugins/vast-ads/loaderxml.ts +260 -0
  336. package/src/plugins/vast-ads/roll.ts +492 -0
  337. package/src/plugins/vast-ads/rollmanager.ts +403 -0
  338. package/src/plugins/vast-ads/sctemanager.ts +134 -0
  339. package/src/plugins/vast-ads/types.ts +14 -0
  340. package/src/plugins/vast-ads/urlhandler.ts +37 -0
  341. package/src/plugins/vast-ads/xmlhttprequest.ts +44 -0
  342. package/src/plugins/vast-ads/xmlmerge.ts +96 -0
  343. package/src/plugins/video360/VRControls.js +104 -0
  344. package/src/plugins/video360/VREffect.js +422 -0
  345. package/src/plugins/video360/Video360.js +979 -0
  346. package/src/plugins/video360/orbit-oriention-controls.js +1002 -0
  347. package/src/plugins/video360/utils.js +49 -0
  348. package/src/plugins/volume-fade/VolumeFade.ts +109 -0
  349. package/tsconfig.tsbuildinfo +1 -1
@@ -1,68 +1,64 @@
1
1
  import { Events, template, UICorePlugin } from '@clappr/core';
2
- import assert from 'assert';
3
- import buttonHtml from '../../../assets/plugins/level-selector/button.ejs';
4
- import listHtml from '../../../assets/plugins/level-selector/list.ejs';
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/plugins/level-selector/style.scss';
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 AUTO = -1;
19
- const NO_LEVEL = {
20
- level: {
21
- bitrate: 0,
22
- // mediaType: 'video',
23
- width: 0,
24
- height: 0,
25
- // scanType: '',
26
- // qualityIndex: -1,
27
- },
28
- id: -1,
29
- };
30
- // type LevelInfo = {
31
- // id: number;
32
- // label: string;
33
- // }
34
- // const NO_LEVEL = {
35
- // id: -1,
36
- // label: 'Auto',
37
- // };
38
- export default class LevelSelector extends UICorePlugin {
39
- currentLevel = null;
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
- // static get version() {
50
- // return VERSION;
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
- 'class': this.name,
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
- const currentPlayback = this.core.activePlayback;
92
- this.listenTo(currentPlayback, Events.PLAYBACK_LEVELS_AVAILABLE, this.fillLevels);
93
- this.listenTo(currentPlayback, Events.PLAYBACK_LEVEL_SWITCH_START, this.startLevelSwitch);
94
- this.listenTo(currentPlayback, Events.PLAYBACK_LEVEL_SWITCH_END, this.stopLevelSwitch);
95
- this.listenTo(currentPlayback, Events.PLAYBACK_BITRATE, this.updateCurrentLevel);
96
- this.listenTo(currentPlayback, Events.PLAYBACK_STOP, this.onStop);
97
- const playbackLevelsAvailableWasTriggered = currentPlayback.levels && currentPlayback.levels.length > 0;
98
- playbackLevelsAvailableWasTriggered && this.fillLevels(currentPlayback.levels);
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.findLevelBy(this.selectedLevelId) || NO_LEVEL;
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 currentPlayback = this.core.activePlayback;
123
- if (!currentPlayback) {
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
- const hasLevels = !!(this.levels && this.levels.length > 1);
130
- return respondsToCurrentLevel && hasLevels;
126
+ return !!(this.levels && this.levels.length > 1);
131
127
  }
132
128
  render() {
133
- if (this.shouldRender()) {
134
- // this.$el.html(this.template({ 'levels': this.levels, 'title': this.getTitle() }));
135
- const t = template(buttonHtml);
136
- this.$el.html(t({
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
- arrowRightIcon,
140
- }));
141
- this.core.mediaControl.$el?.find('.gear-options-list [data-quality]').html(this.el);
142
- // this.highlightCurrentLevel();
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
- if (this.removeAuto) {
145
- this.core.mediaControl
146
- .$el
147
- .find('.gear-options-list [data-quality]')
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
- return this;
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, initialLevel = AUTO) {
155
- trace('${T} fillLevels', { levels, initialLevel });
156
- // Player.player.trigger('levels', levels);
157
- // this.core.trigger('levels', levels);
158
- // TODO fire directly on the plugin object
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
- // if (this.selectedLevelId === undefined) { // TODO compare with AUTO?
164
- // this.selectedLevelId = initialLevel;
165
- // }
166
- this.levels = levels;
167
- this.configureLevelsLabels();
168
- this.render();
185
+ this.deferRender();
169
186
  }
170
- configureLevelsLabels() {
171
- trace('${T} configureLevelsLabels', { options: this.core.options, levels: this.levels });
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
- if (labels) {
175
- for (let i = 0; i < this.levels.length; i++) {
176
- const level = this.levels[i];
177
- const ll = level.level.width > level.level.height ? level.level.height : level.level.width;
178
- const label = labels[ll] || `${ll}p`;
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.id === id);
198
+ return this.levels.find((level) => level.level === id);
186
199
  }
187
200
  onLevelSelect(event) {
188
- const selectedLevel = event.currentTarget?.dataset?.id;
189
- trace('${T} onLevelSelect', { selectedLevel });
190
- this.setIndexLevel(parseInt(event.currentTarget?.dataset?.id ?? "-1", 10));
191
- // this.toggleContextMenu();
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
- setIndexLevel(index) {
212
+ setLevel(index) {
213
+ trace(`${T} setIndexLevel`, { index });
199
214
  this.selectedLevelId = index;
200
- if (this.core.activePlayback) {
201
- this.core.activePlayback.trigger('playback:level:select:start');
215
+ if (!this.core.activePlayback) {
216
+ return;
202
217
  }
203
- if (this.core.activePlayback.currentLevel.id === this.selectedLevelId) {
204
- return false;
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
- const t = template(listHtml);
218
- this.$el.html(t({
219
- levels: this.levels,
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.level_selector || {}).title;
243
+ return (this.core.options.levelSelector || {}).title;
235
244
  }
236
- startLevelSwitch() {
237
- // Player.player.trigger('startLevelSwitch');
245
+ onLevelSwitchStart() {
246
+ this.core.activePlayback.trigger('playback:level:select:start');
238
247
  this.levelElement(this.selectedLevelId).addClass('changing');
239
248
  }
240
- stopLevelSwitch() {
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.id === id);
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] || formatLevelLabel(this.levels[index]);
267
+ return this.levelLabels[index] ?? formatLevelLabel(this.levels[index]);
264
268
  }
265
269
  updateCurrentLevel(info) {
266
- trace('${T} updateCurrentLevel', { info, levels: this.levels });
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('${T} highlightCurrentLevel', { currentLevel: this.currentLevel, selectedLevelId: this.selectedLevelId });
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
- if (this.currentLevel) {
277
- const currentLevelElement = this.levelElement(this.selectedLevelId);
278
- currentLevelElement.addClass('current');
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.level.width > level.level.height ? level.level.height : level.level.width;
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
+ }