cloudinary-video-player 1.6.2-edge.13

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 (226) hide show
  1. package/.eslintignore +4 -0
  2. package/.snyk +19 -0
  3. package/.travis.yml +8 -0
  4. package/CHANGELOG.md +329 -0
  5. package/LICENSE +21 -0
  6. package/README.md +87 -0
  7. package/dist/cld-video-player.css +2110 -0
  8. package/dist/cld-video-player.js +5249 -0
  9. package/dist/cld-video-player.light.css +1766 -0
  10. package/dist/cld-video-player.light.js +1399 -0
  11. package/dist/cld-video-player.light.min.css +1 -0
  12. package/dist/cld-video-player.light.min.js +2 -0
  13. package/dist/cld-video-player.light.min.js.LICENSE.txt +23 -0
  14. package/dist/cld-video-player.min.css +1 -0
  15. package/dist/cld-video-player.min.js +2 -0
  16. package/dist/cld-video-player.min.js.LICENSE.txt +26 -0
  17. package/dist/fonts/cloudinary_icon_for_black_bg.svg +69 -0
  18. package/dist/fonts/cloudinary_icon_for_white_bg.svg +69 -0
  19. package/docs/360.html +102 -0
  20. package/docs/_template.html +93 -0
  21. package/docs/adaptive-streaming.html +297 -0
  22. package/docs/analytics.html +140 -0
  23. package/docs/api.html +302 -0
  24. package/docs/audio.html +136 -0
  25. package/docs/autoplay-fallback.html +138 -0
  26. package/docs/autoplay-on-scroll.html +107 -0
  27. package/docs/codec-fallback.html +158 -0
  28. package/docs/colors.html +135 -0
  29. package/docs/components.html +284 -0
  30. package/docs/custom-cld-errors.html +134 -0
  31. package/docs/floating-player.html +98 -0
  32. package/docs/fluid.html +117 -0
  33. package/docs/force-hls-subtitles-ios.html +159 -0
  34. package/docs/index.html +83 -0
  35. package/docs/interaction-area.html +398 -0
  36. package/docs/live-customer.html +128 -0
  37. package/docs/multiple-players.html +125 -0
  38. package/docs/playlist-by-tag-cap.html +182 -0
  39. package/docs/playlist-by-tag.html +133 -0
  40. package/docs/playlist.html +133 -0
  41. package/docs/poster.html +155 -0
  42. package/docs/raw-url.html +104 -0
  43. package/docs/recommendations.html +155 -0
  44. package/docs/scripts.js +156 -0
  45. package/docs/seek-thumbs.html +90 -0
  46. package/docs/shoppable.html +335 -0
  47. package/docs/subtitles-and-captions.html +267 -0
  48. package/docs/transformations.html +171 -0
  49. package/docs/ui-config.html +108 -0
  50. package/docs/vast-vpaid.html +149 -0
  51. package/env.example.js +6 -0
  52. package/env.js +6 -0
  53. package/jest-puppeteer.config.js +14 -0
  54. package/jest.config.js +196 -0
  55. package/package.json +99 -0
  56. package/sandbox.config.json +3 -0
  57. package/setupJest.js +1 -0
  58. package/src/assets/fonts/VideoJS.svg +120 -0
  59. package/src/assets/fonts/VideoJS.ttf +0 -0
  60. package/src/assets/fonts/VideoJS.woff +0 -0
  61. package/src/assets/fonts/icons.json +120 -0
  62. package/src/assets/icons/cloudinary_icon_for_black_bg.svg +69 -0
  63. package/src/assets/icons/cloudinary_icon_for_white_bg.svg +69 -0
  64. package/src/assets/icons/cloudinary_logo_for_dark_bg.svg +188 -0
  65. package/src/assets/icons/cloudinary_logo_for_white_bg.svg +188 -0
  66. package/src/assets/icons/info-circle.svg +17 -0
  67. package/src/assets/styles/ads-label.scss +16 -0
  68. package/src/assets/styles/components/interaction-areas.scss +158 -0
  69. package/src/assets/styles/components/playlist.scss +213 -0
  70. package/src/assets/styles/components/themedButton.scss +48 -0
  71. package/src/assets/styles/components/thumbnail.scss +94 -0
  72. package/src/assets/styles/components/title-bar.scss +67 -0
  73. package/src/assets/styles/components/triangle-volume-bar.scss +52 -0
  74. package/src/assets/styles/icons.scss +257 -0
  75. package/src/assets/styles/main.scss +324 -0
  76. package/src/assets/styles/mixins/aspect-ratio.scss +16 -0
  77. package/src/assets/styles/mixins/disable-transition.scss +3 -0
  78. package/src/assets/styles/mixins/mixins.scss +5 -0
  79. package/src/assets/styles/mixins/skin.scss +64 -0
  80. package/src/assets/styles/variables.scss +2 -0
  81. package/src/assets/styles/videojs-ima.scss +252 -0
  82. package/src/components/component-utils.js +20 -0
  83. package/src/components/index.js +21 -0
  84. package/src/components/interaction-area/interaction-area.const.js +30 -0
  85. package/src/components/interaction-area/interaction-area.service.js +223 -0
  86. package/src/components/interaction-area/interaction-area.utils.js +236 -0
  87. package/src/components/jumpButtons/jump-10-minus.js +21 -0
  88. package/src/components/jumpButtons/jump-10-plus.js +20 -0
  89. package/src/components/logoButton/logo-button.const.js +3 -0
  90. package/src/components/logoButton/logo-button.js +30 -0
  91. package/src/components/logoButton/logo-button.scss +15 -0
  92. package/src/components/playlist/components/playlist-button.js +34 -0
  93. package/src/components/playlist/components/playlist-next-button.js +18 -0
  94. package/src/components/playlist/components/playlist-previous-button.js +18 -0
  95. package/src/components/playlist/components/playlist.js +5 -0
  96. package/src/components/playlist/components/playlist.scss +15 -0
  97. package/src/components/playlist/components/upcoming-video-overlay.js +149 -0
  98. package/src/components/playlist/components/upcoming-video-overlay.scss +86 -0
  99. package/src/components/playlist/layout/playlist-layout-custom.js +21 -0
  100. package/src/components/playlist/layout/playlist-layout-horizontal.js +16 -0
  101. package/src/components/playlist/layout/playlist-layout-vertical.js +19 -0
  102. package/src/components/playlist/layout/playlist-layout.js +110 -0
  103. package/src/components/playlist/panel/playlist-panel-item.js +86 -0
  104. package/src/components/playlist/panel/playlist-panel.js +92 -0
  105. package/src/components/playlist/playlist-widget.js +119 -0
  106. package/src/components/playlist/playlist.const.js +14 -0
  107. package/src/components/playlist/playlist.js +413 -0
  108. package/src/components/playlist/thumbnail/thumbnail.js +69 -0
  109. package/src/components/progress-control-events-blocker/progress-control-events-blocker.js +17 -0
  110. package/src/components/qualitySelector/quality-selector.scss +10 -0
  111. package/src/components/qualitySelector/qualitySelector.js +152 -0
  112. package/src/components/recommendations-overlay/index.js +3 -0
  113. package/src/components/recommendations-overlay/recommendations-overlay-content.js +57 -0
  114. package/src/components/recommendations-overlay/recommendations-overlay-hide-button.js +18 -0
  115. package/src/components/recommendations-overlay/recommendations-overlay-item.js +35 -0
  116. package/src/components/recommendations-overlay/recommendations-overlay-primary-item.js +81 -0
  117. package/src/components/recommendations-overlay/recommendations-overlay-secondary-item.js +48 -0
  118. package/src/components/recommendations-overlay/recommendations-overlay-secondary-items-container.js +35 -0
  119. package/src/components/recommendations-overlay/recommendations-overlay.js +94 -0
  120. package/src/components/recommendations-overlay/recommendations-overlay.scss +182 -0
  121. package/src/components/shoppable-bar/layout/bar-layout.js +111 -0
  122. package/src/components/shoppable-bar/layout/shoppable-panel-toggle.js +64 -0
  123. package/src/components/shoppable-bar/layout/shoppable-products-overlay.js +87 -0
  124. package/src/components/shoppable-bar/panel/shoppable-panel-item.js +105 -0
  125. package/src/components/shoppable-bar/panel/shoppable-panel.js +172 -0
  126. package/src/components/shoppable-bar/shoppable-post-widget.js +110 -0
  127. package/src/components/shoppable-bar/shoppable-widget.const.js +52 -0
  128. package/src/components/shoppable-bar/shoppable-widget.js +111 -0
  129. package/src/components/shoppable-bar/shoppable-widget.scss +359 -0
  130. package/src/components/themeButton/themedButton.const.js +3 -0
  131. package/src/components/themeButton/themedButton.js +25 -0
  132. package/src/components/title-bar/title-bar.js +79 -0
  133. package/src/config/defaults.js +25 -0
  134. package/src/extended-events.js +228 -0
  135. package/src/index.js +18 -0
  136. package/src/mixins/eventable.js +54 -0
  137. package/src/mixins/playlistable.js +106 -0
  138. package/src/plugins/analytics/index.js +245 -0
  139. package/src/plugins/autoplay-on-scroll/index.js +86 -0
  140. package/src/plugins/cloudinary/common.js +216 -0
  141. package/src/plugins/cloudinary/event-handler-registry.js +46 -0
  142. package/src/plugins/cloudinary/index.js +345 -0
  143. package/src/plugins/cloudinary/models/audio-source/audio-source.const.js +11 -0
  144. package/src/plugins/cloudinary/models/audio-source/audio-source.js +82 -0
  145. package/src/plugins/cloudinary/models/base-source.js +107 -0
  146. package/src/plugins/cloudinary/models/image-source.js +26 -0
  147. package/src/plugins/cloudinary/models/video-source/video-source.const.js +32 -0
  148. package/src/plugins/cloudinary/models/video-source/video-source.js +239 -0
  149. package/src/plugins/cloudinary/models/video-source/video-source.utils.js +57 -0
  150. package/src/plugins/colors/index.js +303 -0
  151. package/src/plugins/context-menu/components/context-menu-item.js +12 -0
  152. package/src/plugins/context-menu/components/context-menu.js +63 -0
  153. package/src/plugins/context-menu/context-menu.scss +30 -0
  154. package/src/plugins/context-menu/contextMenuContent.js +53 -0
  155. package/src/plugins/context-menu/index.js +134 -0
  156. package/src/plugins/dash/index.js +26 -0
  157. package/src/plugins/dash/setup-audio-tracks.js +112 -0
  158. package/src/plugins/dash/setup-text-tracks.js +195 -0
  159. package/src/plugins/dash/videojs-dash.js +372 -0
  160. package/src/plugins/floating-player/floating-player.scss +74 -0
  161. package/src/plugins/floating-player/index.js +129 -0
  162. package/src/plugins/ima/index.js +1775 -0
  163. package/src/plugins/index.js +31 -0
  164. package/src/plugins/interactive-plugin/index.js +10 -0
  165. package/src/plugins/videojs-http-source-selector/components/SourceMenuButton.js +98 -0
  166. package/src/plugins/videojs-http-source-selector/components/SourceMenuItem.js +52 -0
  167. package/src/plugins/videojs-http-source-selector/plugin.js +82 -0
  168. package/src/plugins/videojs-http-source-selector/plugin.scss +9 -0
  169. package/src/plugins/vtt-thumbnails/index.js +526 -0
  170. package/src/plugins/vtt-thumbnails/vtt-thumbnails.scss +29 -0
  171. package/src/utils/api.js +32 -0
  172. package/src/utils/apply-with-props.js +32 -0
  173. package/src/utils/array.js +22 -0
  174. package/src/utils/assign.js +27 -0
  175. package/src/utils/attributes-normalizer.js +72 -0
  176. package/src/utils/cloudinary.js +165 -0
  177. package/src/utils/css-prefix.js +43 -0
  178. package/src/utils/dom.js +74 -0
  179. package/src/utils/find.js +28 -0
  180. package/src/utils/fontFace.js +25 -0
  181. package/src/utils/groupBy.js +12 -0
  182. package/src/utils/index.js +29 -0
  183. package/src/utils/matches.js +11 -0
  184. package/src/utils/mixin.js +5 -0
  185. package/src/utils/object.js +26 -0
  186. package/src/utils/playButton.js +9 -0
  187. package/src/utils/positioning.js +78 -0
  188. package/src/utils/querystring.js +12 -0
  189. package/src/utils/slicing.js +21 -0
  190. package/src/utils/string.js +15 -0
  191. package/src/utils/throttle.js +30 -0
  192. package/src/utils/time.js +77 -0
  193. package/src/utils/type-inference.js +35 -0
  194. package/src/validators/validators-functions.js +48 -0
  195. package/src/validators/validators-types.js +78 -0
  196. package/src/validators/validators.js +110 -0
  197. package/src/video-player.const.js +68 -0
  198. package/src/video-player.js +761 -0
  199. package/src/video-player.utils.js +123 -0
  200. package/test/adaptive-streaming.test.js +38 -0
  201. package/test/ads.test.js +35 -0
  202. package/test/analytics.test.js +111 -0
  203. package/test/api.test.js +111 -0
  204. package/test/autoplay.scroll.test.js +23 -0
  205. package/test/basic-ui.test.js +59 -0
  206. package/test/colors.test.js +58 -0
  207. package/test/components.test.js +21 -0
  208. package/test/custom-error.test.js +24 -0
  209. package/test/fluid.test.js +36 -0
  210. package/test/isValidConfig.test.js +224 -0
  211. package/test/mocks/cloudinary-core-mock.js +0 -0
  212. package/test/mocks/styleMock.js +1 -0
  213. package/test/multiplayer.test.js +25 -0
  214. package/test/playlist.test.js +60 -0
  215. package/test/puppeteer/vp-env.js +19 -0
  216. package/test/recommendations.test.js +38 -0
  217. package/test/title-bar.test.js +28 -0
  218. package/test/ui-conf.test.js +49 -0
  219. package/test/unit/cloudinaryConfig.test.js +22 -0
  220. package/test/unit/cloudinaryUtils.test.js +53 -0
  221. package/test/unit/utils.test.js +27 -0
  222. package/test/unit/videoSource.test.js +454 -0
  223. package/tsconfig.json +15 -0
  224. package/types/video-player-tests.js +12 -0
  225. package/types/video-player-tests.ts +31 -0
  226. package/types/video-player.d.ts +570 -0
@@ -0,0 +1,303 @@
1
+ import { assign } from 'utils/assign';
2
+ import { playerClassPrefix } from 'utils/css-prefix';
3
+ import { isLight } from '../../video-player.utils';
4
+
5
+ const playerColors = `
6
+ .PLAYER-CLASS-PREFIX {
7
+ --color-accent: --accent-color;
8
+ --color-base: --base-color;
9
+ --color-text: --text-color;
10
+
11
+ color: --text-color;
12
+ }
13
+
14
+ .PLAYER-CLASS-PREFIX .vjs-time-tooltip,
15
+ .PLAYER-CLASS-PREFIX .vjs-mouse-display:after,
16
+ .PLAYER-CLASS-PREFIX .vjs-play-progress:after {
17
+ color: --base-color;
18
+ background-color: --text-color;
19
+ }
20
+
21
+ .PLAYER-CLASS-PREFIX .vjs-slider {
22
+ background-color: rgba(--accent-color, 0.3);
23
+ }
24
+
25
+ .PLAYER-CLASS-PREFIX .vjs-load-progress,
26
+ .PLAYER-CLASS-PREFIX .vjs-load-progress div {
27
+ background: rgba(--accent-color, 0.2);
28
+ }
29
+
30
+ .PLAYER-CLASS-PREFIX .vjs-volume-level,
31
+ .PLAYER-CLASS-PREFIX .vjs-play-progress {
32
+ background: --accent-color;
33
+ }
34
+
35
+ .PLAYER-CLASS-PREFIX .vjs-volume-vertical {
36
+ background-color: rgba(--base-color, 0.7);
37
+ }
38
+
39
+ .PLAYER-CLASS-PREFIX .vjs-volume-panel-horizontal .vjs-control:before {
40
+ border-color: transparent transparent rgba(--accent-color, 0.4) transparent;
41
+ }
42
+
43
+ .PLAYER-CLASS-PREFIX .vjs-volume-panel-horizontal .vjs-volume-level:before {
44
+ border-color: transparent transparent --accent-color transparent;
45
+ }
46
+
47
+ .PLAYER-CLASS-PREFIX .vjs-title-bar {
48
+ color: --text-color;
49
+ }
50
+
51
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay {
52
+ color: --text-color;
53
+ background-color: rgba(--base-color, 0.4);
54
+ }
55
+
56
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item {
57
+ box-shadow: 0 0.5em 1.2em 0px --base-color;
58
+ color: --text-color;
59
+ border: 1px solid --text-color !important;
60
+ position: relative;
61
+ }
62
+
63
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item:active,
64
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item:hover {
65
+ border: 1px solid --accent-color !important;
66
+ }
67
+
68
+ .PLAYER-CLASS-PREFIX .vjs-context-menu-ui .vjs-menu-content .vjs-menu-item:active,
69
+ .PLAYER-CLASS-PREFIX .vjs-context-menu-ui .vjs-menu-content .vjs-menu-item:hover {
70
+ color: --text-color;
71
+ background-color: --accent-color;
72
+ }
73
+
74
+ .PLAYER-CLASS-PREFIX.vjs-ad-playing .vjs-progress-control .vjs-play-progress {
75
+ background: --base-color;
76
+ }
77
+
78
+ .PLAYER-CLASS-PREFIX.cld-plw-layout {
79
+ background-color: --base-color;
80
+ }
81
+
82
+ .PLAYER-CLASS-PREFIX .cld-plw-item-info-wrap {
83
+ color: --text-color;
84
+ }
85
+
86
+ .PLAYER-CLASS-PREFIX .cld-plw-panel-item {
87
+ border-color: --text-color;
88
+ }
89
+
90
+ .PLAYER-CLASS-PREFIX .cld-video-player-floater-close polygon {
91
+ fill: --base-color;
92
+ }
93
+
94
+ .PLAYER-CLASS-PREFIX .cld-spbl-product-hotspot:after {
95
+ background: --base-color;
96
+ box-shadow: 0 0 0 4px --accent-color, 0 0 0 8px rgba(--text-color, 0.24);
97
+ }
98
+
99
+ .PLAYER-CLASS-PREFIX .cld-spbl-product-tooltip {
100
+ color: --base-color;
101
+ background: --text-color;
102
+ }
103
+
104
+ .PLAYER-CLASS-PREFIX .base-color-semi-bg {
105
+ background: rgba(--base-color, 0.7);
106
+ }
107
+
108
+ .PLAYER-CLASS-PREFIX .text-color-semi-bg {
109
+ background: rgba(--text-color, 0.7);
110
+ }
111
+
112
+ .PLAYER-CLASS-PREFIX .text-color-text {
113
+ color: --text-color;
114
+ }
115
+
116
+ .PLAYER-CLASS-PREFIX .base-color-text {
117
+ color: --base-color;
118
+ }
119
+
120
+ .PLAYER-CLASS-PREFIX .accent-color-text {
121
+ color: --accent-color;
122
+ }
123
+ `;
124
+
125
+ const darkOnlyColors = `
126
+
127
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-dark .base-color-bg,
128
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-dark .vjs-control-bar,
129
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-dark .vjs-big-play-button,
130
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-dark .vjs-menu-button
131
+ .vjs-menu-content {
132
+ background-color: rgba(--base-color, 0.6);
133
+ }
134
+
135
+ .PLAYER-CLASS-PREFIX .vjs-title-bar {
136
+ background-image: linear-gradient(--base-color, rgba(255, 255, 255, 0) 100%);
137
+ }
138
+
139
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-primary .vjs-recommendations-overlay-item-primary-content {
140
+ background-color: rgba(--base-color, 0.6);
141
+ }
142
+
143
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-secondary div {
144
+ background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent 80%);
145
+ }
146
+
147
+ .PLAYER-CLASS-PREFIX .vjs-upcoming-video {
148
+ border: 1px solid rgba(--text-color, 0.5);
149
+ }
150
+
151
+ .PLAYER-CLASS-PREFIX .vjs-upcoming-video .vjs-upcoming-video-bar {
152
+ background-color: rgba(--base-color, 0.6);
153
+ }
154
+
155
+ .PLAYER-CLASS-PREFIX .vjs-context-menu-ui .vjs-menu-content {
156
+ background-color: rgba(--base-color, 0.6);
157
+ }
158
+ `;
159
+
160
+ const lightOnlyColors = `
161
+ .PLAYER-CLASS-PREFIX .vjs-title-bar {
162
+ flex-direction: row;
163
+ justify-content: left;
164
+ height: 3.6em;
165
+ background: --base-color;
166
+ }
167
+
168
+ .PLAYER-CLASS-PREFIX .vjs-title-bar div {
169
+ width: auto;
170
+ padding: 0 inherit;
171
+ margin: 0;
172
+ }
173
+
174
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-light .base-color-bg,
175
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-light .vjs-control-bar,
176
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-light .vjs-big-play-button,
177
+ .PLAYER-CLASS-PREFIX.cld-video-player-skin-light .vjs-menu-button .vjs-menu-content {
178
+ background-color: --base-color;
179
+ }
180
+
181
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-primary .vjs-recommendations-overlay-item-primary-content {
182
+ background-color: --base-color;
183
+ }
184
+
185
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-primary:active .vjs-recommendations-overlay-item-primary-content,
186
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-primary:hover .vjs-recommendations-overlay-item-primary-content {
187
+ color: --base-color;
188
+ background-color: rgba(--accent-color, 0.8);
189
+ }
190
+
191
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-secondary:active div,
192
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-secondary:hover div {
193
+ color: --base-color;
194
+ background-color: rgba(--accent-color, 0.8);
195
+ }
196
+
197
+ .PLAYER-CLASS-PREFIX .vjs-recommendations-overlay .vjs-recommendations-overlay-item.vjs-recommendations-overlay-item-secondary div {
198
+ background: --base-color;
199
+ }
200
+
201
+ .PLAYER-CLASS-PREFIX .vjs-upcoming-video {
202
+ border: 1px solid --text-color;
203
+ }
204
+
205
+ .PLAYER-CLASS-PREFIX .vjs-upcoming-video .vjs-upcoming-video-bar {
206
+ background-color: --base-color;
207
+ }
208
+
209
+ .PLAYER-CLASS-PREFIX .vjs-context-menu-ui .vjs-menu-content {
210
+ background-color: --base-color;
211
+ }
212
+
213
+ .PLAYER-CLASS-PREFIX .cld-plw-item-info-wrap {
214
+ color: --text-color;
215
+ }
216
+
217
+ @media only screen and (max-width: 768px) {
218
+ .PLAYER-CLASS-PREFIX.cld-plw-vertical .cld-plw-item-info-wrap {
219
+ color: --accent-color;
220
+ }
221
+ }
222
+ `;
223
+
224
+ const defaults = {
225
+ colorsDark: {
226
+ 'base': '#000000',
227
+ 'accent': '#FF620C',
228
+ 'text': '#FFFFFF'
229
+ },
230
+ colorsLight: {
231
+ 'base': '#FFFFFF',
232
+ 'accent': '#0078FF',
233
+ 'text': '#0E2F5A'
234
+ }
235
+ };
236
+
237
+ export const getDefaultPlayerColor = (options) => {
238
+ return isLight(options) ? defaults.colorsLight : defaults.colorsDark;
239
+ };
240
+
241
+ class Colors {
242
+ constructor(player, opts = {}) {
243
+ this.player = player;
244
+
245
+ const skinDefaults = getDefaultPlayerColor(this.player.options_);
246
+
247
+ opts.colors = assign({}, skinDefaults, opts.colors);
248
+
249
+ this.init = () => {
250
+ injectCSS(parseStyles(playerColors));
251
+
252
+ if (this.player.options_.skin === 'light') {
253
+ injectCSS(parseStyles(lightOnlyColors));
254
+ } else {
255
+ injectCSS(parseStyles(darkOnlyColors));
256
+ }
257
+ };
258
+
259
+ const injectCSS = (css) => {
260
+ const style = document.createElement('style');
261
+ style.innerHTML = css;
262
+ this.player.el_.appendChild(style);
263
+ };
264
+
265
+ const hexToRgb = (hex) => {
266
+
267
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
268
+ const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
269
+ hex = hex.replace(shorthandRegex, function(m, r, g, b) {
270
+ return r + r + g + g + b + b;
271
+ });
272
+
273
+ // '#0080C0' to '0, 128, 192'
274
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
275
+
276
+ return result
277
+ ? parseInt(result[1], 16) + ', ' +
278
+ parseInt(result[2], 16) + ', ' +
279
+ parseInt(result[3], 16)
280
+ : null;
281
+ };
282
+
283
+ const parseStyles = (styles) => {
284
+ const parsed = styles
285
+ // wrapper class
286
+ .replace(/PLAYER\-CLASS\-PREFIX/g, playerClassPrefix(this.player))
287
+ // rgba first
288
+ .replace(/rgba\(\-\-base\-color/g, 'rgba(' + hexToRgb(opts.colors.base))
289
+ .replace(/rgba\(\-\-accent\-color/g, 'rgba(' + hexToRgb(opts.colors.accent))
290
+ .replace(/rgba\(\-\-text\-color/g, 'rgba(' + hexToRgb(opts.colors.text))
291
+ // solid colors
292
+ .replace(/\-\-base\-color/g, opts.colors.base)
293
+ .replace(/\-\-accent\-color/g, opts.colors.accent)
294
+ .replace(/\-\-text\-color/g, opts.colors.text);
295
+ return parsed;
296
+ };
297
+
298
+ }
299
+ }
300
+
301
+ export default function(opts = {}) {
302
+ new Colors(this, opts).init();
303
+ }
@@ -0,0 +1,12 @@
1
+ import videojs from 'video.js';
2
+
3
+ const MenuItem = videojs.getComponent('MenuItem');
4
+
5
+ class ContextMenuItem extends MenuItem {
6
+ handleClick() {
7
+ super.handleClick();
8
+ this.options_.listener();
9
+ }
10
+ }
11
+
12
+ export default ContextMenuItem;
@@ -0,0 +1,63 @@
1
+ import videojs from 'video.js';
2
+ import ContextMenuItem from './context-menu-item';
3
+ import { setPosition } from '../../../utils/positioning';
4
+ import { isFunction } from '../../../utils/type-inference';
5
+
6
+ const Menu = videojs.getComponent('Menu');
7
+
8
+ // support VJS5 & VJS6 at the same time
9
+ const dom = videojs.dom || videojs;
10
+
11
+ class ContextMenu extends Menu {
12
+
13
+ constructor(player, options) {
14
+ super(player, options);
15
+
16
+ // Each menu component has its own `dispose` method that can be
17
+ // safely bound and unbound to events while maintaining its context.
18
+ this.dispose = videojs.bind(this, this.dispose);
19
+
20
+ options.content.forEach(c => {
21
+ let fn = null;
22
+
23
+ if (isFunction(c.listener)) {
24
+ fn = c.listener;
25
+ } else if (typeof c.href === 'string') {
26
+ fn = () => window.open(c.href);
27
+ } else {
28
+ fn = () => true;
29
+ }
30
+
31
+ const that = this;
32
+
33
+ this.addItem(new ContextMenuItem(player, {
34
+ label: c.label,
35
+ listener: videojs.bind(player, function() {
36
+ fn(this);
37
+ window.setTimeout(() => {
38
+ that.dispose();
39
+ }, 1);
40
+ })
41
+ }));
42
+ });
43
+ }
44
+
45
+ setPosition(left, top) {
46
+ setPosition(this.el(), left, top);
47
+ }
48
+
49
+ createEl() {
50
+ const el = super.createEl();
51
+
52
+ dom.addClass(el, 'vjs-context-menu-ui');
53
+
54
+ if (this.options_.position) {
55
+ const { left, top } = this.options_.position;
56
+ this.setPosition(left, top);
57
+ }
58
+
59
+ return el;
60
+ }
61
+ }
62
+
63
+ export default ContextMenu;
@@ -0,0 +1,30 @@
1
+ .vjs-context-menu-ui {
2
+ position: absolute;
3
+ z-index: 2;
4
+
5
+ .vjs-menu-content {
6
+ background: rgba(0,0,0,.6);
7
+ border-radius: 0.2em;
8
+ padding: 0;
9
+ }
10
+
11
+ .vjs-menu-item {
12
+ // Override video.js styles for menus
13
+ font-size: 1em;
14
+ line-height: 1em;
15
+ text-transform: none;
16
+
17
+ cursor: pointer;
18
+ margin: 0;
19
+ padding: 0.8em 1.4em;
20
+
21
+ &:active, &:hover {
22
+ background-color: rgba(0, 0, 0, 0.5);
23
+ }
24
+ }
25
+
26
+ .player-version {
27
+ font-size: 80%;
28
+ opacity: .7;
29
+ }
30
+ }
@@ -0,0 +1,53 @@
1
+ const contextMenuContent = (player) => {
2
+
3
+ const isLooping = player.loop();
4
+ const isPaused = player.paused();
5
+ const isMuted = player.muted();
6
+ const isFullscreen = player.isFullscreen();
7
+
8
+ const aboutMenuItem = {
9
+ label: '<span class="player-version">Cloudinary Player v' + VERSION + '</span>'
10
+ };
11
+
12
+ if (!player.controls()) {
13
+ return [aboutMenuItem];
14
+ }
15
+
16
+ return [
17
+ {
18
+ label: isLooping ? 'Unloop' : 'Loop',
19
+ listener: () => {
20
+ player.loop(!isLooping);
21
+ }
22
+ },
23
+ {
24
+ label: isPaused ? 'Play' : 'Pause',
25
+ listener: () => {
26
+ if (isPaused) {
27
+ player.play();
28
+ } else {
29
+ player.pause();
30
+ }
31
+ }
32
+ },
33
+ {
34
+ label: isMuted ? 'Unmute' : 'Mute',
35
+ listener: () => {
36
+ player.muted(!isMuted);
37
+ }
38
+ },
39
+ {
40
+ label: isFullscreen ? 'Exit Fullscreen' : 'Fullscreen',
41
+ listener: () => {
42
+ if (isFullscreen) {
43
+ player.exitFullscreen();
44
+ } else {
45
+ player.requestFullscreen();
46
+ }
47
+ }
48
+ },
49
+ aboutMenuItem
50
+ ];
51
+ };
52
+
53
+ export default contextMenuContent;
@@ -0,0 +1,134 @@
1
+ import videojs from 'video.js';
2
+ import './context-menu.scss';
3
+ import 'videojs-contextmenu';
4
+ import ContextMenu from './components/context-menu';
5
+ import { getPointerPosition } from 'utils/positioning';
6
+ import { sliceProperties } from 'utils/slicing';
7
+ import { assign } from 'utils/assign';
8
+ import { isFunction } from '../../utils/type-inference';
9
+
10
+ const defaults = {
11
+ showNativeOnRecurringEvent: false
12
+ };
13
+
14
+ class ContextMenuPlugin {
15
+
16
+ constructor(player, initOpts) {
17
+ if (!Array.isArray(initOpts.content) && !isFunction(initOpts.content)) {
18
+ throw new Error('"content" required');
19
+ }
20
+
21
+ const opts = assign({}, defaults, initOpts);
22
+
23
+ this.player = player;
24
+ const _options = sliceProperties(opts, 'content', 'showNativeOnRecurringEvent');
25
+
26
+ this.init = () => {
27
+ // If we are not already providing "vjs-contextmenu" events, do so.
28
+ this.player.contextmenu();
29
+ this.player.on('vjs-contextmenu', onContextMenu);
30
+ this.player.ready(() => this.player.addClass('vjs-context-menu'));
31
+ };
32
+
33
+ const getMenuPosition = (e) => {
34
+ // Calc menu size
35
+ const menuEl = this.menu.el();
36
+
37
+ // Must append to element to get bounding rect
38
+ menuEl.style.visibility = 'hidden';
39
+ this.player.el().appendChild(menuEl);
40
+ const menuSize = menuEl.getBoundingClientRect();
41
+ this.player.el().removeChild(menuEl);
42
+ menuEl.style.visibility = 'visible';
43
+
44
+ const ptrPosition = getPointerPosition(this.player.el(), e);
45
+ const playerSize = this.player.el().getBoundingClientRect();
46
+
47
+ let ptrTop = playerSize.height - (playerSize.height * ptrPosition.y) + 1;
48
+ let ptrLeft = Math.round(playerSize.width * ptrPosition.x) + 1;
49
+
50
+ let top = ptrTop;
51
+ let left = ptrLeft;
52
+
53
+ // Correct top when menu can't fit fully height-wise when pointer is at it's top left corner
54
+ if (ptrTop + menuSize.height > playerSize.height) {
55
+ let difference = ptrTop + menuSize.height - playerSize.height;
56
+ top = difference > menuSize.height / 2 ? ptrTop - menuSize.height - 1 : playerSize.height - menuSize.height;
57
+ }
58
+
59
+ // Correct left where menu can't fit fully width-wise when pointer is at it's top left corner
60
+ if (ptrLeft + menuSize.width > playerSize.width) {
61
+ let difference = ptrLeft + menuSize.width - playerSize.width;
62
+ left = difference > menuSize.width / 2 ? ptrLeft - menuSize.width - 1 : playerSize.width - menuSize.width;
63
+ }
64
+
65
+ // Correct top and left in cases that menu is positioned on the pointer
66
+ if (top < ptrTop && left < ptrLeft) {
67
+ top = ptrTop - menuSize.height - 1;
68
+ left = ptrLeft - menuSize.width - 1;
69
+ }
70
+
71
+ // Make sure that we're still in bounds after the corrections.
72
+ top = Math.max(0, top);
73
+ left = Math.max(0, left);
74
+
75
+ return { left, top };
76
+ };
77
+
78
+ const onContextMenu = (e) => {
79
+ if (this.menu) {
80
+ this.menu.dispose();
81
+ if (_options.showNativeOnRecurringEvent) {
82
+ // If this event happens while the custom menu is open, close it and do
83
+ // nothing else. This will cause native contextmenu events to be intercepted
84
+ // once again; so, the next time a contextmenu event is encountered, we'll
85
+ // open the custom menu.
86
+ return;
87
+ }
88
+ }
89
+
90
+ // Stop canceling the native contextmenu event until further notice.
91
+ if (_options.showNativeOnRecurringEvent) {
92
+ this.player.contextmenu.options.cancel = false;
93
+ }
94
+
95
+ e.preventDefault();
96
+
97
+ // Allow dynamically setting the menu labels based on player
98
+ let content = _options.content;
99
+
100
+ if (isFunction(content)) {
101
+ content = content(this.player);
102
+ }
103
+
104
+ this.menu = new ContextMenu(this.player, { content });
105
+
106
+ const { left, top } = getMenuPosition(e);
107
+ this.menu.setPosition(left, top);
108
+
109
+ // This is to handle a bug where firefox triggers both 'contextmenu' and 'click'
110
+ // events on rightclick, causing menu to open and then immediately close.
111
+ const clickHandler = (_e) => {
112
+ if (!(_e.type === 'click' && (_e.which === 3 || _e.button === 2))) {
113
+ this.menu.dispose();
114
+ }
115
+ };
116
+
117
+ this.menu.on('dispose', () => {
118
+ // Begin canceling contextmenu events again, so subsequent events will
119
+ // cause the custom menu to be displayed again.
120
+ this.player.contextmenu.options.cancel = true;
121
+ this.player.removeChild(this.menu);
122
+ videojs.off(document, ['click', 'tap'], clickHandler);
123
+ delete this.menu;
124
+ });
125
+
126
+ this.player.addChild(this.menu);
127
+ videojs.on(document, ['click', 'tap'], clickHandler);
128
+ };
129
+ }
130
+ }
131
+
132
+ export default function(opts = {}) {
133
+ new ContextMenuPlugin(this, opts).init();
134
+ }
@@ -0,0 +1,26 @@
1
+ import videojs from 'video.js';
2
+ import djs from 'dashjs';
3
+ // eslint-disable-next-line no-unused-vars
4
+ import Html5DashJS from 'plugins/dash/videojs-dash';
5
+
6
+ export default function dashPlugin() {
7
+
8
+ const dashInit = (player, mediaPlayer) => {
9
+ // eslint-disable-next-line new-cap
10
+ mediaPlayer = djs.MediaPlayer().create();
11
+ let settings = {
12
+ streaming: {
13
+ liveDelayFragmentCount: null
14
+ }
15
+ };
16
+ mediaPlayer.updateSettings(settings);
17
+ mediaPlayer.on(djs.MediaPlayer.events.PLAYBACK_STALLED, (a) => {
18
+ console.log(a);
19
+ console.log('stalled');
20
+ });
21
+ };
22
+
23
+ // Triggered on 'beforeinitialize'
24
+ videojs.Html5DashJS.hook('beforeinitialize', dashInit);
25
+
26
+ }