ravnur-player-public 3.4.2 → 3.4.4

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 (262) hide show
  1. package/.eslintignore +7 -0
  2. package/.eslintrc.js +206 -0
  3. package/.flowconfig +3 -0
  4. package/.vscode/extensions.json +7 -0
  5. package/.vscode/launch.json +37 -0
  6. package/.vscode/settings.json +4 -0
  7. package/README-Private.md +54 -0
  8. package/babel.config.js +28 -0
  9. package/bitbucket-pipelines.yml +61 -0
  10. package/cert.pem +23 -0
  11. package/demo/BaseM.mp4 +0 -0
  12. package/demo/HD.mp4 +0 -0
  13. package/demo/annotations.json +50 -0
  14. package/demo/annotations_ge.json +50 -0
  15. package/demo/base.mp3 +0 -0
  16. package/demo/cc_2125en.vtt +4958 -0
  17. package/demo/cc_en.vtt +171 -0
  18. package/demo/cc_ge.vtt +178 -0
  19. package/demo/chapters_en.vtt +38 -0
  20. package/demo/chapters_ge.vtt +5 -0
  21. package/demo/chapters_ge1.json +23 -0
  22. package/demo/hls/audio/stereo/en/128kbit.m3u8 +912 -0
  23. package/demo/hls/audio/stereo/none/128kbit.m3u8 +912 -0
  24. package/demo/hls/audio/surround/en/320kbit.m3u8 +912 -0
  25. package/demo/hls/playlist.m3u8 +31 -0
  26. package/demo/hls/video/10000kbit.m3u8 +894 -0
  27. package/demo/hls/video/1100kbit.m3u8 +894 -0
  28. package/demo/hls/video/1500kbit.m3u8 +894 -0
  29. package/demo/hls/video/250kbit.m3u8 +894 -0
  30. package/demo/hls/video/4000kbit.m3u8 +894 -0
  31. package/demo/hls/video/500kbit.m3u8 +894 -0
  32. package/demo/hls/video/6000kbit.m3u8 +894 -0
  33. package/demo/hls/video/800kbit.m3u8 +894 -0
  34. package/demo/hls.js +5 -0
  35. package/demo/hls.js.map +1 -0
  36. package/demo/hls.min.js +2 -0
  37. package/demo/hls.min.js.map +1 -0
  38. package/demo/playlist.m3u8 +31 -0
  39. package/demo/ravnur-flash-audio.swf +0 -0
  40. package/demo/ravnur-flash-video-hls.swf +0 -0
  41. package/demo/ravnur-flash-video.swf +0 -0
  42. package/demo/shaka/shaka-player.foo.debug.d.ts +4532 -0
  43. package/demo/shaka/shaka-player.foo.debug.externs.js +3886 -0
  44. package/demo/shaka/shaka-player.foo.debug.js +1746 -0
  45. package/demo/shaka/shaka-player.foo.debug.map +8 -0
  46. package/demo/shaka/wrapper.js +7 -0
  47. package/demo/test.html +458 -0
  48. package/dist/RavnurMediaPlayer.min.js +1 -1
  49. package/dist/cdn/RavnurMediaPlayer.min.js +1 -1
  50. package/jest.config.js +4 -0
  51. package/key.pem +27 -0
  52. package/lib/es5.js +344 -0
  53. package/lib/images/Spinner-small.gif +0 -0
  54. package/lib/images/close.png +0 -0
  55. package/lib/images/ic_check_box_black_24dp_1x.png +0 -0
  56. package/lib/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
  57. package/lib/images/ic_chevron_left_white_24dp_1x.png +0 -0
  58. package/lib/images/ic_chevron_right_white_24dp_1x.png +0 -0
  59. package/lib/images/ic_closed_caption_white_24dp_1x.png +0 -0
  60. package/lib/images/ic_fast_forward_white_24dp_1x.png +0 -0
  61. package/lib/images/ic_fast_rewind_white_24dp_1x.png +0 -0
  62. package/lib/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
  63. package/lib/images/ic_fullscreen_white_24dp_1x.png +0 -0
  64. package/lib/images/ic_hd_white_24dp_1x.png +0 -0
  65. package/lib/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
  66. package/lib/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
  67. package/lib/images/ic_pause_white_24dp_1x.png +0 -0
  68. package/lib/images/ic_photo_white_24dp_1x.png +0 -0
  69. package/lib/images/ic_play_arrow_white_24dp_1x.png +0 -0
  70. package/lib/images/ic_refresh_white_24dp_1x.png +0 -0
  71. package/lib/images/ic_settings_white_24dp_1x.png +0 -0
  72. package/lib/images/ic_skip_next_white_24dp_1x.png +0 -0
  73. package/lib/images/ic_skip_previous_white_24dp_1x.png +0 -0
  74. package/lib/images/ic_toc_white_24dp_1x.png +0 -0
  75. package/lib/images/ic_volume_off_white_24dp_1x.png +0 -0
  76. package/lib/images/ic_volume_up_white_24dp_1x.png +0 -0
  77. package/lib/player4ie8.css +225 -0
  78. package/package.json +1 -5
  79. package/server.js +29 -0
  80. package/src/config/cc.js +56 -0
  81. package/src/config/i18n.js +101 -0
  82. package/src/config/options.js +123 -0
  83. package/src/config/playlist.js +9 -0
  84. package/src/config/source.js +23 -0
  85. package/src/config/statuses.js +8 -0
  86. package/src/config/styles.js +16 -0
  87. package/src/entity.js +27 -0
  88. package/src/events.js +5 -0
  89. package/src/extensions/annotations.js +142 -0
  90. package/src/extensions/audio-tarcks.js +115 -0
  91. package/src/extensions/backward.js +45 -0
  92. package/src/extensions/base.js +73 -0
  93. package/src/extensions/bottom-next.js +50 -0
  94. package/src/extensions/bottom-prev.js +50 -0
  95. package/src/extensions/buffering.js +78 -0
  96. package/src/extensions/c2pa.js +350 -0
  97. package/src/extensions/caption-search.js +230 -0
  98. package/src/extensions/cc.js +874 -0
  99. package/src/extensions/crawl.js +118 -0
  100. package/src/extensions/download.js +411 -0
  101. package/src/extensions/error.js +47 -0
  102. package/src/extensions/forward.js +44 -0
  103. package/src/extensions/fullscreen.js +84 -0
  104. package/src/extensions/help.js +201 -0
  105. package/src/extensions/helpers/FileSaver.js +157 -0
  106. package/src/extensions/helpers/clickOpener.js +180 -0
  107. package/src/extensions/helpers/opener.js +30 -0
  108. package/src/extensions/helpers/openerHeightChecker.js +13 -0
  109. package/src/extensions/helpers/popover.js +33 -0
  110. package/src/extensions/helpers/popoverPosition.js +30 -0
  111. package/src/extensions/helpers/scrollIntoView.js +9 -0
  112. package/src/extensions/helpers/storage.js +20 -0
  113. package/src/extensions/helpers/textContent.js +6 -0
  114. package/src/extensions/helpers/timeCodeToSeconds.js +44 -0
  115. package/src/extensions/helpers/transport.js +43 -0
  116. package/src/extensions/helpers/vtt-loader.js +42 -0
  117. package/src/extensions/index.js +87 -0
  118. package/src/extensions/live.js +76 -0
  119. package/src/extensions/mux.js +57 -0
  120. package/src/extensions/next-frame.js +44 -0
  121. package/src/extensions/next.js +48 -0
  122. package/src/extensions/placeholder.js +241 -0
  123. package/src/extensions/play.js +102 -0
  124. package/src/extensions/poster.js +47 -0
  125. package/src/extensions/prev-frame.js +44 -0
  126. package/src/extensions/prev.js +48 -0
  127. package/src/extensions/progress.js +465 -0
  128. package/src/extensions/resizer.js +37 -0
  129. package/src/extensions/settings.js +367 -0
  130. package/src/extensions/theater.js +56 -0
  131. package/src/extensions/title.js +38 -0
  132. package/src/extensions/toc.js +334 -0
  133. package/src/extensions/volume.js +196 -0
  134. package/src/flash/FlashPlugin.js +301 -0
  135. package/src/flash/MediaElement.js +361 -0
  136. package/src/flash/plugins.js +32 -0
  137. package/src/flash-detector.js +66 -0
  138. package/src/helpers/$t.js +10 -0
  139. package/src/helpers/binder.js +11 -0
  140. package/src/helpers/isAndroid.js +5 -0
  141. package/src/helpers/isBlackBerry.js +5 -0
  142. package/src/helpers/isCanvasSupported.js +6 -0
  143. package/src/helpers/isIE.js +21 -0
  144. package/src/helpers/isMobile.js +10 -0
  145. package/src/helpers/isWindows.js +5 -0
  146. package/src/helpers/isWindowsPhone.js +5 -0
  147. package/src/helpers/isiOS.js +5 -0
  148. package/src/html5media.js +19 -0
  149. package/src/index.js +2 -0
  150. package/src/logger.js +31 -0
  151. package/src/microevent.js +65 -0
  152. package/src/normalize-options.js +139 -0
  153. package/src/player.js +864 -0
  154. package/src/players/base.js +209 -0
  155. package/src/players/flash.js +172 -0
  156. package/src/players/hls.js +278 -0
  157. package/src/players/html.js +205 -0
  158. package/src/players/index.js +59 -0
  159. package/src/players/shaka.js +219 -0
  160. package/src/playlist.js +362 -0
  161. package/src/screenfull.js +121 -0
  162. package/src/state.js +474 -0
  163. package/src/static/es5.js +344 -0
  164. package/src/static/images/Spinner-small.gif +0 -0
  165. package/src/static/images/close.png +0 -0
  166. package/src/static/images/ic_check_box_black_24dp_1x.png +0 -0
  167. package/src/static/images/ic_check_box_outline_blank_black_24dp_1x.png +0 -0
  168. package/src/static/images/ic_chevron_left_white_24dp_1x.png +0 -0
  169. package/src/static/images/ic_chevron_right_white_24dp_1x.png +0 -0
  170. package/src/static/images/ic_closed_caption_white_24dp_1x.png +0 -0
  171. package/src/static/images/ic_fast_forward_white_24dp_1x.png +0 -0
  172. package/src/static/images/ic_fast_rewind_white_24dp_1x.png +0 -0
  173. package/src/static/images/ic_fullscreen_exit_white_24dp_1x.png +0 -0
  174. package/src/static/images/ic_fullscreen_white_24dp_1x.png +0 -0
  175. package/src/static/images/ic_hd_white_24dp_1x.png +0 -0
  176. package/src/static/images/ic_keyboard_arrow_left_black_24dp_1x.png +0 -0
  177. package/src/static/images/ic_keyboard_arrow_right_black_24dp_1x.png +0 -0
  178. package/src/static/images/ic_pause_white_24dp_1x.png +0 -0
  179. package/src/static/images/ic_play_arrow_white_24dp_1x.png +0 -0
  180. package/src/static/images/ic_refresh_white_24dp_1x.png +0 -0
  181. package/src/static/images/ic_settings_white_24dp_1x.png +0 -0
  182. package/src/static/images/ic_skip_next_white_24dp_1x.png +0 -0
  183. package/src/static/images/ic_skip_previous_white_24dp_1x.png +0 -0
  184. package/src/static/images/ic_toc_white_24dp_1x.png +0 -0
  185. package/src/static/images/ic_volume_off_white_24dp_1x.png +0 -0
  186. package/src/static/images/ic_volume_up_white_24dp_1x.png +0 -0
  187. package/src/static/player4ie8.css +225 -0
  188. package/src/styles/bplaylist.css.js +124 -0
  189. package/src/styles/index.js +1966 -0
  190. package/src/styles/playlist.css.js +84 -0
  191. package/src/styles/rplaylist.css.js +98 -0
  192. package/src/svgs.js +111 -0
  193. package/src/types/Logger.js +10 -0
  194. package/src/types/Options.js +179 -0
  195. package/src/types/Playlist.js +3 -0
  196. package/src/types/Source.js +28 -0
  197. package/src/types/State.js +46 -0
  198. package/src/types/Styles.js +11 -0
  199. package/src/types/TimeData.js +8 -0
  200. package/src/types/Translation.js +69 -0
  201. package/src/utils/absolutizeUrl.js +9 -0
  202. package/src/utils/addClass.js +9 -0
  203. package/src/utils/addEvent.js +31 -0
  204. package/src/utils/addProperty.js +65 -0
  205. package/src/utils/appendChild.js +14 -0
  206. package/src/utils/buff2hex.js +5 -0
  207. package/src/utils/contains.js +33 -0
  208. package/src/utils/createElement.js +24 -0
  209. package/src/utils/each.js +34 -0
  210. package/src/utils/escapeHTML.js +8 -0
  211. package/src/utils/existy.js +4 -0
  212. package/src/utils/extend.js +17 -0
  213. package/src/utils/filter.js +16 -0
  214. package/src/utils/find.js +11 -0
  215. package/src/utils/findIndex.js +20 -0
  216. package/src/utils/first.js +5 -0
  217. package/src/utils/get.js +19 -0
  218. package/src/utils/has.js +5 -0
  219. package/src/utils/hasClass.js +6 -0
  220. package/src/utils/head.js +11 -0
  221. package/src/utils/inRange.js +16 -0
  222. package/src/utils/index.js +73 -0
  223. package/src/utils/isArray.js +4 -0
  224. package/src/utils/isBoolean.js +3 -0
  225. package/src/utils/isElement.js +7 -0
  226. package/src/utils/isEmpty.js +6 -0
  227. package/src/utils/isEqual.js +33 -0
  228. package/src/utils/isEqualBuffer.js +13 -0
  229. package/src/utils/isFunction.js +3 -0
  230. package/src/utils/isNotEmpty.js +5 -0
  231. package/src/utils/isObject.js +5 -0
  232. package/src/utils/isString.js +9 -0
  233. package/src/utils/last.js +4 -0
  234. package/src/utils/map.js +11 -0
  235. package/src/utils/negate.js +8 -0
  236. package/src/utils/noop.js +1 -0
  237. package/src/utils/notExisty.js +5 -0
  238. package/src/utils/reduce.js +8 -0
  239. package/src/utils/remove.js +7 -0
  240. package/src/utils/removeClass.js +8 -0
  241. package/src/utils/removeEvent.js +7 -0
  242. package/src/utils/toArray.js +7 -0
  243. package/src/utils/toggleClass.js +16 -0
  244. package/src/utils/uidGenerator.js +8 -0
  245. package/src/utils/upperFirst.js +4 -0
  246. package/tests/extensions/__snapshots__/download.spec.js.snap +226 -0
  247. package/tests/extensions/__snapshots__/fullscreen.spec.js.snap +30 -0
  248. package/tests/extensions/__snapshots__/title.spec.js.snap +16 -0
  249. package/tests/extensions/download.spec.js +111 -0
  250. package/tests/extensions/fullscreen.spec.js +56 -0
  251. package/tests/extensions/title.spec.js +35 -0
  252. package/tests/mocks/assets/BaseM.mp4 +0 -0
  253. package/tests/mocks/assets/hls.min.js +5 -0
  254. package/tests/mocks/assets/styleMock.js +1 -0
  255. package/tests/mocks/base-player-options.js +47 -0
  256. package/tests/mocks/sources.js +58 -0
  257. package/tests/mocks/timedata/cc_en.vtt +171 -0
  258. package/tests/mocks/timedata/cc_ge.vtt +178 -0
  259. package/tests/utils/wait.js +1 -0
  260. package/webpack.config.js +78 -0
  261. package/dist/.DS_Store +0 -0
  262. package/dist/cdn/.DS_Store +0 -0
package/server.js ADDED
@@ -0,0 +1,29 @@
1
+ // var https = require('https');
2
+ var express = require('express');
3
+ var fs = require('fs');
4
+
5
+ var server = express();
6
+
7
+ //CORS middleware
8
+ function allowCrossDomain(req, res, next) {
9
+ res.header('Access-Control-Allow-Origin', '*');
10
+ res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
11
+ res.header('Access-Control-Allow-Headers', 'Content-Type');
12
+ next();
13
+ }
14
+
15
+
16
+ server.use(allowCrossDomain);
17
+ server.use('/lib', express.static('./lib'));
18
+ server.use('/demo', express.static('./demo'));
19
+ server.use('/', express.static('./'));
20
+
21
+ // server = https.createServer({
22
+ // key: fs.readFileSync('key.pem'),
23
+ // cert: fs.readFileSync('cert.pem')
24
+ // }, server);
25
+
26
+ /* =============== RUNNER =============== */
27
+ server.listen(7890, function() {
28
+ console.log(`http://localhost:7890/test.html`);
29
+ });
@@ -0,0 +1,56 @@
1
+ // @flow
2
+
3
+ import type {
4
+ Player$CCColor, Player$CCFontFamily, Player$CCFontSize, Player$CCLocation
5
+ } from '../types/State';
6
+
7
+ import type { Player$Translation } from '../types/Translation';
8
+
9
+ export type CCOption<T: string> = {
10
+ key?: $Keys<Player$Translation>,
11
+ label?: string,
12
+ value: T
13
+ }
14
+
15
+ export const DEFAULT_CC_TEXT_COLOR: Player$CCColor = '#FFF';
16
+ export const DEFAULT_CC_BG_COLOR: Player$CCColor = '#000';
17
+
18
+ export const CC_COLORS: CCOption<Player$CCColor>[] = [
19
+ { key: 'red', value: '#F44336' },
20
+ { key: 'purple', value: '#9C27B0' },
21
+ { key: 'indigo', value: '#3F51B5' },
22
+ { key: 'blue', value: '#2196F3' },
23
+ { key: 'green', value: '#4CAF50' },
24
+ { key: 'yellow', value: '#FFEB3B' },
25
+ { key: 'orange', value: '#FF9800' },
26
+ { key: 'brown', value: '#795548' },
27
+ { key: 'grey', value: '#9E9E9E' },
28
+ { key: 'white', value: '#FFF' },
29
+ { key: 'black', value: '#000' }
30
+ ];
31
+
32
+ export const DEFAULT_CC_FONT_SIZE = '100%';
33
+
34
+ export const CC_FONT_SIZES: CCOption<Player$CCFontSize>[] = [
35
+ { label: '75%', value: '75%' },
36
+ { label: '100%', value: '100%' },
37
+ { label: '125%', value: '125%' },
38
+ { label: '150%', value: '150%' },
39
+ { label: '200%', value: '200%' }
40
+ ];
41
+
42
+ export const DEFAULT_CC_FONT_FAMILY = 'Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, sans-serif';
43
+
44
+ export const CC_FONT_FAMILIES: CCOption<Player$CCFontFamily>[] = [
45
+ { key: 'monoserif', value: '"Courier New", Courier, "Nimbus Mono L", "Cutive Mono", monospace' },
46
+ { key: 'propserif', value: '"Times New Roman", Times, Georgia, Cambria, "PT Serif Caption", serif' },
47
+ { key: 'monosans', value: '"Deja Vu Sans Mono", "Lucida Console", Monaco, Consolas, "PT Mono", monospace' },
48
+ { key: 'propssans', value: 'Roboto, "Arial Unicode Ms", Arial, Helvetica, Verdana, sans-serif' }
49
+ ];
50
+
51
+ export const DEFAULT_CC_LOCATION = 'over';
52
+
53
+ export const CC_LOCATIONS: CCOption<Player$CCLocation>[] = [
54
+ { key: 'cc-location-over', value: 'over' },
55
+ { key: 'cc-location-below', value: 'below' }
56
+ ];
@@ -0,0 +1,101 @@
1
+ // @flow
2
+ import type { Player$Translation } from '../types/Translation';
3
+
4
+ const i18n: Player$Translation = {
5
+ fullscreen: 'Fullscreen',
6
+ 'exit-fullscreen': 'Exit full screen',
7
+
8
+ theater: 'Theater mode',
9
+ 'exit-theater': 'Standard mode',
10
+
11
+ play: 'Play',
12
+ pause: 'Pause',
13
+ replay: 'Replay',
14
+ 'standard-playbackrate': 'Standard',
15
+ forward: 'Forward 10 sec',
16
+ backward: 'Back 10 sec',
17
+ prevframe: 'Move to previous frame',
18
+ nextframe: 'Move to next frame',
19
+ annotations: 'Annotations',
20
+ quality: 'Quality',
21
+ 'audio-tracks': 'Audio tracks',
22
+ 'playback-rate': 'Playback rate',
23
+ settings: 'Settings',
24
+ buffering: 'Buffering...',
25
+ cc: 'Closed Captions',
26
+ transcript: 'Transcript',
27
+ chapters: 'Chapters',
28
+ back: 'Back',
29
+ 'settings-fontcolor': 'Font color',
30
+ 'settings-fontsize': 'Font size',
31
+ 'settings-fontfamily': 'Font family',
32
+ 'settings-background': 'Background color',
33
+ 'settings-captionlocations': 'Captions location',
34
+ help: 'Help',
35
+ download: 'Download',
36
+ 'video-drm': 'Video',
37
+ 'video-only': 'Video Only',
38
+ 'video-and': 'Video and',
39
+ language: 'Language',
40
+
41
+ 'unapproved-source': '(unapproved)',
42
+ translate: 'Translate',
43
+ translating: 'Translating...',
44
+
45
+ monoserif : 'Monospace serif',
46
+ propserif : 'Proportionate serif',
47
+ monosans : 'Monospace sans serif',
48
+ propssans : 'Proportionate sans serif',
49
+
50
+ 'cc-location-over' : 'Overlay video',
51
+ 'cc-location-below' : 'Below the video',
52
+
53
+ red : 'Red',
54
+ purple : 'Purple',
55
+ indigo : 'Indigo',
56
+ blue : 'Blue',
57
+ green : 'Green',
58
+ yellow : 'Yellow',
59
+ orange : 'Orange',
60
+ brown : 'Brown',
61
+ grey : 'Grey',
62
+ white : 'White',
63
+ black : 'Black',
64
+
65
+ 'help-bacward' : '"Left (◄)" - Jump backward by 10 seconds',
66
+ 'help-play' : '"Space" - Toggle playback',
67
+ 'help-skip' : '"Right (►)" - Skip 10 seconds',
68
+ 'help-volume' : '"UP/DOWN (▲/▼)" - Change volume by 10%',
69
+ 'help-esc' : '"ESC" - exit fullscreen',
70
+
71
+ 'no-video' : 'No playable sources found',
72
+ 'no-flash' : 'For watching video you need to install Flash Player and restart your browser',
73
+ 'playlist-count-of': 'videos',
74
+
75
+ 'caption-search': 'Search captions',
76
+
77
+ c2pa: 'C2PA',
78
+ 'view-more': 'Learn more',
79
+ 'c2pa-invalid-claim': 'Content credentials are incomplete or missing',
80
+ 'c2pa-exception-subtitle': 'Unexpected error occurred while validating content provenance',
81
+ 'c2pa-unverified-claim': 'Content credentials are unverified',
82
+ 'c2pa-no-data-message': 'Video is missing provenance information. Video owner cannot be established',
83
+ 'c2pa-video-credentials-status': 'Video credentials status:',
84
+ 'c2pa-status-valid': 'Valid',
85
+ 'c2pa-status-invalid': 'Invalid',
86
+ 'c2pa-status-incomplete': 'Incomplete',
87
+ 'c2pa-status-unknown': 'Unknown',
88
+ 'c2pa-signature-valid': 'Digital signature is valid',
89
+ 'c2pa-signature-valid-extended': 'Digital signature is valid. All tracks pass validation and are signed by the owner.',
90
+ 'c2pa-issued-to': 'Issued to:',
91
+ 'c2pa-issued-by': 'Issued by:',
92
+ 'c2pa-encoded-by': 'Encoded by:',
93
+ 'c2pa-video-owner': 'Video owner:',
94
+ 'c2pa-signature-invalid': 'Content credentials have been changed, and authenticity cannot be verified',
95
+ next: 'Next',
96
+ prev: 'Previous',
97
+
98
+ error: 'An error occurred while playing the media.'
99
+ };
100
+
101
+ export default i18n;
@@ -0,0 +1,123 @@
1
+ // import type { Player$InputOptions } from '../types/Options';
2
+
3
+ import { AUTO_MODE } from './playlist';
4
+
5
+ /* eslint camelcase: 0 */
6
+
7
+ const DEFAULT_OPTIONS = {
8
+ // logger: null,
9
+ loggerLevel: 2,
10
+
11
+ timecode: 0,
12
+ frameRate: 23.976,
13
+
14
+ autoStart: false,
15
+ startTime: null,
16
+ endTime: null,
17
+
18
+ useNativeControls: false,
19
+
20
+ useOriginTimeForPreview: true,
21
+
22
+ playlistmode: AUTO_MODE,
23
+ plalistAutoGoNext: true,
24
+ playlistitle: '',
25
+ playlistforcepoint: 0,
26
+
27
+ showExtensions: true,
28
+ alwaysShowExtensions: false,
29
+ extensionsVisibilityTimeout: 2000,
30
+
31
+ showPlay: true,
32
+ showProgress: true,
33
+ showVolume: true,
34
+ showFullScreen: true,
35
+ showClosedCaptions: true,
36
+ showTOC: true,
37
+ showAnnotations: true,
38
+ showQuality: true,
39
+ showAudioTracks: false,
40
+ showPoster: true,
41
+ showError: false,
42
+ showPlaceholder: true,
43
+ showPlaybackRate: true,
44
+ showForward: true,
45
+ showBackward: true,
46
+ showSettings: true,
47
+ showDownload: true,
48
+ showDownloadVideo: true,
49
+ showDownloadCC: false,
50
+ showBottomNext: false,
51
+ showBottomPrev: false,
52
+ showCaptionSearch: false,
53
+ showCrawl: false,
54
+ crawl: {},
55
+ downloadVideoURL: null,
56
+
57
+ showHelp: true,
58
+ showTitle: true,
59
+ showNext: false,
60
+ showNextFrame: false,
61
+ showPrevFrame: false,
62
+ showCCLayout: true,
63
+ showTheaterMode: false,
64
+ useMux: false,
65
+ showSubtitles: false,
66
+ skipDelta: 10,
67
+ keyboardListeners: {},
68
+ globalKeyboardListeners: false,
69
+ isHandlingKeyboardEvents: true,
70
+
71
+ bufferingTimeout: 200,
72
+
73
+ // qualityLevel: null,
74
+ // startLevel: null,
75
+
76
+ hls: {
77
+ maxFragLookUpTolerance: 0.001,
78
+ maxMaxBufferLength: 60 // 60 s = 1 min; default - 10 min
79
+ },
80
+
81
+ shaka: {},
82
+
83
+ mux: {
84
+ env_key: '', // required
85
+ page_type: 'watchpage', // (see docs) 'watchpage', 'iframe', or leave empty
86
+ viewer_user_id: '', // ex: '12345'
87
+ experiment_name: '', // ex: 'player_test_A'
88
+ sub_property_id: '', // ex: 'cus-1'
89
+
90
+ // Player Metadata
91
+ player_name: 'RavnurPlayer',
92
+ player_version: '3.3.3',
93
+ player_init_time: '', // ex: 1451606400000
94
+
95
+ // Video Metadata (cleared with 'videochange' event)
96
+ video_id: '', // ex: 'abcd123'
97
+ video_title: '', // ex: 'My Great Video'
98
+ video_series: '', // ex: 'Weekly Great Videos'
99
+ video_producer: '', // ex: 'Bob the Producer'
100
+ video_content_type: '', // 'short', 'movie', 'episode', 'clip', 'trailer', or 'event'
101
+ video_language_code: '', // ex: 'en'
102
+ video_variant_name: '', // ex: 'Spanish Hard Subs'
103
+ video_variant_id: '', // ex: 'abcd1234'
104
+ video_duration: '', // in milliseconds, ex: 120000
105
+ video_stream_type: 'on-demand', // 'live' or 'on-demand'
106
+ video_encoding_variant: '', // ex: 'Variant 1'
107
+ video_cdn: '' // ex: 'Fastly', 'Akamai'
108
+ },
109
+
110
+ i18n: null,
111
+
112
+ hlsjsURL : 'https://cdn.jsdelivr.net/npm/hls.js@1.5.17/dist/hls.min.js',
113
+ shakaURL : 'https://cdn.jsdelivr.net/npm/shaka-player@4.16.0/dist/shaka-player.compiled.min.js',
114
+ flashPath : '/',
115
+ muxURL : 'https://src.litix.io/core/4/mux.js',
116
+
117
+ disableAutoUrlRewrite: false,
118
+
119
+ useHTMLPlayer: false,
120
+ useHLSJSPlayer: false
121
+ };
122
+
123
+ export default DEFAULT_OPTIONS;
@@ -0,0 +1,9 @@
1
+ // @flow
2
+
3
+ import type { Player$PlaylistMode } from '../types/Playlist';
4
+
5
+ export const BOTTOM_MODE: Player$PlaylistMode = 'bottom';
6
+ export const RIGHT_MODE: Player$PlaylistMode = 'right';
7
+ export const AUTO_MODE: Player$PlaylistMode = 'auto';
8
+
9
+ export const PLAYLIST_MODES = [ AUTO_MODE, BOTTOM_MODE, RIGHT_MODE ];
@@ -0,0 +1,23 @@
1
+ // @flow
2
+
3
+ // import type { Player$Source } from '../types/Source';
4
+
5
+ const SOURCE_OPTIONS = {
6
+ annotations: null,
7
+ chapters: null,
8
+ cc: null,
9
+ preview: null,
10
+ poster: null,
11
+
12
+ title: '',
13
+
14
+ nextTrackTitle: '',
15
+ nextTrackThumbnails: '',
16
+
17
+ clip: null, // [ 10, 300 ] sec
18
+
19
+ // inner props
20
+ isAudio: false
21
+ };
22
+
23
+ export default SOURCE_OPTIONS;
@@ -0,0 +1,8 @@
1
+ // @flow
2
+
3
+ import type { Player$SourceStatus } from '../types/Source';
4
+
5
+ export const APPROVED_TIMEDATA_STATUS: Player$SourceStatus = 2;
6
+ export const UNAPPROVED_TIMEDATA_STATUS: Player$SourceStatus = 1;
7
+ export const TRANSLATABLE_TIMEDATA_STATUS: Player$SourceStatus = 0;
8
+ export const UNTRANSLATED_TIMEDATA_STATUS: Player$SourceStatus = 3;
@@ -0,0 +1,16 @@
1
+ // @flow
2
+ import type { Player$Styles } from '../types/Styles';
3
+
4
+ const DEFAULT_STYLES: Player$Styles = {
5
+ accentColor: '#81d4fa',
6
+ mainColor: '#fff',
7
+ submenuBgColor: '#eee',
8
+ submenuColor: '#333',
9
+ chaptersBubbleColor: '#1565C0',
10
+
11
+ pltHeight: '135px',
12
+
13
+ rplaylistHeight: '30%'
14
+ };
15
+
16
+ export default DEFAULT_STYLES;
package/src/entity.js ADDED
@@ -0,0 +1,27 @@
1
+ // @flow
2
+ import { addEvent, removeEvent, each } from './utils';
3
+
4
+ import MicroEvent from './microevent';
5
+
6
+ import type { Player$Logger } from './types/Logger';
7
+
8
+ export default class Entity {
9
+ _tokens: Array<mixed> = []
10
+ bus: MicroEvent
11
+ logger: Player$Logger
12
+
13
+ constructor(bus: MicroEvent, logger: Player$Logger) {
14
+ this.bus = bus;
15
+ this.logger = logger;
16
+ }
17
+
18
+ addEvent(el: EventTarget, event: string, callback: (Event) => void, useCapture: boolean = false) {
19
+ const token = addEvent(el, event, callback, useCapture);
20
+ this._tokens.push(token);
21
+ }
22
+
23
+ destroy() {
24
+ each(this._tokens, removeEvent);
25
+ this._tokens.length = 0;
26
+ }
27
+ }
package/src/events.js ADDED
@@ -0,0 +1,5 @@
1
+ export default [
2
+ 'loadstart', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata',
3
+ 'loadeddata', 'waiting', 'playing', 'canplay', 'canplaythrough', 'seeking', 'seeked', 'timeupdate', 'ended',
4
+ 'ratechange', 'durationchange', 'volumechange'
5
+ ];
@@ -0,0 +1,142 @@
1
+ import BaseExtension from './base';
2
+
3
+ import {
4
+ createElement, existy, inRange, find, addClass, removeClass, remove, map, isArray
5
+ } from '../utils';
6
+
7
+ import load from './helpers/transport';
8
+ import timeCodeToSeconds from './helpers/timeCodeToSeconds';
9
+ import createSvg, { CROSS } from '../svgs';
10
+
11
+ const OUTER_CN = 'rmp-annotation';
12
+ const OUTER_VISIBLE_CN = `${OUTER_CN}--visible`;
13
+ const OUTER_HOLDER_CN = `${OUTER_CN}__holder`;
14
+ const OUTER_BUTTON_CN = `${OUTER_CN}__button`;
15
+
16
+ const URL_REGEX = /(https?:\/\/[^\s]+)/g;
17
+ const CROSS_SIZE = 16;
18
+
19
+ export default class AnnotationsExtension extends BaseExtension {
20
+ /** @type {Array} */
21
+ annotations = [];
22
+ /** @type {Array} */
23
+ sources = [];
24
+ /** @type {Object} */
25
+ current = null;
26
+
27
+ constructor(player, state, options) {
28
+ super(player, state, options, ['timeupdate', 'annotationslang']);
29
+ this.logger.debug('annotations:extension:creating');
30
+
31
+ this.render();
32
+ this.init();
33
+
34
+ this.logger.debug('annotations:extension:created');
35
+ }
36
+
37
+ init() {
38
+ this.addEvent(this.$button, 'click', () => {
39
+ remove(this.annotations, this.current);
40
+ removeClass(this.$outer, OUTER_VISIBLE_CN);
41
+ this.current = null;
42
+ this.player.focus();
43
+ });
44
+
45
+ const { annotations } = this.options;
46
+ this.sources = isArray(annotations) ? annotations : [annotations];
47
+ }
48
+
49
+ onAnnotationslang(lang) {
50
+ this.annotations.length = 0;
51
+ this.current = null;
52
+ this.onTimeupdate();
53
+ const source = find(this.sources, s => s.srclang === lang );
54
+ if (source) {
55
+ load({ url: source.src, success: (resp) => {
56
+ try {
57
+ this.annotations = map( JSON.parse(resp.data), _convert);
58
+ this.onTimeupdate();
59
+ } catch (e) {
60
+ this.logger.error('Error occurred when parsing the response', resp.data, e);
61
+ }
62
+ }});
63
+ }
64
+ }
65
+
66
+ render() {
67
+ /** @type {HTMLMediaElement} */
68
+ this.$outer = createElement('div', { class: OUTER_CN } );
69
+
70
+ this.$button = createElement('button', { type: 'button', class: OUTER_BUTTON_CN }, this.$outer);
71
+ this.$button.setAttribute('aria-label', 'Close annotation');
72
+
73
+ createSvg(this.$button, CROSS, { width: CROSS_SIZE, height: CROSS_SIZE });
74
+
75
+ this.$outerHolder = createElement('div', { class: OUTER_HOLDER_CN }, this.$outer);
76
+ }
77
+
78
+ onTimeupdate() {
79
+ const time = this.player.getCurrentTime();
80
+ if ( existy(this.current) && inRange(time, this.current.from, this.current.to) ) {
81
+ return;
82
+ }
83
+
84
+ this.current = find(this.annotations, ann => inRange(time, ann.from, ann.to));
85
+
86
+ if ( existy(this.current) ) {
87
+ _applyStyles(this.$outer, this.current);
88
+ _insertText(this.$outerHolder, this.current.text);
89
+ addClass(this.$outer, OUTER_VISIBLE_CN);
90
+ } else {
91
+ removeClass(this.$outer, OUTER_VISIBLE_CN);
92
+ }
93
+ }
94
+
95
+ getOuter() {
96
+ return this.$outer;
97
+ }
98
+
99
+ destroy() {
100
+ super.destroy();
101
+
102
+ if (this.$outer) {
103
+ const parent = this.$outer.parentNode;
104
+ parent.removeChild(this.$outer);
105
+ this.$outer = null;
106
+ }
107
+ }
108
+ }
109
+
110
+ function _wrapURLs(text) {
111
+ return text.replace(URL_REGEX, '<a href="$1">$1</a>');
112
+ }
113
+
114
+ function _wrapNewLine(text) {
115
+ return text.replace(/\n/g, '<br />');
116
+ }
117
+
118
+ function _convert({ text, starts, ends, top, left, width, height, fontsize, fontcolor, background }) {
119
+ return {
120
+ text, top, left, width, height, fontsize, fontcolor, background,
121
+ from: timeCodeToSeconds(`${starts.hh}:${starts.mm}:${starts.ss}`),
122
+ to: timeCodeToSeconds(`${ends.hh}:${ends.mm}:${ends.ss}`)
123
+ };
124
+ }
125
+
126
+ function _applyStyles(element, ann) {
127
+ element.style.top = `${ann.top}px`;
128
+ element.style.left = `${ann.left}px`;
129
+ element.style.width = `${ann.width}px`;
130
+ element.style.height = `${ann.height}px`;
131
+
132
+ element.style.fontSize = ann.fontsize;
133
+ element.style.color = `#${ann.fontcolor}`;
134
+ element.style.backgroundColor = `#${ann.background}`;
135
+ }
136
+
137
+ function _insertText(element, text) {
138
+ element.textContent = text;
139
+ let html = _wrapURLs(element.innerHTML);
140
+ html = _wrapNewLine(html);
141
+ element.innerHTML = html;
142
+ }
@@ -0,0 +1,115 @@
1
+ import BaseExtension from './base';
2
+
3
+ import { createElement, addClass, removeClass, each, toArray } from '../utils';
4
+
5
+ import opener from './helpers/clickOpener';
6
+ import popover from './helpers/popover';
7
+ import createSvg, { HEADPHONE } from '../svgs';
8
+
9
+ const CN = 'rmp-ext-audio-tracks';
10
+ const BUTTON_CN = `${CN}__button`;
11
+ const SELECTOR_CN = `${CN}__selector`;
12
+ const SELECTOR_OPEN_CN = `${SELECTOR_CN}--open`;
13
+
14
+ const ITEM_CN = `${CN}__item`;
15
+ const ITEM_CHECKED_CN = `${ITEM_CN}--checked`;
16
+
17
+ export default class AudioTracksExtension extends BaseExtension {
18
+ constructor(player, state, options) {
19
+ super(player, state, options, ['loadeddata', 'audiotrackswitched']);
20
+ this.logger.debug('audio-tracks:extension:creating');
21
+
22
+ this.render();
23
+ this.init();
24
+
25
+ this.logger.debug('audio-tracks:extension:created');
26
+ }
27
+
28
+ render() {
29
+ this.$el = createElement('div', { class: CN });
30
+
31
+ this.$button = createElement(
32
+ 'button',
33
+ { type: 'button', class: BUTTON_CN },
34
+ this.$el
35
+ );
36
+
37
+ this.$selector = createElement('div', { class: SELECTOR_CN, tabindex: -1 }, this.$el);
38
+
39
+ createSvg(this.$button, HEADPHONE);
40
+ }
41
+
42
+ init() {
43
+ const $button = this.$button,
44
+ $selector = this.$selector,
45
+ reposition = false,
46
+ closeOnClick = true,
47
+ heightControl = true;
48
+ popover(this, { $button, text: this.$t('audio-tracks') });
49
+ opener(this, {
50
+ $button,
51
+ $selector,
52
+ SELECTOR_OPEN_CN,
53
+ reposition,
54
+ closeOnClick,
55
+ heightControl,
56
+ firstFocusItemSelector: `.${ITEM_CN}`
57
+ });
58
+ }
59
+
60
+ _renderAudioTracks() {
61
+ // fix RAV-411
62
+ each(toArray(this.$selector.childNodes), (btn) =>
63
+ this.$selector.removeChild(btn)
64
+ );
65
+
66
+ const audioTrackIdx = this.player.getAudioTrack();
67
+
68
+ const items = [];
69
+ each(this.player.getAudioTracks(), (track, idx) => {
70
+ if (!track || typeof track !== 'object') {
71
+ return;
72
+ }
73
+ const item = createElement(
74
+ 'button',
75
+ { type: 'button', class: ITEM_CN },
76
+ this.$selector
77
+ );
78
+ item.textContent = track.name || track.label;
79
+
80
+ if (+idx === audioTrackIdx) {
81
+ addClass(item, ITEM_CHECKED_CN);
82
+ }
83
+
84
+ this.addEvent(item, 'click', () => {
85
+ each(items, (el) => removeClass(el, ITEM_CHECKED_CN));
86
+ addClass(item, ITEM_CHECKED_CN);
87
+ this.player.setAudioTrack(track.id);
88
+ });
89
+ items.push(item);
90
+ });
91
+ }
92
+
93
+ onAudiotrackswitched() {
94
+ this._renderAudioTracks();
95
+ }
96
+
97
+ onLoadeddata() {
98
+ if (this.player.isMultiAudioTracks()) {
99
+ this._renderAudioTracks();
100
+ } else {
101
+ this.$el.style.display = 'none';
102
+ }
103
+ }
104
+
105
+ getElement() {
106
+ return this.$el;
107
+ }
108
+
109
+ destroy() {
110
+ super.destroy();
111
+ const parent = this.$el.parentNode;
112
+ parent.removeChild(this.$el);
113
+ this.$el = null;
114
+ }
115
+ }