@gcorevideo/player 2.18.3 → 2.19.1

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 (404) 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/{index-C02TmVOf.js → plugins/index.js/index.plugins.js} +29283 -29567
  115. package/lib/index.core.d.ts +15 -0
  116. package/lib/index.core.d.ts.map +1 -0
  117. package/lib/index.core.js +14 -0
  118. package/lib/index.d.ts +2 -14
  119. package/lib/index.d.ts.map +1 -1
  120. package/lib/index.js +2 -14
  121. package/lib/index.plugins.d.ts +37 -0
  122. package/lib/index.plugins.d.ts.map +1 -0
  123. package/lib/index.plugins.js +39 -0
  124. package/lib/plugins/audio-selector/AudioSelector.d.ts +3 -3
  125. package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
  126. package/lib/plugins/audio-selector/AudioSelector.js +6 -12
  127. package/lib/plugins/big-mute-button/BigMuteButton.d.ts +2 -2
  128. package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
  129. package/lib/plugins/big-mute-button/BigMuteButton.js +7 -12
  130. package/lib/plugins/bottom-gear/BottomGear.d.ts +4 -3
  131. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  132. package/lib/plugins/bottom-gear/BottomGear.js +11 -16
  133. package/lib/plugins/build.d.ts +2 -0
  134. package/lib/plugins/build.d.ts.map +1 -0
  135. package/lib/plugins/build.js +1 -0
  136. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +44 -0
  137. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -0
  138. package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +294 -0
  139. package/lib/plugins/clappr-nerd-stats/formatter.d.ts +8 -0
  140. package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -0
  141. package/lib/plugins/clappr-nerd-stats/formatter.js +91 -0
  142. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts +54 -0
  143. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -0
  144. package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +335 -0
  145. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +9 -0
  146. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -0
  147. package/lib/plugins/clappr-nerd-stats/speedtest/index.js +154 -0
  148. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +6 -0
  149. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -0
  150. package/lib/plugins/clappr-nerd-stats/types.d.ts +4 -0
  151. package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -0
  152. package/lib/plugins/clappr-stats/ClapprStats.d.ts +56 -0
  153. package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -0
  154. package/lib/plugins/clappr-stats/ClapprStats.js +332 -0
  155. package/lib/plugins/clappr-stats/types.d.ts +50 -0
  156. package/lib/plugins/clappr-stats/types.d.ts.map +1 -0
  157. package/lib/plugins/clappr-stats/types.js +5 -0
  158. package/lib/plugins/clappr-stats/utils.d.ts +3 -0
  159. package/lib/plugins/clappr-stats/utils.d.ts.map +1 -0
  160. package/lib/plugins/clappr-stats/utils.js +40 -0
  161. package/lib/plugins/click-to-pause/ClickToPause.d.ts +2 -2
  162. package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
  163. package/lib/plugins/click-to-pause/ClickToPause.js +4 -6
  164. package/lib/plugins/clips/Clips.d.ts +23 -0
  165. package/lib/plugins/clips/Clips.d.ts.map +1 -0
  166. package/lib/plugins/clips/Clips.js +109 -0
  167. package/lib/plugins/context-menu/ContextMenu.d.ts +36 -0
  168. package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -0
  169. package/lib/plugins/context-menu/ContextMenu.js +102 -0
  170. package/lib/plugins/disable-controls/DisableControls.d.ts +1 -1
  171. package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -1
  172. package/lib/plugins/disable-controls/DisableControls.js +3 -5
  173. package/lib/plugins/dvr-controls/{DVRControls.d.ts → DvrControls.d.ts} +4 -4
  174. package/lib/plugins/dvr-controls/DvrControls.d.ts.map +1 -0
  175. package/lib/plugins/dvr-controls/{DVRControls.js → DvrControls.js} +5 -4
  176. package/lib/plugins/error-screen/ErrorScreen.d.ts +44 -0
  177. package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -0
  178. package/lib/plugins/error-screen/ErrorScreen.js +179 -0
  179. package/lib/plugins/favicon/Favicon.d.ts +24 -0
  180. package/lib/plugins/favicon/Favicon.d.ts.map +1 -0
  181. package/lib/plugins/favicon/Favicon.js +106 -0
  182. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +30 -0
  183. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -0
  184. package/lib/plugins/google-analytics/GoogleAnalytics.js +114 -0
  185. package/lib/plugins/index.d.ts +38 -0
  186. package/lib/plugins/index.d.ts.map +1 -0
  187. package/lib/plugins/index.js +40 -0
  188. package/lib/plugins/kibo/index.d.ts +23 -0
  189. package/lib/plugins/kibo/index.d.ts.map +1 -0
  190. package/lib/plugins/kibo/index.js +199 -0
  191. package/lib/plugins/level-selector/LevelSelector.d.ts +48 -17
  192. package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
  193. package/lib/plugins/level-selector/LevelSelector.js +169 -155
  194. package/lib/plugins/logo/Logo.d.ts +29 -0
  195. package/lib/plugins/logo/Logo.d.ts.map +1 -0
  196. package/lib/plugins/logo/Logo.js +181 -0
  197. package/lib/plugins/logo/utils/index.d.ts +22 -0
  198. package/lib/plugins/logo/utils/index.d.ts.map +1 -0
  199. package/lib/plugins/logo/utils/index.js +32 -0
  200. package/lib/plugins/media-control/MediaControl.d.ts +20 -25
  201. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  202. package/lib/plugins/media-control/MediaControl.js +136 -106
  203. package/lib/plugins/multi-camera/MultiCamera.d.ts +59 -0
  204. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -0
  205. package/lib/plugins/multi-camera/MultiCamera.js +353 -0
  206. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +20 -0
  207. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -0
  208. package/lib/plugins/picture-in-picture/PictureInPicture.js +68 -0
  209. package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -0
  210. package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -0
  211. package/lib/plugins/playback-rate/PlaybackRate.js +205 -0
  212. package/lib/plugins/poster/Poster.d.ts +18 -17
  213. package/lib/plugins/poster/Poster.d.ts.map +1 -1
  214. package/lib/plugins/poster/Poster.js +83 -37
  215. package/lib/plugins/seek-time/SeekTime.d.ts +38 -0
  216. package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -0
  217. package/lib/plugins/seek-time/SeekTime.js +153 -0
  218. package/lib/plugins/share/Share.d.ts +38 -0
  219. package/lib/plugins/share/Share.d.ts.map +1 -0
  220. package/lib/plugins/share/Share.js +122 -0
  221. package/lib/plugins/skip-time/SkipTime.d.ts +28 -0
  222. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -0
  223. package/lib/plugins/skip-time/SkipTime.js +86 -0
  224. package/lib/plugins/source-controller/SourceController.d.ts +41 -0
  225. package/lib/plugins/source-controller/SourceController.d.ts.map +1 -0
  226. package/lib/plugins/source-controller/SourceController.js +199 -0
  227. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +26 -0
  228. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -0
  229. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +117 -0
  230. package/lib/plugins/statistics/Statistics.d.ts +52 -0
  231. package/lib/plugins/statistics/Statistics.d.ts.map +1 -0
  232. package/lib/plugins/statistics/Statistics.js +130 -0
  233. package/lib/plugins/subtitles/Subtitles.d.ts +61 -0
  234. package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -0
  235. package/lib/plugins/subtitles/Subtitles.js +354 -0
  236. package/lib/plugins/thumbnails/Thumbnails.d.ts +47 -0
  237. package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -0
  238. package/lib/plugins/thumbnails/Thumbnails.js +414 -0
  239. package/lib/plugins/types.d.ts +8 -0
  240. package/lib/plugins/types.d.ts.map +1 -0
  241. package/lib/plugins/types.js +1 -0
  242. package/lib/plugins/utils.d.ts +5 -0
  243. package/lib/plugins/utils.d.ts.map +1 -0
  244. package/lib/plugins/utils.js +68 -0
  245. package/lib/plugins/vast-ads/VastAds.d.ts +72 -0
  246. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -0
  247. package/lib/plugins/vast-ads/VastAds.js +686 -0
  248. package/lib/plugins/vast-ads/loaderxml.d.ts +32 -0
  249. package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -0
  250. package/lib/plugins/vast-ads/loaderxml.js +226 -0
  251. package/lib/plugins/vast-ads/roll.d.ts +60 -0
  252. package/lib/plugins/vast-ads/roll.d.ts.map +1 -0
  253. package/lib/plugins/vast-ads/roll.js +415 -0
  254. package/lib/plugins/vast-ads/rollmanager.d.ts +62 -0
  255. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -0
  256. package/lib/plugins/vast-ads/rollmanager.js +347 -0
  257. package/lib/plugins/vast-ads/sctemanager.d.ts +18 -0
  258. package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -0
  259. package/lib/plugins/vast-ads/sctemanager.js +116 -0
  260. package/lib/plugins/vast-ads/types.d.ts +12 -0
  261. package/lib/plugins/vast-ads/types.d.ts.map +1 -0
  262. package/lib/plugins/vast-ads/types.js +1 -0
  263. package/lib/plugins/vast-ads/urlhandler.d.ts +4 -0
  264. package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -0
  265. package/lib/plugins/vast-ads/urlhandler.js +30 -0
  266. package/lib/plugins/vast-ads/xmlhttprequest.d.ts +6 -0
  267. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -0
  268. package/lib/plugins/vast-ads/xmlhttprequest.js +39 -0
  269. package/lib/plugins/vast-ads/xmlmerge.d.ts +12 -0
  270. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -0
  271. package/lib/plugins/vast-ads/xmlmerge.js +82 -0
  272. package/lib/plugins/volume-fade/VolumeFade.d.ts +21 -0
  273. package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -0
  274. package/lib/plugins/volume-fade/VolumeFade.js +90 -0
  275. package/package.json +10 -2
  276. package/rollup.config.js +32 -2
  277. package/src/index.core.ts +15 -0
  278. package/src/index.plugins.ts +41 -0
  279. package/src/index.ts +2 -15
  280. package/src/plugins/audio-selector/AudioSelector.ts +370 -0
  281. package/src/plugins/big-mute-button/BigMuteButton.ts +187 -0
  282. package/src/plugins/bottom-gear/BottomGear.ts +122 -0
  283. package/src/plugins/build.ts +1 -0
  284. package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +369 -0
  285. package/src/plugins/clappr-nerd-stats/formatter.ts +109 -0
  286. package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +414 -0
  287. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +183 -0
  288. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +5 -0
  289. package/src/plugins/clappr-nerd-stats/types.ts +3 -0
  290. package/src/plugins/clappr-stats/ClapprStats.ts +441 -0
  291. package/src/plugins/clappr-stats/types.ts +52 -0
  292. package/src/plugins/clappr-stats/utils.ts +42 -0
  293. package/src/plugins/click-to-pause/ClickToPause.ts +93 -0
  294. package/src/plugins/clips/Clips.ts +152 -0
  295. package/src/plugins/context-menu/ContextMenu.ts +134 -0
  296. package/src/plugins/disable-controls/DisableControls.ts +81 -0
  297. package/src/plugins/dvr-controls/DvrControls.ts +131 -0
  298. package/src/plugins/error-screen/ErrorScreen.ts +241 -0
  299. package/src/plugins/favicon/Favicon.ts +137 -0
  300. package/src/plugins/ga-events/GaEvents.js +395 -0
  301. package/src/plugins/ga-events/ga-tracking.js +46 -0
  302. package/src/plugins/google-analytics/GoogleAnalytics.ts +147 -0
  303. package/src/plugins/index.ts +42 -0
  304. package/src/plugins/kibo/index.ts +244 -0
  305. package/src/plugins/level-selector/LevelSelector.ts +400 -0
  306. package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +72 -0
  307. package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +11 -0
  308. package/src/plugins/logo/Logo.ts +233 -0
  309. package/src/plugins/logo/utils/index.ts +46 -0
  310. package/src/plugins/media-control/MediaControl.ts +1383 -0
  311. package/src/plugins/multi-camera/MultiCamera copy.xts +414 -0
  312. package/src/plugins/multi-camera/MultiCamera.ts +426 -0
  313. package/src/plugins/picture-in-picture/PictureInPicture.ts +87 -0
  314. package/src/plugins/playback-rate/PlaybackRate.ts +269 -0
  315. package/src/plugins/poster/Poster.ts +298 -0
  316. package/src/plugins/seek-time/SeekTime.ts +191 -0
  317. package/src/plugins/share/Share.ts +148 -0
  318. package/src/plugins/skip-time/SkipTime.ts +109 -0
  319. package/src/plugins/source-controller/SourceController.ts +239 -0
  320. package/src/plugins/source-controller/__tests__/SourceController.test.ts +230 -0
  321. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +135 -0
  322. package/src/plugins/statistics/Statistics copy.xts +296 -0
  323. package/src/plugins/statistics/Statistics.ts +207 -0
  324. package/src/plugins/subtitles/Subtitles.ts +505 -0
  325. package/src/plugins/thumbnails/Thumbnails.ts +530 -0
  326. package/src/plugins/types.ts +7 -0
  327. package/src/plugins/typings/globals.d.ts +10 -0
  328. package/src/plugins/typings/parse-srt.d.ts +14 -0
  329. package/src/plugins/typings/workers.d.ts +3 -0
  330. package/src/plugins/utils.ts +77 -0
  331. package/src/plugins/vast-ads/VastAds.ts +915 -0
  332. package/src/plugins/vast-ads/loaderxml.ts +260 -0
  333. package/src/plugins/vast-ads/roll.ts +492 -0
  334. package/src/plugins/vast-ads/rollmanager.ts +403 -0
  335. package/src/plugins/vast-ads/sctemanager.ts +134 -0
  336. package/src/plugins/vast-ads/types.ts +14 -0
  337. package/src/plugins/vast-ads/urlhandler.ts +37 -0
  338. package/src/plugins/vast-ads/xmlhttprequest.ts +44 -0
  339. package/src/plugins/vast-ads/xmlmerge.ts +96 -0
  340. package/src/plugins/video360/VRControls.js +104 -0
  341. package/src/plugins/video360/VREffect.js +422 -0
  342. package/src/plugins/video360/Video360.js +979 -0
  343. package/src/plugins/video360/orbit-oriention-controls.js +1002 -0
  344. package/src/plugins/video360/utils.js +49 -0
  345. package/src/plugins/volume-fade/VolumeFade.ts +109 -0
  346. package/tsconfig.tsbuildinfo +1 -1
  347. package/dist/HlsPlayback-D9EmONbV.js +0 -747
  348. package/dist/player.d.ts +0 -646
  349. package/lib/backend.d.ts +0 -3
  350. package/lib/backend.d.ts.map +0 -1
  351. package/lib/backend.js +0 -10
  352. package/lib/constants.d.ts +0 -1
  353. package/lib/constants.d.ts.map +0 -1
  354. package/lib/constants.js +0 -1
  355. package/lib/gcore.types.d.ts +0 -84
  356. package/lib/gcore.types.d.ts.map +0 -1
  357. package/lib/gcore.types.js +0 -9
  358. package/lib/plugins/dash-playback/DashPlayback.d.ts +0 -73
  359. package/lib/plugins/dash-playback/DashPlayback.d.ts.map +0 -1
  360. package/lib/plugins/dash-playback/DashPlayback.js +0 -455
  361. package/lib/plugins/dash-playback/types.d.ts +0 -6
  362. package/lib/plugins/dash-playback/types.d.ts.map +0 -1
  363. package/lib/plugins/dash-plugin/DashPlayback.d.ts +0 -86
  364. package/lib/plugins/dash-plugin/DashPlayback.d.ts.map +0 -1
  365. package/lib/plugins/dash-plugin/DashPlayback.js +0 -659
  366. package/lib/plugins/dvr-controls/DVRControls.d.ts.map +0 -1
  367. package/lib/plugins/hls-playback/HlsPlayback.d.ts +0 -102
  368. package/lib/plugins/hls-playback/HlsPlayback.d.ts.map +0 -1
  369. package/lib/plugins/hls-playback/HlsPlayback.js +0 -815
  370. package/lib/trace/LogTracer.d.ts +0 -12
  371. package/lib/trace/LogTracer.d.ts.map +0 -1
  372. package/lib/trace/LogTracer.js +0 -17
  373. package/lib/trace/SentryTracer.d.ts +0 -12
  374. package/lib/trace/SentryTracer.d.ts.map +0 -1
  375. package/lib/trace/SentryTracer.js +0 -23
  376. package/lib/trace/Tracer.d.ts +0 -13
  377. package/lib/trace/Tracer.d.ts.map +0 -1
  378. package/lib/trace/Tracer.js +0 -15
  379. package/lib/trace/index.d.ts +0 -18
  380. package/lib/trace/index.d.ts.map +0 -1
  381. package/lib/trace/index.js +0 -27
  382. package/lib/trace/types.d.ts +0 -8
  383. package/lib/trace/types.d.ts.map +0 -1
  384. package/lib/tsdoc-metadata.json +0 -11
  385. package/lib/utils/Logger.d.ts +0 -23
  386. package/lib/utils/Logger.d.ts.map +0 -1
  387. package/lib/utils/Logger.js +0 -81
  388. package/lib/utils/canAutoplay.d.ts +0 -6
  389. package/lib/utils/canAutoplay.d.ts.map +0 -1
  390. package/lib/utils/canAutoplay.js +0 -30
  391. package/lib/utils/queryParams.d.ts +0 -2
  392. package/lib/utils/queryParams.d.ts.map +0 -1
  393. package/lib/utils/queryParams.js +0 -4
  394. package/lib/utils/scripts-load.d.ts +0 -2
  395. package/lib/utils/scripts-load.d.ts.map +0 -1
  396. package/lib/utils/scripts-load.js +0 -20
  397. package/lib/utils/testUtils.d.ts +0 -3
  398. package/lib/utils/testUtils.d.ts.map +0 -1
  399. package/lib/utils/testUtils.js +0 -12
  400. package/lib/utils/utils.d.ts +0 -3
  401. package/lib/utils/utils.d.ts.map +0 -1
  402. package/lib/utils/utils.js +0 -31
  403. /package/lib/plugins/{dash-playback → clappr-nerd-stats/speedtest}/types.js +0 -0
  404. /package/lib/{trace → plugins/clappr-nerd-stats}/types.js +0 -0
@@ -1,815 +0,0 @@
1
- // Copyright 2014 Globo.com Player authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
- import { Events, HTML5Video, Log, Playback, PlayerError, Utils, } from '@clappr/core';
5
- import { trace } from '@gcorevideo/utils';
6
- import assert from 'assert';
7
- import HLSJS from 'hls.js';
8
- import { PlaybackErrorCode } from '../../playback.types.js';
9
- import { CLAPPR_VERSION } from '../../build.js';
10
- const { now, listContainsIgnoreCase } = Utils;
11
- const AUTO = -1;
12
- const DEFAULT_RECOVER_ATTEMPTS = 16;
13
- Events.register('PLAYBACK_FRAGMENT_CHANGED');
14
- Events.register('PLAYBACK_FRAGMENT_PARSING_METADATA');
15
- const T = 'playback.hls';
16
- // @ts-expect-error
17
- export default class HlsPlayback extends HTML5Video {
18
- _ccIsSetup = false;
19
- _ccTracksUpdated = false;
20
- _currentFragment = null;
21
- _currentLevel = null;
22
- _durationExcludesAfterLiveSyncPoint = false;
23
- _extrapolatedWindowNumSegments = 0; // TODO
24
- highDefinition = false;
25
- _hls = null;
26
- _isReadyState = false;
27
- _lastDuration = null;
28
- _lastTimeUpdate = null;
29
- _levels = null;
30
- _localStartTimeCorrelation = null;
31
- _localEndTimeCorrelation = null;
32
- _manifestParsed = false;
33
- _playableRegionDuration = 0;
34
- _playbackType = Playback.VOD;
35
- _playlistType = null;
36
- _playableRegionStartTime = 0;
37
- _programDateTime = null;
38
- _recoverAttemptsRemaining = 0;
39
- _recoveredAudioCodecError = false;
40
- _recoveredDecodingError = false;
41
- _segmentTargetDuration = null;
42
- _timeUpdateTimer = null;
43
- get name() {
44
- return 'hls';
45
- }
46
- get supportedVersion() {
47
- return { min: CLAPPR_VERSION };
48
- }
49
- get levels() {
50
- return this._levels || [];
51
- }
52
- get currentLevel() {
53
- return this._currentLevel ?? AUTO;
54
- }
55
- get isReady() {
56
- return this._isReadyState;
57
- }
58
- set currentLevel(id) {
59
- this._currentLevel = id;
60
- this.trigger(Events.PLAYBACK_LEVEL_SWITCH_START);
61
- assert.ok(this._hls, 'Hls.js instance is not available');
62
- if (this.options.playback.hlsUseNextLevel) {
63
- this._hls.nextLevel = this._currentLevel;
64
- }
65
- else {
66
- this._hls.currentLevel = this._currentLevel;
67
- }
68
- }
69
- get latency() {
70
- assert.ok(this._hls, 'Hls.js instance is not available');
71
- return this._hls.latency;
72
- }
73
- get currentProgramDateTime() {
74
- assert.ok(this._hls, 'Hls.js instance is not available');
75
- assert.ok(this._hls.playingDate, 'Hls.js playingDate is not defined');
76
- return this._hls.playingDate;
77
- }
78
- get _startTime() {
79
- if (this._playbackType === Playback.LIVE &&
80
- this._playlistType !== 'EVENT') {
81
- return this._extrapolatedStartTime;
82
- }
83
- return this._playableRegionStartTime;
84
- }
85
- get _now() {
86
- return now();
87
- }
88
- // the time in the video element which should represent the start of the sliding window
89
- // extrapolated to increase in real time (instead of jumping as the early segments are removed)
90
- get _extrapolatedStartTime() {
91
- if (!this._localStartTimeCorrelation) {
92
- return this._playableRegionStartTime;
93
- }
94
- const corr = this._localStartTimeCorrelation;
95
- const timePassed = this._now - corr.local;
96
- const extrapolatedWindowStartTime = (corr.remote + timePassed) / 1000;
97
- // cap at the end of the extrapolated window duration
98
- return Math.min(extrapolatedWindowStartTime, this._playableRegionStartTime + this._extrapolatedWindowDuration);
99
- }
100
- // the time in the video element which should represent the end of the content
101
- // extrapolated to increase in real time (instead of jumping as segments are added)
102
- get _extrapolatedEndTime() {
103
- const actualEndTime = this._playableRegionStartTime + this._playableRegionDuration;
104
- if (!this._localEndTimeCorrelation) {
105
- return actualEndTime;
106
- }
107
- const correlation = this._localEndTimeCorrelation;
108
- const timePassed = this._now - correlation.local;
109
- const extrapolatedEndTime = (correlation.remote + timePassed) / 1000;
110
- return Math.max(actualEndTime - this._extrapolatedWindowDuration, Math.min(extrapolatedEndTime, actualEndTime));
111
- }
112
- get _duration() {
113
- return this._extrapolatedEndTime - this._startTime;
114
- }
115
- // Returns the duration (seconds) of the window that the extrapolated start time is allowed
116
- // to move in before being capped.
117
- // The extrapolated start time should never reach the cap at the end of the window as the
118
- // window should slide as chunks are removed from the start.
119
- // This also applies to the extrapolated end time in the same way.
120
- //
121
- // If chunks aren't being removed for some reason that the start time will reach and remain fixed at
122
- // playableRegionStartTime + extrapolatedWindowDuration
123
- //
124
- // <-- window duration -->
125
- // I.e playableRegionStartTime |-----------------------|
126
- // | --> . . .
127
- // . --> | --> . .
128
- // . . --> | --> .
129
- // . . . --> |
130
- // . . . .
131
- // extrapolatedStartTime
132
- get _extrapolatedWindowDuration() {
133
- if (this._segmentTargetDuration === null) {
134
- return 0;
135
- }
136
- return this._extrapolatedWindowNumSegments * this._segmentTargetDuration;
137
- }
138
- get bandwidthEstimate() {
139
- return this._hls && this._hls.bandwidthEstimate;
140
- }
141
- get defaultOptions() {
142
- return { preload: true };
143
- }
144
- get customListeners() {
145
- return ((this.options.hlsPlayback && this.options.hlsPlayback.customListeners) ||
146
- []);
147
- }
148
- get sourceMedia() {
149
- return this.options.src;
150
- }
151
- get currentTimestamp() {
152
- if (!this._currentFragment) {
153
- return null;
154
- }
155
- assert(this._currentFragment.programDateTime !== null, 'Hls.js programDateTime is not defined');
156
- const startTime = this._currentFragment.programDateTime;
157
- const playbackTime = this.el.currentTime;
158
- const playTimeOffSet = playbackTime - this._currentFragment.start;
159
- const currentTimestampInMs = startTime + playTimeOffSet * 1000;
160
- return currentTimestampInMs / 1000;
161
- }
162
- static get HLSJS() {
163
- return HLSJS;
164
- }
165
- constructor(...args) {
166
- // @ts-ignore
167
- super(...args);
168
- this.options.hlsPlayback = {
169
- ...this.defaultOptions,
170
- ...this.options.hlsPlayback,
171
- };
172
- this._setInitialState();
173
- }
174
- _setInitialState() {
175
- // @ts-ignore
176
- this._minDvrSize =
177
- typeof this.options.hlsMinimumDvrSize === 'undefined'
178
- ? 60
179
- : this.options.hlsMinimumDvrSize;
180
- // The size of the start time extrapolation window measured as a multiple of segments.
181
- // Should be 2 or higher, or 0 to disable. Should only need to be increased above 2 if more than one segment is
182
- // removed from the start of the playlist at a time. E.g if the playlist is cached for 10 seconds and new chunks are
183
- // added/removed every 5.
184
- this._extrapolatedWindowNumSegments =
185
- !this.options.playback ||
186
- typeof this.options.playback.extrapolatedWindowNumSegments === 'undefined'
187
- ? 2
188
- : this.options.playback.extrapolatedWindowNumSegments;
189
- this._playbackType = Playback.VOD;
190
- this._lastTimeUpdate = { current: 0, total: 0 };
191
- this._lastDuration = null;
192
- // for hls streams which have dvr with a sliding window,
193
- // the content at the start of the playlist is removed as new
194
- // content is appended at the end.
195
- // this means the actual playable start time will increase as the
196
- // start content is deleted
197
- // For streams with dvr where the entire recording is kept from the
198
- // beginning this should stay as 0
199
- this._playableRegionStartTime = 0;
200
- // {local, remote} remote is the time in the video element that should represent 0
201
- // local is the system time when the 'remote' measurment took place
202
- this._localStartTimeCorrelation = null;
203
- // {local, remote} remote is the time in the video element that should represents the end
204
- // local is the system time when the 'remote' measurment took place
205
- this._localEndTimeCorrelation = null;
206
- // if content is removed from the beginning then this empty area should
207
- // be ignored. "playableRegionDuration" excludes the empty area
208
- this._playableRegionDuration = 0;
209
- // #EXT-X-PROGRAM-DATE-TIME
210
- this._programDateTime = null;
211
- // true when the actual duration is longer than hlsjs's live sync point
212
- // when this is false playableRegionDuration will be the actual duration
213
- // when this is true playableRegionDuration will exclude the time after the sync point
214
- this._durationExcludesAfterLiveSyncPoint = false;
215
- // #EXT-X-TARGETDURATION
216
- this._segmentTargetDuration = null;
217
- // #EXT-X-PLAYLIST-TYPE
218
- this._playlistType = null;
219
- // TODO options.hlsRecoverAttempts
220
- this._recoverAttemptsRemaining =
221
- this.options.hlsRecoverAttempts || DEFAULT_RECOVER_ATTEMPTS;
222
- }
223
- _setup() {
224
- this._destroyHLSInstance();
225
- this._createHLSInstance();
226
- this._listenHLSEvents();
227
- this._attachHLSMedia();
228
- }
229
- _destroyHLSInstance() {
230
- if (!this._hls) {
231
- return;
232
- }
233
- this._manifestParsed = false;
234
- this._ccIsSetup = false;
235
- this._ccTracksUpdated = false;
236
- this._setInitialState();
237
- this._hls.destroy();
238
- this._hls = null;
239
- }
240
- _createHLSInstance() {
241
- const config = {
242
- ...this.options.playback.hlsjsConfig,
243
- maxBufferLength: 2,
244
- maxMaxBufferLength: 4,
245
- };
246
- this._hls = new HLSJS(config);
247
- }
248
- _attachHLSMedia() {
249
- if (!this._hls) {
250
- return;
251
- }
252
- this._hls.attachMedia(this.el);
253
- }
254
- _listenHLSEvents() {
255
- if (!this._hls) {
256
- return;
257
- }
258
- this._hls.once(HLSJS.Events.MEDIA_ATTACHED, () => {
259
- assert.ok(this._hls, 'Hls.js instance is not available');
260
- this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src);
261
- });
262
- const onPlaying = () => {
263
- if (this._hls) {
264
- this._hls.config.maxBufferLength =
265
- this.options.hlsPlayback.maxBufferLength || 30;
266
- this._hls.config.maxMaxBufferLength =
267
- this.options.hlsPlayback.maxMaxBufferLength || 60;
268
- }
269
- this.el.removeEventListener('playing', onPlaying);
270
- };
271
- this.el.addEventListener('playing', onPlaying);
272
- this._hls.on(HLSJS.Events.MANIFEST_PARSED, () => (this._manifestParsed = true));
273
- this._hls.on(HLSJS.Events.LEVEL_LOADED, (evt, data) => this._updatePlaybackType(evt, data));
274
- this._hls.on(HLSJS.Events.LEVEL_UPDATED, (evt, data) => this._onLevelUpdated(evt, data));
275
- this._hls.on(HLSJS.Events.LEVEL_SWITCHING, (evt, data) => this._onLevelSwitch(evt, data));
276
- this._hls.on(HLSJS.Events.FRAG_CHANGED, (evt, data) => this._onFragmentChanged(evt, data));
277
- this._hls.on(HLSJS.Events.FRAG_LOADED, (evt, data) => this._onFragmentLoaded(evt, data));
278
- this._hls.on(HLSJS.Events.FRAG_PARSING_METADATA, (evt, data) => this._onFragmentParsingMetadata(evt, data));
279
- this._hls.on(HLSJS.Events.ERROR, (evt, data) => this._onHLSJSError(evt, data));
280
- // this._hls.on(HLSJS.Events.SUBTITLE_TRACK_LOADED, (evt, data) => this._onSubtitleLoaded(evt, data));
281
- this._hls.on(HLSJS.Events.SUBTITLE_TRACK_LOADED, () => this._onSubtitleLoaded());
282
- this._hls.on(HLSJS.Events.SUBTITLE_TRACKS_UPDATED, () => (this._ccTracksUpdated = true));
283
- this.bindCustomListeners();
284
- }
285
- bindCustomListeners() {
286
- this.customListeners.forEach((item) => {
287
- const requestedEventName = item.eventName;
288
- const typeOfListener = item.once ? 'once' : 'on';
289
- assert.ok(this._hls, 'Hls.js instance is not available');
290
- requestedEventName &&
291
- this._hls[`${typeOfListener}`](requestedEventName, item.callback);
292
- });
293
- }
294
- unbindCustomListeners() {
295
- this.customListeners.forEach((item) => {
296
- const requestedEventName = item.eventName;
297
- assert.ok(this._hls, 'Hls.js instance is not available');
298
- requestedEventName && this._hls.off(requestedEventName, item.callback);
299
- });
300
- }
301
- _onFragmentParsingMetadata(evt, data) {
302
- // @ts-ignore
303
- this.trigger(Events.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA, {
304
- evt,
305
- data,
306
- });
307
- }
308
- render() {
309
- this._ready();
310
- return super.render();
311
- }
312
- _ready() {
313
- if (this._isReadyState) {
314
- return;
315
- }
316
- !this._hls && this._setup();
317
- this._isReadyState = true;
318
- this.trigger(Events.PLAYBACK_READY, this.name);
319
- }
320
- _recover(evt, data, error) {
321
- assert(this._hls, 'Hls.js instance is not available');
322
- if (!this._recoveredDecodingError) {
323
- this._recoveredDecodingError = true;
324
- this._hls.recoverMediaError();
325
- }
326
- else if (!this._recoveredAudioCodecError) {
327
- this._recoveredAudioCodecError = true;
328
- this._hls.swapAudioCodec();
329
- this._hls.recoverMediaError();
330
- }
331
- else {
332
- Log.error('hlsjs: failed to recover', { evt, data });
333
- error.level = PlayerError.Levels.FATAL;
334
- this.triggerError(error);
335
- }
336
- }
337
- // this playback manages the src on the video element itself
338
- _setupSrc(srcUrl) { } // eslint-disable-line no-unused-vars
339
- _startTimeUpdateTimer() {
340
- if (this._timeUpdateTimer) {
341
- return;
342
- }
343
- this._timeUpdateTimer = setInterval(() => {
344
- this._onDurationChange();
345
- this._onTimeUpdate();
346
- }, 100);
347
- }
348
- _stopTimeUpdateTimer() {
349
- if (!this._timeUpdateTimer) {
350
- return;
351
- }
352
- clearInterval(this._timeUpdateTimer);
353
- this._timeUpdateTimer = null;
354
- }
355
- getProgramDateTime() {
356
- return this._programDateTime ?? 0;
357
- }
358
- // the duration on the video element itself should not be used
359
- // as this does not necesarily represent the duration of the stream
360
- // https://github.com/clappr/clappr/issues/668#issuecomment-157036678
361
- getDuration() {
362
- return this._duration;
363
- }
364
- getCurrentTime() {
365
- // e.g. can be < 0 if user pauses near the start
366
- // eventually they will then be kicked to the end by hlsjs if they run out of buffer
367
- // before the official start time
368
- return Math.max(0, this.el.currentTime - this._startTime);
369
- }
370
- // the time that "0" now represents relative to when playback started
371
- // for a stream with a sliding window this will increase as content is
372
- // removed from the beginning
373
- getStartTimeOffset() {
374
- return this._startTime;
375
- }
376
- seekPercentage(percentage) {
377
- const seekTo = percentage > 0 ? this._duration * (percentage / 100) : this._duration;
378
- this.seek(seekTo);
379
- }
380
- seek(time) {
381
- if (time < 0) {
382
- Log.warn('Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point.');
383
- time = this.getDuration();
384
- }
385
- // assume live if time within 3 seconds of end of stream
386
- this.dvrEnabled && this._updateDvr(time < this.getDuration() - 3);
387
- time += this._startTime;
388
- this.el.currentTime = time;
389
- }
390
- seekToLivePoint() {
391
- this.seek(this.getDuration());
392
- }
393
- _updateDvr(status) {
394
- this.trigger(Events.PLAYBACK_DVR, status);
395
- this.trigger(Events.PLAYBACK_STATS_ADD, { dvr: status });
396
- }
397
- _updateSettings() {
398
- if (this._playbackType === Playback.VOD) {
399
- // @ts-expect-error
400
- this.settings.left = ['playpause', 'position', 'duration'];
401
- }
402
- else if (this.dvrEnabled) {
403
- // @ts-expect-error
404
- this.settings.left = ['playpause'];
405
- }
406
- else {
407
- // @ts-expect-error
408
- this.settings.left = ['playstop'];
409
- }
410
- // @ts-expect-error
411
- this.settings.seekEnabled = this.isSeekEnabled();
412
- this.trigger(Events.PLAYBACK_SETTINGSUPDATE);
413
- }
414
- _onHLSJSError(evt, data) {
415
- const error = {
416
- code: PlaybackErrorCode.Generic,
417
- description: `${this.name} error: type: ${data.type}, details: ${data.details} fatal: ${data.fatal}`,
418
- level: data.fatal ? PlayerError.Levels.FATAL : PlayerError.Levels.WARN,
419
- message: `${this.name} error: type: ${data.type}, details: ${data.details}`,
420
- };
421
- if (data.response) {
422
- error.description += `, response: ${JSON.stringify(data.response)}`;
423
- }
424
- // only report/handle errors if they are fatal
425
- // hlsjs should automatically handle non fatal errors
426
- if (data.fatal) {
427
- if (this._recoverAttemptsRemaining > 0) {
428
- this._recoverAttemptsRemaining -= 1;
429
- switch (data.type) {
430
- case HLSJS.ErrorTypes.NETWORK_ERROR:
431
- switch (data.details) {
432
- // The following network errors cannot be recovered with HLS.startLoad()
433
- // For more details, see https://github.com/video-dev/hls.js/blob/master/doc/design.md#error-detection-and-handling
434
- // For "level load" fatal errors, see https://github.com/video-dev/hls.js/issues/1138
435
- case HLSJS.ErrorDetails.MANIFEST_LOAD_ERROR:
436
- case HLSJS.ErrorDetails.MANIFEST_LOAD_TIMEOUT:
437
- case HLSJS.ErrorDetails.MANIFEST_PARSING_ERROR:
438
- case HLSJS.ErrorDetails.LEVEL_LOAD_ERROR:
439
- case HLSJS.ErrorDetails.LEVEL_LOAD_TIMEOUT:
440
- Log.error('hlsjs: unrecoverable network fatal error.', {
441
- evt,
442
- data,
443
- });
444
- error.code = PlaybackErrorCode.MediaSourceUnavailable;
445
- this.triggerError(error);
446
- break;
447
- default:
448
- Log.warn('hlsjs: trying to recover from network error.', {
449
- evt,
450
- data,
451
- });
452
- error.level = PlayerError.Levels.WARN;
453
- this._hls?.startLoad();
454
- break;
455
- }
456
- break;
457
- case HLSJS.ErrorTypes.MEDIA_ERROR:
458
- Log.warn('hlsjs: trying to recover from media error.', {
459
- evt,
460
- data,
461
- });
462
- error.level = PlayerError.Levels.WARN;
463
- this._recover(evt, data, error);
464
- break;
465
- default:
466
- Log.error('hlsjs: could not recover from error.', { evt, data });
467
- this.triggerError(error);
468
- break;
469
- }
470
- }
471
- else {
472
- Log.error('hlsjs: could not recover from error after maximum number of attempts.', { evt, data });
473
- // TODO
474
- this.triggerError(error);
475
- }
476
- }
477
- else {
478
- // Transforms HLSJS.ErrorDetails.KEY_LOAD_ERROR non-fatal error to
479
- // playback fatal error if triggerFatalErrorOnResourceDenied playback
480
- // option is set. HLSJS.ErrorTypes.KEY_SYSTEM_ERROR are fatal errors
481
- // and therefore already handled.
482
- if (this.options.playback.triggerFatalErrorOnResourceDenied &&
483
- this._keyIsDenied(data)) {
484
- Log.error('hlsjs: could not load decrypt key.', { evt, data });
485
- this.triggerError(error);
486
- return;
487
- }
488
- Log.warn('hlsjs: non-fatal error occurred', { evt, data });
489
- }
490
- }
491
- _keyIsDenied(data) {
492
- return (data.type === HLSJS.ErrorTypes.NETWORK_ERROR &&
493
- data.details === HLSJS.ErrorDetails.KEY_LOAD_ERROR &&
494
- data.response &&
495
- data.response.code &&
496
- data.response.code >= 400);
497
- }
498
- _onTimeUpdate() {
499
- const update = {
500
- current: this.getCurrentTime(),
501
- total: this.getDuration(),
502
- firstFragDateTime: this.getProgramDateTime(),
503
- };
504
- const isSame = this._lastTimeUpdate &&
505
- update.current === this._lastTimeUpdate.current &&
506
- update.total === this._lastTimeUpdate.total;
507
- if (isSame) {
508
- return;
509
- }
510
- this._lastTimeUpdate = update;
511
- this.trigger(Events.PLAYBACK_TIMEUPDATE, update, this.name);
512
- }
513
- _onDurationChange() {
514
- const duration = this.getDuration();
515
- if (this._lastDuration === duration) {
516
- return;
517
- }
518
- this._lastDuration = duration;
519
- super._onDurationChange();
520
- }
521
- _onProgress() {
522
- if (!this.el.buffered.length) {
523
- return;
524
- }
525
- let buffered = [];
526
- let bufferedPos = 0;
527
- for (let i = 0; i < this.el.buffered.length; i++) {
528
- buffered = [
529
- ...buffered,
530
- {
531
- // for a stream with sliding window dvr something that is buffered my slide off the start of the timeline
532
- start: Math.max(0, this.el.buffered.start(i) -
533
- this._playableRegionStartTime),
534
- end: Math.max(0, this.el.buffered.end(i) -
535
- this._playableRegionStartTime),
536
- },
537
- ];
538
- if (this.el.currentTime >= buffered[i].start &&
539
- this.el.currentTime <= buffered[i].end) {
540
- bufferedPos = i;
541
- }
542
- }
543
- const progress = {
544
- start: buffered[bufferedPos].start,
545
- current: buffered[bufferedPos].end,
546
- total: this.getDuration(),
547
- };
548
- this.trigger(Events.PLAYBACK_PROGRESS, progress, buffered);
549
- }
550
- load(url) {
551
- this._stopTimeUpdateTimer();
552
- this.options.src = url;
553
- this._setup();
554
- }
555
- play() {
556
- trace(`${T} play`, { hls: !!this._hls, ...this.options.hlsPlayback });
557
- !this._hls && this._setup();
558
- assert.ok(this._hls, 'Hls.js instance is not available');
559
- !this._manifestParsed &&
560
- !this.options.hlsPlayback.preload &&
561
- this._hls.loadSource(this.options.src);
562
- super.play();
563
- this._startTimeUpdateTimer();
564
- }
565
- pause() {
566
- if (!this._hls) {
567
- return;
568
- }
569
- ;
570
- this.el.pause();
571
- if (this.dvrEnabled) {
572
- this._updateDvr(true);
573
- }
574
- }
575
- stop() {
576
- this._stopTimeUpdateTimer();
577
- if (this._hls) {
578
- super.stop();
579
- }
580
- this._destroyHLSInstance();
581
- }
582
- destroy() {
583
- this._stopTimeUpdateTimer();
584
- this._destroyHLSInstance();
585
- return super.destroy();
586
- }
587
- _updatePlaybackType(evt, data) {
588
- const prevPlaybackType = this._playbackType;
589
- this._playbackType = (data.details.live ? Playback.LIVE : Playback.VOD);
590
- this._onLevelUpdated(evt, data);
591
- // Live stream subtitle tracks detection hack (may not immediately available)
592
- if (this._ccTracksUpdated &&
593
- this._playbackType === Playback.LIVE &&
594
- this.hasClosedCaptionsTracks) {
595
- this._onSubtitleLoaded();
596
- }
597
- if (prevPlaybackType !== this._playbackType) {
598
- this._updateSettings();
599
- }
600
- }
601
- _fillLevels() {
602
- assert.ok(this._hls, 'Hls.js instance is not available');
603
- this._levels = this._hls.levels.map((level, index) => {
604
- return {
605
- level: index, // or level.id?
606
- width: level.width,
607
- height: level.height,
608
- bitrate: level.bitrate,
609
- };
610
- });
611
- this.trigger(Events.PLAYBACK_LEVELS_AVAILABLE, this._levels);
612
- }
613
- _onLevelUpdated(evt, data) {
614
- this._segmentTargetDuration = data.details.targetduration;
615
- this._playlistType = data.details.type || null;
616
- let startTimeChanged = false;
617
- let durationChanged = false;
618
- const fragments = data.details.fragments;
619
- const previousPlayableRegionStartTime = this._playableRegionStartTime;
620
- const previousPlayableRegionDuration = this._playableRegionDuration;
621
- if (fragments.length === 0) {
622
- return;
623
- }
624
- // #EXT-X-PROGRAM-DATE-TIME
625
- if (fragments[0].rawProgramDateTime) {
626
- this._programDateTime = Number(fragments[0].rawProgramDateTime);
627
- }
628
- if (this._playableRegionStartTime !== fragments[0].start) {
629
- startTimeChanged = true;
630
- this._playableRegionStartTime = fragments[0].start;
631
- }
632
- if (startTimeChanged) {
633
- if (!this._localStartTimeCorrelation) {
634
- // set the correlation to map to middle of the extrapolation window
635
- this._localStartTimeCorrelation = {
636
- local: this._now,
637
- remote: (fragments[0].start + this._extrapolatedWindowDuration / 2) * 1000,
638
- };
639
- }
640
- else {
641
- // check if the correlation still works
642
- const corr = this._localStartTimeCorrelation;
643
- const timePassed = this._now - corr.local;
644
- // this should point to a time within the extrapolation window
645
- const startTime = (corr.remote + timePassed) / 1000;
646
- if (startTime < fragments[0].start) {
647
- // our start time is now earlier than the first chunk
648
- // (maybe the chunk was removed early)
649
- // reset correlation so that it sits at the beginning of the first available chunk
650
- this._localStartTimeCorrelation = {
651
- local: this._now,
652
- remote: fragments[0].start * 1000,
653
- };
654
- }
655
- else if (startTime >
656
- previousPlayableRegionStartTime + this._extrapolatedWindowDuration) {
657
- // start time was past the end of the old extrapolation window (so would have been capped)
658
- // see if now that time would be inside the window, and if it would be set the correlation
659
- // so that it resumes from the time it was at at the end of the old window
660
- // update the correlation so that the time starts counting again from the value it's on now
661
- this._localStartTimeCorrelation = {
662
- local: this._now,
663
- remote: Math.max(fragments[0].start, previousPlayableRegionStartTime +
664
- this._extrapolatedWindowDuration) * 1000,
665
- };
666
- }
667
- }
668
- }
669
- let newDuration = data.details.totalduration;
670
- // if it's a live stream then shorten the duration to remove access
671
- // to the area after hlsjs's live sync point
672
- // seeks to areas after this point sometimes have issues
673
- if (this._playbackType === Playback.LIVE) {
674
- const fragmentTargetDuration = data.details.targetduration;
675
- const hlsjsConfig = this.options.playback.hlsjsConfig || {};
676
- const liveSyncDurationCount = hlsjsConfig.liveSyncDurationCount ||
677
- HLSJS.DefaultConfig.liveSyncDurationCount;
678
- const hiddenAreaDuration = fragmentTargetDuration * liveSyncDurationCount;
679
- if (hiddenAreaDuration <= newDuration) {
680
- newDuration -= hiddenAreaDuration;
681
- this._durationExcludesAfterLiveSyncPoint = true;
682
- }
683
- else {
684
- this._durationExcludesAfterLiveSyncPoint = false;
685
- }
686
- }
687
- if (newDuration !== this._playableRegionDuration) {
688
- durationChanged = true;
689
- this._playableRegionDuration = newDuration;
690
- }
691
- // Note the end time is not the playableRegionDuration
692
- // The end time will always increase even if content is removed from the beginning
693
- const endTime = fragments[0].start + newDuration;
694
- const previousEndTime = previousPlayableRegionStartTime + previousPlayableRegionDuration;
695
- const endTimeChanged = endTime !== previousEndTime;
696
- if (endTimeChanged) {
697
- if (!this._localEndTimeCorrelation) {
698
- // set the correlation to map to the end
699
- this._localEndTimeCorrelation = {
700
- local: this._now,
701
- remote: endTime * 1000,
702
- };
703
- }
704
- else {
705
- // check if the correlation still works
706
- const corr = this._localEndTimeCorrelation;
707
- const timePassed = this._now - corr.local;
708
- // this should point to a time within the extrapolation window from the end
709
- const extrapolatedEndTime = (corr.remote + timePassed) / 1000;
710
- if (extrapolatedEndTime > endTime) {
711
- this._localEndTimeCorrelation = {
712
- local: this._now,
713
- remote: endTime * 1000,
714
- };
715
- }
716
- else if (extrapolatedEndTime <
717
- endTime - this._extrapolatedWindowDuration) {
718
- // our extrapolated end time is now earlier than the extrapolation window from the actual end time
719
- // (maybe a chunk became available early)
720
- // reset correlation so that it sits at the beginning of the extrapolation window from the end time
721
- this._localEndTimeCorrelation = {
722
- local: this._now,
723
- remote: (endTime - this._extrapolatedWindowDuration) * 1000,
724
- };
725
- }
726
- else if (extrapolatedEndTime > previousEndTime) {
727
- // end time was past the old end time (so would have been capped)
728
- // set the correlation so that it resumes from the time it was at at the end of the old window
729
- this._localEndTimeCorrelation = {
730
- local: this._now,
731
- remote: previousEndTime * 1000,
732
- };
733
- }
734
- }
735
- }
736
- // now that the values have been updated call any methods that use on them so they get the updated values
737
- // immediately
738
- durationChanged && this._onDurationChange();
739
- startTimeChanged && this._onProgress();
740
- }
741
- _onFragmentChanged(evt, data) {
742
- this._currentFragment = data.frag;
743
- // @ts-ignore
744
- this.trigger(Events.Custom.PLAYBACK_FRAGMENT_CHANGED, data);
745
- }
746
- _onFragmentLoaded(evt, data) {
747
- this.trigger(Events.PLAYBACK_FRAGMENT_LOADED, data);
748
- }
749
- _onSubtitleLoaded() {
750
- // This event may be triggered multiple times
751
- // Setup CC only once (disable CC by default)
752
- if (!this._ccIsSetup) {
753
- this.trigger(Events.PLAYBACK_SUBTITLE_AVAILABLE);
754
- const trackId = this._playbackType === Playback.LIVE ? -1 : this.closedCaptionsTrackId;
755
- this.closedCaptionsTrackId = trackId;
756
- this._ccIsSetup = true;
757
- }
758
- }
759
- _onLevelSwitch(evt, data) {
760
- if (!this.levels.length) {
761
- this._fillLevels();
762
- }
763
- this.trigger(Events.PLAYBACK_LEVEL_SWITCH_END);
764
- this.trigger(Events.PLAYBACK_LEVEL_SWITCH, data);
765
- assert(this._hls, 'Hls.js instance is not available');
766
- const currentLevel = this._hls.levels[data.level];
767
- if (currentLevel) {
768
- // TODO should highDefinition be private and maybe have a read only accessor if it's used somewhere
769
- this.highDefinition =
770
- currentLevel.height >= 720 || currentLevel.bitrate / 1000 >= 2000;
771
- this.trigger(Events.PLAYBACK_HIGHDEFINITIONUPDATE, this.highDefinition);
772
- this.trigger(Events.PLAYBACK_BITRATE, {
773
- height: currentLevel.height,
774
- width: currentLevel.width,
775
- bitrate: currentLevel.bitrate,
776
- level: data.level,
777
- });
778
- }
779
- }
780
- get dvrEnabled() {
781
- // enabled when:
782
- // - the duration does not include content after hlsjs's live sync point
783
- // - the playable region duration is longer than the configured duration to enable dvr after
784
- // - the playback type is LIVE.
785
- return (this._durationExcludesAfterLiveSyncPoint &&
786
- this._duration >= this._minDvrSize &&
787
- this.getPlaybackType() === Playback.LIVE);
788
- }
789
- getPlaybackType() {
790
- return this._playbackType;
791
- }
792
- isSeekEnabled() {
793
- return this._playbackType === Playback.VOD || this.dvrEnabled;
794
- }
795
- triggerError(error) {
796
- trace(`${T} triggerError`, { error });
797
- this.trigger(Events.PLAYBACK_ERROR, error);
798
- this.stop();
799
- }
800
- }
801
- HlsPlayback.canPlay = function (resource, mimeType) {
802
- const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
803
- const isHls = (resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'm3u8') ||
804
- listContainsIgnoreCase(mimeType, [
805
- 'application/vnd.apple.mpegurl',
806
- 'application/x-mpegURL',
807
- ]);
808
- const hasSupport = HLSJS.isSupported();
809
- trace(`${T} canPlay`, {
810
- hasSupport,
811
- isHls,
812
- resource,
813
- });
814
- return !!(hasSupport && isHls);
815
- };