@gcorevideo/player 2.28.25 → 2.28.26

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 (143) hide show
  1. package/dist/core.js +38 -32
  2. package/dist/index.css +223 -223
  3. package/dist/index.embed.js +95 -38
  4. package/dist/index.js +227 -122
  5. package/lib/Player.d.ts.map +1 -1
  6. package/lib/index.core.d.ts +1 -1
  7. package/lib/index.core.d.ts.map +1 -1
  8. package/lib/index.core.js +1 -1
  9. package/lib/index.plugins.d.ts +34 -34
  10. package/lib/index.plugins.d.ts.map +1 -1
  11. package/lib/index.plugins.js +34 -34
  12. package/lib/playback/types.d.ts.map +1 -1
  13. package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
  14. package/lib/plugins/bottom-gear/BottomGear.js +3 -1
  15. package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -1
  16. package/lib/plugins/clappr-nerd-stats/speedtest/index.js +9 -5
  17. package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -1
  18. package/lib/plugins/clappr-nerd-stats/utils.d.ts +2 -2
  19. package/lib/plugins/clips/utils.d.ts.map +1 -1
  20. package/lib/plugins/cmcd-config/CmcdConfig.js +1 -1
  21. package/lib/plugins/favicon/Favicon.d.ts.map +1 -1
  22. package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -1
  23. package/lib/plugins/google-analytics/GoogleAnalytics.js +10 -3
  24. package/lib/plugins/kibo/index.d.ts.map +1 -1
  25. package/lib/plugins/kibo/index.js +69 -20
  26. package/lib/plugins/level-selector/QualityLevels.js +2 -2
  27. package/lib/plugins/logo/Logo.d.ts.map +1 -1
  28. package/lib/plugins/logo/Logo.js +19 -15
  29. package/lib/plugins/logo/utils/index.d.ts.map +1 -1
  30. package/lib/plugins/logo/utils/index.js +11 -7
  31. package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
  32. package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -1
  33. package/lib/plugins/multi-camera/MultiCamera.js +42 -20
  34. package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -1
  35. package/lib/plugins/picture-in-picture/PictureInPicture.js +3 -2
  36. package/lib/plugins/share/Share.d.ts.map +1 -1
  37. package/lib/plugins/share/Share.js +17 -12
  38. package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -1
  39. package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -1
  40. package/lib/plugins/subtitles/ClosedCaptions.d.ts.map +1 -1
  41. package/lib/plugins/subtitles/ClosedCaptions.js +4 -3
  42. package/lib/plugins/thumbnails/Thumbnails.js +2 -3
  43. package/lib/plugins/thumbnails/utils.d.ts.map +1 -1
  44. package/lib/plugins/utils/fullscreen.d.ts.map +1 -1
  45. package/lib/plugins/utils.d.ts.map +1 -1
  46. package/lib/plugins/utils.js +1 -1
  47. package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -1
  48. package/lib/plugins/vast-ads/VastAds.js +2 -1
  49. package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -1
  50. package/lib/plugins/vast-ads/loaderxml.js +8 -5
  51. package/lib/plugins/vast-ads/roll.d.ts +2 -2
  52. package/lib/plugins/vast-ads/roll.d.ts.map +1 -1
  53. package/lib/plugins/vast-ads/roll.js +16 -10
  54. package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -1
  55. package/lib/plugins/vast-ads/rollmanager.js +17 -7
  56. package/lib/plugins/vast-ads/sctemanager.d.ts +1 -1
  57. package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -1
  58. package/lib/plugins/vast-ads/sctemanager.js +6 -5
  59. package/lib/plugins/vast-ads/types.d.ts.map +1 -1
  60. package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -1
  61. package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -1
  62. package/lib/plugins/vast-ads/xmlhttprequest.js +3 -2
  63. package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -1
  64. package/lib/plugins/vast-ads/xmlmerge.js +4 -3
  65. package/lib/types.d.ts +1 -1
  66. package/lib/types.d.ts.map +1 -1
  67. package/lib/utils/clickaway.d.ts.map +1 -1
  68. package/lib/utils/mediaSources.d.ts.map +1 -1
  69. package/lib/utils/mediaSources.js +1 -3
  70. package/lib/utils/types.d.ts.map +1 -1
  71. package/lib/version.js +2 -2
  72. package/package.json +2 -2
  73. package/src/Player.ts +10 -10
  74. package/src/__tests__/Player.test.ts +33 -10
  75. package/src/index.core.ts +9 -1
  76. package/src/index.plugins.ts +35 -35
  77. package/src/playback/BasePlayback.ts +1 -1
  78. package/src/playback/__tests__/HTML5Video.test.ts +10 -4
  79. package/src/playback/dash-playback/__tests__/DashPlayback.test.ts +10 -38
  80. package/src/playback/hls-playback/__tests__/HlsPlayback.test.ts +12 -45
  81. package/src/playback/types.ts +0 -1
  82. package/src/playback.types.ts +1 -2
  83. package/src/plugins/audio-selector/AudioTracks.ts +1 -1
  84. package/src/plugins/audio-selector/__tests__/AudioTracks.test.ts +30 -11
  85. package/src/plugins/bottom-gear/BottomGear.ts +3 -2
  86. package/src/plugins/clappr-nerd-stats/NerdStats.ts +1 -1
  87. package/src/plugins/clappr-nerd-stats/speedtest/index.ts +104 -82
  88. package/src/plugins/clappr-nerd-stats/speedtest/types.ts +3 -3
  89. package/src/plugins/clappr-nerd-stats/utils.ts +2 -2
  90. package/src/plugins/clappr-stats/__tests__/ClapprStats.test.ts +30 -18
  91. package/src/plugins/clips/utils.ts +5 -1
  92. package/src/plugins/cmcd-config/CmcdConfig.ts +1 -1
  93. package/src/plugins/error-screen/__tests__/ErrorScreen.test.ts +21 -15
  94. package/src/plugins/favicon/Favicon.ts +73 -49
  95. package/src/plugins/google-analytics/GoogleAnalytics.ts +93 -58
  96. package/src/plugins/kibo/index.ts +183 -109
  97. package/src/plugins/level-selector/QualityLevels.ts +2 -2
  98. package/src/plugins/logo/Logo.ts +134 -105
  99. package/src/plugins/logo/utils/index.ts +27 -20
  100. package/src/plugins/media-control/MediaControl.ts +12 -6
  101. package/src/plugins/multi-camera/MultiCamera.ts +218 -157
  102. package/src/plugins/picture-in-picture/PictureInPicture.ts +41 -37
  103. package/src/plugins/playback-rate/__tests__/PlaybackRate.test.ts +25 -11
  104. package/src/plugins/poster/__tests__/Poster.test.ts +8 -9
  105. package/src/plugins/share/Share.ts +85 -60
  106. package/src/plugins/skip-time/SkipTime.ts +5 -1
  107. package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +8 -5
  108. package/src/plugins/subtitles/ClosedCaptions.ts +7 -5
  109. package/src/plugins/subtitles/__tests__/ClosedCaptions.test.ts +0 -1
  110. package/src/plugins/thumbnails/Thumbnails.ts +22 -21
  111. package/src/plugins/thumbnails/__tests__/Thumbnails.test.ts +14 -7
  112. package/src/plugins/thumbnails/utils.ts +3 -1
  113. package/src/plugins/typings/globals.d.ts +7 -7
  114. package/src/plugins/typings/workers.d.ts +3 -3
  115. package/src/plugins/utils/fullscreen.ts +2 -2
  116. package/src/plugins/utils.ts +17 -13
  117. package/src/plugins/vast-ads/VastAds.ts +4 -5
  118. package/src/plugins/vast-ads/loaderxml.ts +142 -101
  119. package/src/plugins/vast-ads/roll.ts +381 -284
  120. package/src/plugins/vast-ads/rollmanager.ts +214 -170
  121. package/src/plugins/vast-ads/sctemanager.ts +66 -48
  122. package/src/plugins/vast-ads/types.ts +15 -9
  123. package/src/plugins/vast-ads/urlhandler.ts +18 -13
  124. package/src/plugins/vast-ads/xmlhttprequest.ts +25 -20
  125. package/src/plugins/vast-ads/xmlmerge.ts +42 -32
  126. package/src/plugins/video360/VRControls.js +50 -42
  127. package/src/plugins/video360/VREffect.js +298 -206
  128. package/src/plugins/video360/Video360.js +553 -423
  129. package/src/plugins/video360/orbit-oriention-controls.js +526 -421
  130. package/src/plugins/video360/utils.js +18 -18
  131. package/src/types.ts +5 -3
  132. package/src/typings/@clappr/core/error_mixin.d.ts +9 -9
  133. package/src/typings/@clappr/core/index.d.ts +1 -3
  134. package/src/typings/@clappr/core/playback.d.ts +3 -3
  135. package/src/typings/@clappr/index.d.ts +1 -1
  136. package/src/typings/globals.d.ts +15 -15
  137. package/src/utils/__tests__/mediaSources.test.ts +42 -26
  138. package/src/utils/clickaway.ts +24 -24
  139. package/src/utils/errors.ts +2 -2
  140. package/src/utils/mediaSources.ts +5 -4
  141. package/src/utils/types.ts +1 -1
  142. package/src/version.ts +2 -2
  143. package/tsconfig.tsbuildinfo +1 -1
@@ -1,123 +1,135 @@
1
- import { UICorePlugin, Events, Browser, template } from '@clappr/core';
2
- import * as THREE from 'three';
3
- import WebVRPolyfill from 'webvr-polyfill';
4
- import * as utils from './utils';
5
- import OrbitOrientationControls from './orbit-oriention-controls';
6
- import pluginHtml from './public/button.ejs';
7
- import './public/style.scss';
8
- import cardBoard from '../../icons/old/cardboard.svg';
9
-
10
- import { isFullscreen } from '../../utils/utils';
11
- import LogManager from '../../utils/LogManager';
12
- import { VRControls } from './VRControls';
13
- import { VREffect } from './VREffect';
1
+ import { UICorePlugin, Events, Browser, template } from '@clappr/core'
2
+ import * as THREE from 'three'
3
+ import WebVRPolyfill from 'webvr-polyfill'
4
+ import * as utils from './utils'
5
+ import OrbitOrientationControls from './orbit-oriention-controls'
6
+ import pluginHtml from './public/button.ejs'
7
+ import './public/style.scss'
8
+ import cardBoard from '../../icons/old/cardboard.svg'
9
+
10
+ import { isFullscreen } from '../../utils/utils'
11
+ import LogManager from '../../utils/LogManager'
12
+ import { VRControls } from './VRControls'
13
+ import { VREffect } from './VREffect'
14
14
 
15
15
  export default class Video360 extends UICorePlugin {
16
16
  get name() {
17
- return 'video_360';
17
+ return 'video_360'
18
18
  }
19
19
 
20
20
  get supportedVersion() {
21
- return { min: process.env.CLAPPR_VERSION };
21
+ return { min: process.env.CLAPPR_VERSION }
22
22
  }
23
23
 
24
24
  get mediaControl() {
25
- return this.core.mediaControl;
25
+ return this.core.mediaControl
26
26
  }
27
27
 
28
28
  get attributes() {
29
29
  return {
30
- 'class': this.name,
31
- 'data-vr': ''
32
- };
30
+ class: this.name,
31
+ 'data-vr': '',
32
+ }
33
33
  }
34
34
 
35
35
  get events() {
36
36
  return {
37
37
  'click [data-vr-button]': 'onVRChanged',
38
- };
38
+ }
39
39
  }
40
40
 
41
41
  constructor(...args) {
42
- super(...args);
42
+ super(...args)
43
43
  // custom videojs-errors integration boolean
44
44
 
45
45
  // IE 11 does not support enough webgl to be supported
46
46
  // older safari does not support cors, so it wont work
47
47
  if (Browser.isIE || Browser.isIE || !utils.corsSupport) {
48
- console.error('There isn\'t vr');
49
- this.destroy();
48
+ console.error("There isn't vr")
49
+ this.destroy()
50
50
 
51
- return;
51
+ return
52
52
  }
53
53
 
54
- this.active_ = false;
54
+ this.active_ = false
55
55
 
56
- this.polyfill_ = new WebVRPolyfill();
56
+ this.polyfill_ = new WebVRPolyfill()
57
57
 
58
- this.handleResize = this.handleResize.bind(this);
59
- this.handleVrDisplayActivate_ = this.handleVrDisplayActivate_.bind(this);
60
- this.handleVrDisplayDeactivate_ = this.handleVrDisplayDeactivate_.bind(this);
61
- this.handleVrDisplayPresentChange_ = this.handleVrDisplayPresentChange_.bind(this);
62
- this.animate_ = this.animate_.bind(this);
58
+ this.handleResize = this.handleResize.bind(this)
59
+ this.handleVrDisplayActivate_ = this.handleVrDisplayActivate_.bind(this)
60
+ this.handleVrDisplayDeactivate_ = this.handleVrDisplayDeactivate_.bind(this)
61
+ this.handleVrDisplayPresentChange_ =
62
+ this.handleVrDisplayPresentChange_.bind(this)
63
+ this.animate_ = this.animate_.bind(this)
63
64
  }
64
65
 
65
66
  handleResize() {
66
67
  if (!this.container) {
67
- return;
68
+ return
68
69
  }
69
- const width = this.container.$el.width();
70
- const height = this.container.$el.height();
70
+ const width = this.container.$el.width()
71
+ const height = this.container.$el.height()
71
72
 
72
- this.effect && this.effect.setSize(width, height, false);
73
+ this.effect && this.effect.setSize(width, height, false)
73
74
  if (this.camera) {
74
- this.camera.aspect = width / height;
75
- this.camera.updateProjectionMatrix();
75
+ this.camera.aspect = width / height
76
+ this.camera.updateProjectionMatrix()
76
77
  }
77
- this.checkFullscreen();
78
+ this.checkFullscreen()
78
79
  }
79
80
 
80
81
  animate_() {
81
82
  if (!this.initialized_) {
82
- return;
83
+ return
83
84
  }
84
85
  try {
85
- if (!this.activated && this.getVideoEl_() && this.getVideoEl_().readyState === 4) {
86
- this.activated = true;
86
+ if (
87
+ !this.activated &&
88
+ this.getVideoEl_() &&
89
+ this.getVideoEl_().readyState === 4
90
+ ) {
91
+ this.activated = true
87
92
 
88
- return;
93
+ return
89
94
  }
90
- if (this.getVideoEl_() && this.getVideoEl_().readyState === this.getVideoEl_().HAVE_ENOUGH_DATA) {
95
+ if (
96
+ this.getVideoEl_() &&
97
+ this.getVideoEl_().readyState === this.getVideoEl_().HAVE_ENOUGH_DATA
98
+ ) {
91
99
  if (this.videoTexture) {
92
- this.videoTexture.needsUpdate = true;
100
+ this.videoTexture.needsUpdate = true
93
101
  }
94
102
  }
95
103
  } catch (error) {
96
- LogManager.exception(error);
104
+ LogManager.exception(error)
97
105
  }
98
106
 
99
107
  if (this.controls3d) {
100
- this.controls3d.update();
108
+ this.controls3d.update()
101
109
  }
102
110
 
103
- this.effect.render(this.scene, this.camera);
111
+ this.effect.render(this.scene, this.camera)
104
112
 
105
113
  if (window.navigator.getGamepads) {
106
114
  // Grab all gamepads
107
- const gamepads = window.navigator.getGamepads();
115
+ const gamepads = window.navigator.getGamepads()
108
116
 
109
117
  for (let i = 0; i < gamepads.length; ++i) {
110
- const gamepad = gamepads[i];
118
+ const gamepad = gamepads[i]
111
119
 
112
120
  // Make sure gamepad is defined
113
121
  // Only take input if state has changed since we checked last
114
- if (!gamepad || !gamepad.timestamp || gamepad.timestamp === this.prevTimestamps_[i]) {
115
- continue;
122
+ if (
123
+ !gamepad ||
124
+ !gamepad.timestamp ||
125
+ gamepad.timestamp === this.prevTimestamps_[i]
126
+ ) {
127
+ continue
116
128
  }
117
129
  for (let j = 0; j < gamepad.buttons.length; ++j) {
118
130
  if (gamepad.buttons[j].pressed) {
119
- this.prevTimestamps_[i] = gamepad.timestamp;
120
- break;
131
+ this.prevTimestamps_[i] = gamepad.timestamp
132
+ break
121
133
  }
122
134
  }
123
135
  }
@@ -125,66 +137,81 @@ export default class Video360 extends UICorePlugin {
125
137
  }
126
138
 
127
139
  bindEvents() {
128
- this.listenToOnce(this.core, Events.CORE_READY, this.onCoreReady);
140
+ this.listenToOnce(this.core, Events.CORE_READY, this.onCoreReady)
129
141
 
130
142
  if (this.core.mediaControl) {
131
- this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_RENDERED, this.render);
132
- this.listenTo(this.core.mediaControl, Events.MEDIACONTROL_CONTAINERCHANGED, this.containerChanged.bind(this));
143
+ this.listenTo(
144
+ this.core.mediaControl,
145
+ Events.MEDIACONTROL_RENDERED,
146
+ this.render,
147
+ )
148
+ this.listenTo(
149
+ this.core.mediaControl,
150
+ Events.MEDIACONTROL_CONTAINERCHANGED,
151
+ this.containerChanged.bind(this),
152
+ )
133
153
  }
134
154
 
135
- this.listenTo(this.core, 'core:advertisement:start', this.onStartAd);
136
- this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd);
137
- this.listenTo(this.core, Events.CORE_RESIZE, this.handleResize);
155
+ this.listenTo(this.core, 'core:advertisement:start', this.onStartAd)
156
+ this.listenTo(this.core, 'core:advertisement:finish', this.onFinishAd)
157
+ this.listenTo(this.core, Events.CORE_RESIZE, this.handleResize)
138
158
  }
139
159
 
140
160
  bindContainerEvents() {
141
161
  if (this.container) {
142
- this.listenTo(this.container, 'container:destroyed', this.destroy);
162
+ this.listenTo(this.container, 'container:destroyed', this.destroy)
143
163
  this.listenTo(this.container, Events.CONTAINER_LOADEDMETADATA, () => {
144
- this.loadMetadata = true;
145
- });
146
- this.listenTo(this.container, Events.CONTAINER_LOADEDMETADATA, this.init);
164
+ this.loadMetadata = true
165
+ })
166
+ this.listenTo(this.container, Events.CONTAINER_LOADEDMETADATA, this.init)
147
167
  this.listenTo(this.container, Events.CONTAINER_STOP, () => {
148
- this.loadMetadata = false;
149
- });
150
- this.listenTo(this.container, Events.CONTAINER_STOP, this.reset);
151
- this.listenTo(this.container, Events.CONTAINER_FULLSCREEN, this.onFullscreenChange);
168
+ this.loadMetadata = false
169
+ })
170
+ this.listenTo(this.container, Events.CONTAINER_STOP, this.reset)
171
+ this.listenTo(
172
+ this.container,
173
+ Events.CONTAINER_FULLSCREEN,
174
+ this.onFullscreenChange,
175
+ )
152
176
  }
153
177
  }
154
178
 
155
179
  unbindContainerEvents() {
156
180
  if (this.container) {
157
- this.stopListening(this.container, 'container:destroyed');
158
- this.stopListening(this.container, Events.CONTAINER_LOADEDMETADATA);
159
- this.stopListening(this.container, Events.CONTAINER_STOP);
160
- this.stopListening(this.container, Events.CONTAINER_FULLSCREEN);
181
+ this.stopListening(this.container, 'container:destroyed')
182
+ this.stopListening(this.container, Events.CONTAINER_LOADEDMETADATA)
183
+ this.stopListening(this.container, Events.CONTAINER_STOP)
184
+ this.stopListening(this.container, Events.CONTAINER_FULLSCREEN)
161
185
  }
162
186
  }
163
187
 
164
188
  onCoreReady() {
165
- const element = this.findElementBySource(this.options.source);
189
+ const element = this.findElementBySource(this.options.source)
166
190
 
167
191
  if (!this.options.video360) {
168
- this.options.video360 = {};
192
+ this.options.video360 = {}
169
193
  }
170
- this.options.video360.projection = element.projection;
171
- this.container = this.core.activeContainer;
172
- if (window.DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission === 'function') {
194
+ this.options.video360.projection = element.projection
195
+ this.container = this.core.activeContainer
196
+ if (
197
+ window.DeviceOrientationEvent &&
198
+ typeof DeviceOrientationEvent.requestPermission === 'function'
199
+ ) {
173
200
  if (this.container && this.container.$el) {
174
201
  this.container.$el.click(() => {
175
202
  DeviceOrientationEvent.requestPermission()
176
203
  .then(() => {})
177
204
  .catch((error) => {
178
- LogManager.exception(error);
179
- });
180
- });
205
+ LogManager.exception(error)
206
+ })
207
+ })
181
208
  }
182
209
  }
183
210
  }
184
211
 
185
212
  containerChanged() {
186
- this.container = this.core.activeContainer;
187
- const element = this.findElementBySource(this.options.source);
213
+ this.container = this.core.activeContainer
214
+ const element = this.findElementBySource(this.options.source)
188
215
 
189
216
  if (
190
217
  Object.prototype.hasOwnProperty.call(element, 'projection') &&
@@ -192,83 +219,95 @@ export default class Video360 extends UICorePlugin {
192
219
  this.container &&
193
220
  this.container.el
194
221
  ) {
195
- this.container.el.style.touchAction = 'none';
196
- this.container.el.addEventListener('touchmove', function (event) {
197
- event.preventDefault();
198
- }, false);
199
- this.container.playback.el.setAttribute('crossorigin', 'anonymous');
200
- this.unbindContainerEvents();
201
- this.bindContainerEvents();
202
- this.render();
222
+ this.container.el.style.touchAction = 'none'
223
+ this.container.el.addEventListener(
224
+ 'touchmove',
225
+ function (event) {
226
+ event.preventDefault()
227
+ },
228
+ false,
229
+ )
230
+ this.container.playback.el.setAttribute('crossorigin', 'anonymous')
231
+ this.unbindContainerEvents()
232
+ this.bindContainerEvents()
233
+ this.render()
203
234
  } else {
204
- this.listenToOnce(this.container, Events.CONTAINER_LOADEDMETADATA, this.reset);
235
+ this.listenToOnce(
236
+ this.container,
237
+ Events.CONTAINER_LOADEDMETADATA,
238
+ this.reset,
239
+ )
205
240
  }
206
241
  }
207
242
 
208
243
  findElementBySource(source) {
209
244
  return this.options.multisources.find((element) => {
210
245
  if (element.source === source) {
211
- return element;
246
+ return element
212
247
  }
213
248
 
214
- return false;
215
- });
249
+ return false
250
+ })
216
251
  }
217
252
 
218
253
  onVRChanged() {
219
- this.vrSwitch();
254
+ this.vrSwitch()
220
255
  }
221
256
 
222
257
  vrSwitch() {
223
258
  if (this.shouldRender()) {
224
- this.active_ = !this.active_;
259
+ this.active_ = !this.active_
225
260
  if (this.active_) {
226
261
  // This starts playback mode when the cardboard button
227
262
  // is clicked on Andriod. We need to do this as the controls
228
263
  // disappear
229
- if (this.container && !this.container.playback.isPlaying() && Browser.isAndroid) {
230
- this.container.play();
264
+ if (
265
+ this.container &&
266
+ !this.container.playback.isPlaying() &&
267
+ Browser.isAndroid
268
+ ) {
269
+ this.container.play()
231
270
  }
232
- window.dispatchEvent(new window.Event('vrdisplayactivate'));
271
+ window.dispatchEvent(new window.Event('vrdisplayactivate'))
233
272
  } else {
234
- window.dispatchEvent(new window.Event('vrdisplaydeactivate'));
273
+ window.dispatchEvent(new window.Event('vrdisplaydeactivate'))
235
274
  }
236
275
  }
237
276
  }
238
277
 
239
278
  onFullscreenChange() {
240
- this.checkFullscreen();
279
+ this.checkFullscreen()
241
280
  }
242
281
 
243
282
  checkFullscreen() {
244
283
  if (this.container && this.container.el) {
245
- const fs = isFullscreen(this.container.el);
284
+ const fs = isFullscreen(this.container.el)
246
285
 
247
286
  if (Browser.isAndroid && fs) {
248
- this.$el.hide();
287
+ this.$el.hide()
249
288
  } else {
250
- this.$el.show();
289
+ this.$el.show()
251
290
  }
252
291
  }
253
292
  }
254
293
 
255
294
  init() {
256
295
  if (this.initialized_) {
257
- return;
296
+ return
258
297
  }
259
298
  if (this.advertisement) {
260
- return;
299
+ return
261
300
  }
262
- this.reset();
301
+ this.reset()
263
302
 
264
303
  this.camera = new THREE.PerspectiveCamera(
265
304
  75,
266
305
  this.container.$el.width() / this.container.$el.height(),
267
306
  1,
268
- 1100
269
- );
307
+ 1100,
308
+ )
270
309
  // Store vector representing the direction in which the camera is looking, in world space.
271
- this.cameraVector = new THREE.Vector3();
310
+ this.cameraVector = new THREE.Vector3()
272
311
 
273
312
  if (
274
313
  this.options.video360.projection === '360_LR' ||
@@ -277,94 +316,105 @@ export default class Video360 extends UICorePlugin {
277
316
  this.options.video360.projection === 'EAC_LR'
278
317
  ) {
279
318
  // Render left eye when not in VR mode
280
- this.camera.layers.enable(1);
319
+ this.camera.layers.enable(1)
281
320
  }
282
321
 
283
- this.scene = new THREE.Scene();
284
- this.videoTexture = new THREE.VideoTexture(this.getVideoEl_());
322
+ this.scene = new THREE.Scene()
323
+ this.videoTexture = new THREE.VideoTexture(this.getVideoEl_())
285
324
 
286
325
  // shared regardless of wether THREE.VideoTexture is used or
287
326
  // an image canvas is used
288
- this.videoTexture.generateMipmaps = false;
289
- this.videoTexture.minFilter = THREE.LinearFilter;
290
- this.videoTexture.magFilter = THREE.LinearFilter;
291
- this.videoTexture.format = THREE.RGBFormat;
327
+ this.videoTexture.generateMipmaps = false
328
+ this.videoTexture.minFilter = THREE.LinearFilter
329
+ this.videoTexture.magFilter = THREE.LinearFilter
330
+ this.videoTexture.format = THREE.RGBFormat
292
331
 
293
- this.changeProjection_(this.options.video360.projection);
332
+ this.changeProjection_(this.options.video360.projection)
294
333
 
295
334
  if (this.options.video360.projection === 'NONE') {
296
- console.warn('Projection is NONE, dont init');
297
- this.reset();
335
+ console.warn('Projection is NONE, dont init')
336
+ this.reset()
298
337
 
299
- return;
338
+ return
300
339
  }
301
340
 
302
- this.camera.position.set(0, 0, 0);
341
+ this.camera.position.set(0, 0, 0)
303
342
  this.renderer = new THREE.WebGLRenderer({
304
343
  devicePixelRatio: window.devicePixelRatio,
305
344
  alpha: false,
306
345
  clearColor: 0xffffff,
307
- antialias: true
308
- });
346
+ antialias: true,
347
+ })
309
348
 
310
- this.renderer.setAnimationLoop(this.animate_);
349
+ this.renderer.setAnimationLoop(this.animate_)
311
350
 
312
- const webglContext = this.renderer.getContext('webgl');
313
- const oldTexImage2D = webglContext.texImage2D;
351
+ const webglContext = this.renderer.getContext('webgl')
352
+ const oldTexImage2D = webglContext.texImage2D
314
353
 
315
354
  /* this is a workaround since threejs uses try catch */
316
355
  webglContext.texImage2D = (...args) => {
317
356
  try {
318
- return oldTexImage2D.apply(webglContext, args);
357
+ return oldTexImage2D.apply(webglContext, args)
319
358
  } catch (error) {
320
- LogManager.exception(error);
321
- this.reset();
322
- this.container.pause();
359
+ LogManager.exception(error)
360
+ this.reset()
361
+ this.container.pause()
323
362
 
324
- throw new Error(error);
363
+ throw new Error(error)
325
364
  }
326
- };
365
+ }
327
366
 
328
- this.renderer.setSize(this.container.$el.width(), this.container.$el.height(), false);
329
- this.effect = new VREffect(this.renderer);
367
+ this.renderer.setSize(
368
+ this.container.$el.width(),
369
+ this.container.$el.height(),
370
+ false,
371
+ )
372
+ this.effect = new VREffect(this.renderer)
330
373
 
331
- this.effect.setSize(this.container.$el.width(), this.container.$el.height(), false);
374
+ this.effect.setSize(
375
+ this.container.$el.width(),
376
+ this.container.$el.height(),
377
+ false,
378
+ )
332
379
 
333
380
  // Previous timestamps for gamepad updates
334
- this.prevTimestamps_ = [];
335
- this.renderedCanvas = this.renderer.domElement;
336
- this.renderedCanvas.setAttribute('style', 'width:100%;height:100%;position:absolute;top:0;left:0;z-index:3;');
381
+ this.prevTimestamps_ = []
382
+ this.renderedCanvas = this.renderer.domElement
383
+ this.renderedCanvas.setAttribute(
384
+ 'style',
385
+ 'width:100%;height:100%;position:absolute;top:0;left:0;z-index:3;',
386
+ )
337
387
 
338
388
  // TODO: fix that hack
339
389
  if (Browser.isiOS) {
340
- this.renderedCanvas.style.pointerEvents = 'none';
390
+ this.renderedCanvas.style.pointerEvents = 'none'
341
391
  }
342
392
 
343
- const videoElStyle = this.getVideoEl_().style;
393
+ const videoElStyle = this.getVideoEl_().style
344
394
 
345
- this.container.el.appendChild(this.renderedCanvas);
346
- videoElStyle.zIndex = '-1';
347
- videoElStyle.opacity = '0';
395
+ this.container.el.appendChild(this.renderedCanvas)
396
+ videoElStyle.zIndex = '-1'
397
+ videoElStyle.opacity = '0'
348
398
 
349
399
  if (window.navigator.getVRDisplays) {
350
400
  this.getVRDisplays((device) => {
351
401
  if (device) {
352
- this.vrDisplay = device;
402
+ this.vrDisplay = device
353
403
  if (window.self !== window.top) {
354
- this.vrDisplay.poseSensor_.useDeviceMotion();
404
+ this.vrDisplay.poseSensor_.useDeviceMotion()
355
405
  }
356
406
  if (!device.isPolyfilled) {
357
- this.controls3d = new VRControls(this.camera);
407
+ this.controls3d = new VRControls(this.camera)
358
408
  } else {
359
409
  const options = {
360
410
  camera: this.camera,
361
411
  canvas: this.renderedCanvas,
362
412
  // check if its a half sphere view projection
363
413
  halfView: this.options.video360.projection === '180',
364
- orientation: Browser.isiOS || Browser.isAndroid || false
365
- };
414
+ orientation: Browser.isiOS || Browser.isAndroid || false,
415
+ }
366
416
 
367
- this.controls3d = new OrbitOrientationControls(options);
417
+ this.controls3d = new OrbitOrientationControls(options)
368
418
  }
369
419
  } else {
370
420
  const options = {
@@ -372,393 +422,455 @@ export default class Video360 extends UICorePlugin {
372
422
  canvas: this.renderedCanvas,
373
423
  // check if its a half sphere view projection
374
424
  halfView: this.options.video360.projection === '180',
375
- orientation: Browser.isiOS || Browser.isAndroid || false
376
- };
425
+ orientation: Browser.isiOS || Browser.isAndroid || false,
426
+ }
377
427
 
378
- this.controls3d = new OrbitOrientationControls(options);
428
+ this.controls3d = new OrbitOrientationControls(options)
379
429
  }
380
- });
430
+ })
381
431
  } else if (window.navigator.getVRDevices) {
382
- console.error('There isn\'t vr');
432
+ console.error("There isn't vr")
383
433
  } else {
384
- console.error('There isn\'t vr');
434
+ console.error("There isn't vr")
385
435
  }
386
436
 
387
- window.addEventListener('vrdisplaypresentchange', this.handleResize, true);
388
- window.addEventListener('vrdisplayactivate', this.handleVrDisplayActivate_, true);
389
- window.addEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true);
390
- window.addEventListener('vrdisplaypresentchange', this.handleVrDisplayPresentChange_, true);
391
-
392
- this.initialized_ = true;
437
+ window.addEventListener('vrdisplaypresentchange', this.handleResize, true)
438
+ window.addEventListener(
439
+ 'vrdisplayactivate',
440
+ this.handleVrDisplayActivate_,
441
+ true,
442
+ )
443
+ window.addEventListener(
444
+ 'vrdisplaydeactivate',
445
+ this.handleVrDisplayDeactivate_,
446
+ true,
447
+ )
448
+ window.addEventListener(
449
+ 'vrdisplaypresentchange',
450
+ this.handleVrDisplayPresentChange_,
451
+ true,
452
+ )
453
+
454
+ this.initialized_ = true
393
455
  }
394
456
 
395
457
  getVRDisplays(onDisplay) {
396
458
  if ('getVRDisplays' in navigator) {
397
- navigator.getVRDisplays()
398
- .then(function (displays) {
399
- onDisplay(displays[0]);
400
- });
459
+ navigator.getVRDisplays().then(function (displays) {
460
+ onDisplay(displays[0])
461
+ })
401
462
  }
402
463
  }
403
464
 
404
465
  getVideoEl_() {
405
- return this.container.$el.find('video')[0];
466
+ return this.container.$el.find('video')[0]
406
467
  }
407
468
 
408
469
  reset() {
409
470
  if (this.controls3d) {
410
- this.controls3d.dispose();
411
- this.controls3d = null;
471
+ this.controls3d.dispose()
472
+ this.controls3d = null
412
473
  }
413
474
 
414
475
  // reset the ios touch to click workaround
415
476
  if (this.iosRevertTouchToClick_) {
416
- this.iosRevertTouchToClick_();
477
+ this.iosRevertTouchToClick_()
417
478
  }
418
479
 
419
480
  if (this.effect) {
420
- this.effect.dispose();
421
- this.effect = null;
481
+ this.effect.dispose()
482
+ this.effect = null
422
483
  }
423
484
 
424
485
  if (this.movieGeometry) {
425
- this.movieGeometry.dispose();
486
+ this.movieGeometry.dispose()
426
487
  }
427
488
  if (this.movieMaterial) {
428
- this.movieMaterial.dispose();
489
+ this.movieMaterial.dispose()
429
490
  }
430
491
 
431
492
  if (this.videoTexture) {
432
- this.videoTexture.dispose();
493
+ this.videoTexture.dispose()
433
494
  }
434
495
 
435
- window.removeEventListener('resize', this.handleResize, true);
436
- window.removeEventListener('vrdisplaypresentchange', this.handleResize, true);
437
- window.removeEventListener('vrdisplaypresentchange', this.handleResize, true);
438
- window.removeEventListener('vrdisplayactivate', this.handleVrDisplayPresentChange_, true);
439
- window.removeEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true);
496
+ window.removeEventListener('resize', this.handleResize, true)
497
+ window.removeEventListener(
498
+ 'vrdisplaypresentchange',
499
+ this.handleResize,
500
+ true,
501
+ )
502
+ window.removeEventListener(
503
+ 'vrdisplaypresentchange',
504
+ this.handleResize,
505
+ true,
506
+ )
507
+ window.removeEventListener(
508
+ 'vrdisplayactivate',
509
+ this.handleVrDisplayPresentChange_,
510
+ true,
511
+ )
512
+ window.removeEventListener(
513
+ 'vrdisplaydeactivate',
514
+ this.handleVrDisplayDeactivate_,
515
+ true,
516
+ )
440
517
 
441
518
  // reset the video element style so that it will be displayed
442
519
  if (this.getVideoEl_()) {
443
- const videoElStyle = this.getVideoEl_().style;
520
+ const videoElStyle = this.getVideoEl_().style
444
521
 
445
- videoElStyle.zIndex = '';
446
- videoElStyle.opacity = '';
522
+ videoElStyle.zIndex = ''
523
+ videoElStyle.opacity = ''
447
524
  }
448
525
 
449
526
  // reset the ios touch to click workaround
450
527
  if (this.iosRevertTouchToClick_) {
451
- this.iosRevertTouchToClick_();
528
+ this.iosRevertTouchToClick_()
452
529
  }
453
530
 
454
531
  if (this.renderer) {
455
- this.renderer.setAnimationLoop(null);
456
- this.renderer = null;
532
+ this.renderer.setAnimationLoop(null)
533
+ this.renderer = null
457
534
  }
458
535
 
459
536
  // remove the old canvas
460
537
  if (this.renderedCanvas && this.container && this.container.el) {
461
538
  try {
462
- this.container.el.removeChild(this.renderedCanvas);
463
- this.renderedCanvas = null;
539
+ this.container.el.removeChild(this.renderedCanvas)
540
+ this.renderedCanvas = null
464
541
  } catch (error) {
465
- LogManager.exception(error);
542
+ LogManager.exception(error)
466
543
  }
467
544
  }
468
- this.initialized_ = false;
545
+ this.initialized_ = false
469
546
  }
470
547
 
471
548
  handleVrDisplayPresentChange_() {
472
549
  if (this.vrDisplay) {
473
550
  if (!this.vrDisplay.isPresenting && this.active_) {
474
- this.handleVrDisplayDeactivate_();
551
+ this.handleVrDisplayDeactivate_()
475
552
  }
476
553
  if (this.vrDisplay.isPresenting && !this.active_) {
477
- this.handleVrDisplayActivate_();
554
+ this.handleVrDisplayActivate_()
478
555
  }
479
556
  }
480
557
  }
481
558
 
482
559
  handleVrDisplayDeactivate_() {
483
560
  if (!this.vrDisplay) {
484
- return;
561
+ return
485
562
  }
486
- this.active_ = false;
563
+ this.active_ = false
487
564
  if (this.iosRevertTouchToClick_) {
488
- this.iosRevertTouchToClick_();
565
+ this.iosRevertTouchToClick_()
489
566
  }
490
567
 
491
568
  setTimeout(() => {
492
- this.vrDisplay.exitPresent().then(() => {
493
- }).catch((error) => {
494
- LogManager.exception(error);
495
- });
496
- }, 0);
569
+ this.vrDisplay
570
+ .exitPresent()
571
+ .then(() => {})
572
+ .catch((error) => {
573
+ LogManager.exception(error)
574
+ })
575
+ }, 0)
497
576
  }
498
577
 
499
578
  handleVrDisplayActivate_() {
500
579
  if (!this.vrDisplay) {
501
- return;
580
+ return
502
581
  }
503
- this.vrDisplay.requestPresent([{ source: this.renderedCanvas }]).then(() => {
504
- if (!this.vrDisplay.cardboardUI_ || !Browser.isiOS) {
505
- return;
506
- }
507
- this.container.play();
508
- // webvr-polyfill/cardboard ui only watches for click events
509
- // to tell that the back arrow button is pressed during cardboard vr.
510
- // but somewhere along the line these events are silenced with preventDefault
511
- // but only on iOS, so we translate them ourselves here
512
- let touches = [];
513
- const iosCardboardTouchStart_ = (e) => {
514
- for (let i = 0; i < e.touches.length; i++) {
515
- touches.push(e.touches[i]);
582
+ this.vrDisplay
583
+ .requestPresent([{ source: this.renderedCanvas }])
584
+ .then(() => {
585
+ if (!this.vrDisplay.cardboardUI_ || !Browser.isiOS) {
586
+ return
516
587
  }
517
- };
518
-
519
- const iosCardboardTouchEnd_ = () => {
520
- if (!touches.length) {
521
- return;
588
+ this.container.play()
589
+ // webvr-polyfill/cardboard ui only watches for click events
590
+ // to tell that the back arrow button is pressed during cardboard vr.
591
+ // but somewhere along the line these events are silenced with preventDefault
592
+ // but only on iOS, so we translate them ourselves here
593
+ let touches = []
594
+ const iosCardboardTouchStart_ = (e) => {
595
+ for (let i = 0; i < e.touches.length; i++) {
596
+ touches.push(e.touches[i])
597
+ }
522
598
  }
523
599
 
524
- touches.forEach((t) => {
525
- const simulatedClick = new window.MouseEvent('click', {
526
- screenX: t.screenX,
527
- screenY: t.screenY,
528
- clientX: t.clientX,
529
- clientY: t.clientY
530
- });
600
+ const iosCardboardTouchEnd_ = () => {
601
+ if (!touches.length) {
602
+ return
603
+ }
531
604
 
532
- this.renderedCanvas.dispatchEvent(simulatedClick);
533
- });
605
+ touches.forEach((t) => {
606
+ const simulatedClick = new window.MouseEvent('click', {
607
+ screenX: t.screenX,
608
+ screenY: t.screenY,
609
+ clientX: t.clientX,
610
+ clientY: t.clientY,
611
+ })
534
612
 
535
- touches = [];
536
- };
613
+ this.renderedCanvas.dispatchEvent(simulatedClick)
614
+ })
537
615
 
538
- this.renderedCanvas.addEventListener('touchstart', iosCardboardTouchStart_);
539
- this.renderedCanvas.addEventListener('touchend', iosCardboardTouchEnd_);
616
+ touches = []
617
+ }
540
618
 
541
- this.iosRevertTouchToClick_ = () => {
542
- this.renderedCanvas.removeEventListener('touchstart', iosCardboardTouchStart_);
543
- this.renderedCanvas.removeEventListener('touchend', iosCardboardTouchEnd_);
544
- this.iosRevertTouchToClick_ = null;
545
- };
546
- });
619
+ this.renderedCanvas.addEventListener(
620
+ 'touchstart',
621
+ iosCardboardTouchStart_,
622
+ )
623
+ this.renderedCanvas.addEventListener('touchend', iosCardboardTouchEnd_)
624
+
625
+ this.iosRevertTouchToClick_ = () => {
626
+ this.renderedCanvas.removeEventListener(
627
+ 'touchstart',
628
+ iosCardboardTouchStart_,
629
+ )
630
+ this.renderedCanvas.removeEventListener(
631
+ 'touchend',
632
+ iosCardboardTouchEnd_,
633
+ )
634
+ this.iosRevertTouchToClick_ = null
635
+ }
636
+ })
547
637
  }
548
638
 
549
639
  changeProjection_(projection) {
550
640
  // don't change to an invalid projection
551
641
  if (!projection) {
552
- console.error('none projection');
642
+ console.error('none projection')
553
643
 
554
- return;
644
+ return
555
645
  }
556
- const position = { x: 0, y: 0, z: 0 };
646
+ const position = { x: 0, y: 0, z: 0 }
557
647
 
558
648
  if (this.scene) {
559
- this.scene.remove(this.movieScreen);
649
+ this.scene.remove(this.movieScreen)
560
650
  }
561
651
  if (projection === 'AUTO') {
562
652
  // mediainfo cannot be set to auto or we would infinite loop here
563
653
  // each source should know wether they are 360 or not, if using AUTO
564
- return this.changeProjection_('NONE');
654
+ return this.changeProjection_('NONE')
565
655
  } else if (projection === '360') {
566
- this.movieGeometry = new THREE.SphereBufferGeometry(256, 32, 32);
567
- this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, side: THREE.BackSide });
568
-
569
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
570
- this.movieScreen.position.set(position.x, position.y, position.z);
571
-
572
- this.movieScreen.scale.x = -1;
573
- this.movieScreen.quaternion.setFromAxisAngle({ x: 0, y: 1, z: 0 }, -Math.PI / 2);
574
- this.scene.add(this.movieScreen);
656
+ this.movieGeometry = new THREE.SphereBufferGeometry(256, 32, 32)
657
+ this.movieMaterial = new THREE.MeshBasicMaterial({
658
+ map: this.videoTexture,
659
+ side: THREE.BackSide,
660
+ })
661
+
662
+ this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial)
663
+ this.movieScreen.position.set(position.x, position.y, position.z)
664
+
665
+ this.movieScreen.scale.x = -1
666
+ this.movieScreen.quaternion.setFromAxisAngle(
667
+ { x: 0, y: 1, z: 0 },
668
+ -Math.PI / 2,
669
+ )
670
+ this.scene.add(this.movieScreen)
575
671
  } else if (projection === '360_LR' || projection === '360_TB') {
576
672
  // Left eye view
577
- let geometry = new THREE.SphereGeometry(256, 32, 32);
673
+ let geometry = new THREE.SphereGeometry(256, 32, 32)
578
674
 
579
- let uvs = geometry.faceVertexUvs[0];
675
+ let uvs = geometry.faceVertexUvs[0]
580
676
 
581
677
  for (let i = 0; i < uvs.length; i++) {
582
678
  for (let j = 0; j < 3; j++) {
583
679
  if (projection === '360_LR') {
584
- uvs[i][j].x *= 0.5;
680
+ uvs[i][j].x *= 0.5
585
681
  } else {
586
- uvs[i][j].y *= 0.5;
587
- uvs[i][j].y += 0.5;
682
+ uvs[i][j].y *= 0.5
683
+ uvs[i][j].y += 0.5
588
684
  }
589
685
  }
590
686
  }
591
687
 
592
- this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
593
- this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, side: THREE.BackSide });
594
-
595
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
596
- this.movieScreen.scale.x = -1;
597
- this.movieScreen.quaternion.setFromAxisAngle({ x: 0, y: 1, z: 0 }, -Math.PI / 2);
688
+ this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry)
689
+ this.movieMaterial = new THREE.MeshBasicMaterial({
690
+ map: this.videoTexture,
691
+ side: THREE.BackSide,
692
+ })
693
+
694
+ this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial)
695
+ this.movieScreen.scale.x = -1
696
+ this.movieScreen.quaternion.setFromAxisAngle(
697
+ { x: 0, y: 1, z: 0 },
698
+ -Math.PI / 2,
699
+ )
598
700
  // display in left eye only
599
- this.movieScreen.layers.set(1);
600
- this.scene.add(this.movieScreen);
701
+ this.movieScreen.layers.set(1)
702
+ this.scene.add(this.movieScreen)
601
703
 
602
704
  // Right eye view
603
- geometry = new THREE.SphereGeometry(256, 32, 32);
705
+ geometry = new THREE.SphereGeometry(256, 32, 32)
604
706
 
605
- uvs = geometry.faceVertexUvs[0];
707
+ uvs = geometry.faceVertexUvs[0]
606
708
 
607
709
  for (let i = 0; i < uvs.length; i++) {
608
710
  for (let j = 0; j < 3; j++) {
609
711
  if (projection === '360_LR') {
610
- uvs[i][j].x *= 0.5;
611
- uvs[i][j].x += 0.5;
712
+ uvs[i][j].x *= 0.5
713
+ uvs[i][j].x += 0.5
612
714
  } else {
613
- uvs[i][j].y *= 0.5;
715
+ uvs[i][j].y *= 0.5
614
716
  }
615
717
  }
616
718
  }
617
719
 
618
- this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
619
- this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, side: THREE.BackSide });
620
-
621
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
622
- this.movieScreen.scale.x = -1;
623
- this.movieScreen.quaternion.setFromAxisAngle({ x: 0, y: 1, z: 0 }, -Math.PI / 2);
720
+ this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry)
721
+ this.movieMaterial = new THREE.MeshBasicMaterial({
722
+ map: this.videoTexture,
723
+ side: THREE.BackSide,
724
+ })
725
+
726
+ this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial)
727
+ this.movieScreen.scale.x = -1
728
+ this.movieScreen.quaternion.setFromAxisAngle(
729
+ { x: 0, y: 1, z: 0 },
730
+ -Math.PI / 2,
731
+ )
624
732
  // display in right eye only
625
- this.movieScreen.layers.set(2);
626
- this.scene.add(this.movieScreen);
733
+ this.movieScreen.layers.set(2)
734
+ this.scene.add(this.movieScreen)
627
735
  } else if (projection === '360_CUBE') {
628
- this.movieGeometry = new THREE.BoxGeometry(256, 256, 256);
629
- this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, side: THREE.BackSide });
736
+ this.movieGeometry = new THREE.BoxGeometry(256, 256, 256)
737
+ this.movieMaterial = new THREE.MeshBasicMaterial({
738
+ map: this.videoTexture,
739
+ side: THREE.BackSide,
740
+ })
630
741
 
631
742
  const left = [
632
743
  new THREE.Vector2(0, 0.5),
633
744
  new THREE.Vector2(0.333, 0.5),
634
- new THREE.Vector2(0.333, 1), new THREE.Vector2(0, 1)
635
- ];
745
+ new THREE.Vector2(0.333, 1),
746
+ new THREE.Vector2(0, 1),
747
+ ]
636
748
  const right = [
637
749
  new THREE.Vector2(0.333, 0.5),
638
750
  new THREE.Vector2(0.666, 0.5),
639
751
  new THREE.Vector2(0.666, 1),
640
- new THREE.Vector2(0.333, 1)
641
- ];
752
+ new THREE.Vector2(0.333, 1),
753
+ ]
642
754
  const top = [
643
755
  new THREE.Vector2(0.666, 0.5),
644
756
  new THREE.Vector2(1, 0.5),
645
757
  new THREE.Vector2(1, 1),
646
- new THREE.Vector2(0.666, 1)
647
- ];
758
+ new THREE.Vector2(0.666, 1),
759
+ ]
648
760
  const bottom = [
649
761
  new THREE.Vector2(0, 0),
650
762
  new THREE.Vector2(0.333, 0),
651
763
  new THREE.Vector2(0.333, 0.5),
652
- new THREE.Vector2(0, 0.5)
653
- ];
764
+ new THREE.Vector2(0, 0.5),
765
+ ]
654
766
  const front = [
655
767
  new THREE.Vector2(0.333, 0),
656
768
  new THREE.Vector2(0.666, 0),
657
769
  new THREE.Vector2(0.666, 0.5),
658
- new THREE.Vector2(0.333, 0.5)
659
- ];
770
+ new THREE.Vector2(0.333, 0.5),
771
+ ]
660
772
  const back = [
661
773
  new THREE.Vector2(0.666, 0),
662
774
  new THREE.Vector2(1, 0),
663
775
  new THREE.Vector2(1, 0.5),
664
- new THREE.Vector2(0.666, 0.5)
665
- ];
776
+ new THREE.Vector2(0.666, 0.5),
777
+ ]
666
778
 
667
- this.movieGeometry.faceVertexUvs[0] = [];
779
+ this.movieGeometry.faceVertexUvs[0] = []
668
780
 
669
- this.movieGeometry.faceVertexUvs[0][0] = [right[2], right[1], right[3]];
670
- this.movieGeometry.faceVertexUvs[0][1] = [right[1], right[0], right[3]];
781
+ this.movieGeometry.faceVertexUvs[0][0] = [right[2], right[1], right[3]]
782
+ this.movieGeometry.faceVertexUvs[0][1] = [right[1], right[0], right[3]]
671
783
 
672
- this.movieGeometry.faceVertexUvs[0][2] = [left[2], left[1], left[3]];
673
- this.movieGeometry.faceVertexUvs[0][3] = [left[1], left[0], left[3]];
784
+ this.movieGeometry.faceVertexUvs[0][2] = [left[2], left[1], left[3]]
785
+ this.movieGeometry.faceVertexUvs[0][3] = [left[1], left[0], left[3]]
674
786
 
675
- this.movieGeometry.faceVertexUvs[0][4] = [top[2], top[1], top[3]];
676
- this.movieGeometry.faceVertexUvs[0][5] = [top[1], top[0], top[3]];
787
+ this.movieGeometry.faceVertexUvs[0][4] = [top[2], top[1], top[3]]
788
+ this.movieGeometry.faceVertexUvs[0][5] = [top[1], top[0], top[3]]
677
789
 
678
- this.movieGeometry.faceVertexUvs[0][6] = [bottom[2], bottom[1], bottom[3]];
679
- this.movieGeometry.faceVertexUvs[0][7] = [bottom[1], bottom[0], bottom[3]];
790
+ this.movieGeometry.faceVertexUvs[0][6] = [bottom[2], bottom[1], bottom[3]]
791
+ this.movieGeometry.faceVertexUvs[0][7] = [bottom[1], bottom[0], bottom[3]]
680
792
 
681
- this.movieGeometry.faceVertexUvs[0][8] = [front[2], front[1], front[3]];
682
- this.movieGeometry.faceVertexUvs[0][9] = [front[1], front[0], front[3]];
793
+ this.movieGeometry.faceVertexUvs[0][8] = [front[2], front[1], front[3]]
794
+ this.movieGeometry.faceVertexUvs[0][9] = [front[1], front[0], front[3]]
683
795
 
684
- this.movieGeometry.faceVertexUvs[0][10] = [back[2], back[1], back[3]];
685
- this.movieGeometry.faceVertexUvs[0][11] = [back[1], back[0], back[3]];
796
+ this.movieGeometry.faceVertexUvs[0][10] = [back[2], back[1], back[3]]
797
+ this.movieGeometry.faceVertexUvs[0][11] = [back[1], back[0], back[3]]
686
798
 
687
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
688
- this.movieScreen.position.set(position.x, position.y, position.z);
689
- this.movieScreen.rotation.y = -Math.PI;
799
+ this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial)
800
+ this.movieScreen.position.set(position.x, position.y, position.z)
801
+ this.movieScreen.rotation.y = -Math.PI
690
802
 
691
- this.scene.add(this.movieScreen);
803
+ this.scene.add(this.movieScreen)
692
804
  } else if (projection === '180') {
693
- let geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI);
805
+ let geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI)
694
806
 
695
807
  // Left eye view
696
- geometry.scale(-1, 1, 1);
697
- let uvs = geometry.faceVertexUvs[0];
808
+ geometry.scale(-1, 1, 1)
809
+ let uvs = geometry.faceVertexUvs[0]
698
810
 
699
811
  for (let i = 0; i < uvs.length; i++) {
700
812
  for (let j = 0; j < 3; j++) {
701
- uvs[i][j].x *= 0.5;
813
+ uvs[i][j].x *= 0.5
702
814
  }
703
815
  }
704
816
 
705
- this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
817
+ this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry)
706
818
  this.movieMaterial = new THREE.MeshBasicMaterial({
707
- map: this.videoTexture
708
- });
709
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
819
+ map: this.videoTexture,
820
+ })
821
+ this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial)
710
822
  // display in left eye only
711
- this.movieScreen.layers.set(1);
712
- this.scene.add(this.movieScreen);
823
+ this.movieScreen.layers.set(1)
824
+ this.scene.add(this.movieScreen)
713
825
 
714
826
  // Right eye view
715
- geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI);
716
- geometry.scale(-1, 1, 1);
717
- uvs = geometry.faceVertexUvs[0];
827
+ geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI)
828
+ geometry.scale(-1, 1, 1)
829
+ uvs = geometry.faceVertexUvs[0]
718
830
 
719
831
  for (let i = 0; i < uvs.length; i++) {
720
832
  for (let j = 0; j < 3; j++) {
721
- uvs[i][j].x *= 0.5;
722
- uvs[i][j].x += 0.5;
833
+ uvs[i][j].x *= 0.5
834
+ uvs[i][j].x += 0.5
723
835
  }
724
836
  }
725
837
 
726
- this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
838
+ this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry)
727
839
  this.movieMaterial = new THREE.MeshBasicMaterial({
728
- map: this.videoTexture
729
- });
730
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
840
+ map: this.videoTexture,
841
+ })
842
+ this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial)
731
843
  // display in right eye only
732
- this.movieScreen.layers.set(2);
733
- this.scene.add(this.movieScreen);
844
+ this.movieScreen.layers.set(2)
845
+ this.scene.add(this.movieScreen)
734
846
  } else if (projection === 'EAC' || projection === 'EAC_LR') {
735
847
  const makeScreen = (mapMatrix, scaleMatrix) => {
736
848
  // "Continuity correction?": because of discontinuous faces and aliasing,
737
849
  // we truncate the 2-pixel-wide strips on all discontinuous edges,
738
- const contCorrect = 2;
850
+ const contCorrect = 2
739
851
 
740
- this.movieGeometry = new THREE.BoxGeometry(256, 256, 256);
852
+ this.movieGeometry = new THREE.BoxGeometry(256, 256, 256)
741
853
  this.movieMaterial = new THREE.ShaderMaterial({
742
854
  side: THREE.BackSide,
743
855
  uniforms: {
744
856
  mapped: {
745
- value: this.videoTexture
857
+ value: this.videoTexture,
746
858
  },
747
859
  mapMatrix: {
748
- value: mapMatrix
860
+ value: mapMatrix,
749
861
  },
750
862
  contCorrect: {
751
- value: contCorrect
863
+ value: contCorrect,
752
864
  },
753
865
  faceWH: {
754
- value: new THREE.Vector2(1 / 3, 1 / 2).applyMatrix3(scaleMatrix)
866
+ value: new THREE.Vector2(1 / 3, 1 / 2).applyMatrix3(scaleMatrix),
755
867
  },
756
868
  vidWH: {
757
869
  value: new THREE.Vector2(
758
870
  this.videoTexture.image.videoWidth,
759
- this.videoTexture.image.videoHeight
760
- ).applyMatrix3(scaleMatrix)
761
- }
871
+ this.videoTexture.image.videoHeight,
872
+ ).applyMatrix3(scaleMatrix),
873
+ },
762
874
  },
763
875
  vertexShader: `
764
876
  varying vec2 vUv;
@@ -788,192 +900,210 @@ export default class Video360 extends UICorePlugin {
788
900
  vec2 eUv = corner + q * faceWHadj;
789
901
 
790
902
  gl_FragColor = texture2D(mapped, eUv);
791
- }`
792
- });
903
+ }`,
904
+ })
793
905
 
794
906
  const right = [
795
907
  new THREE.Vector2(0, 1 / 2),
796
908
  new THREE.Vector2(1 / 3, 1 / 2),
797
909
  new THREE.Vector2(1 / 3, 1),
798
- new THREE.Vector2(0, 1)
799
- ];
910
+ new THREE.Vector2(0, 1),
911
+ ]
800
912
  const front = [
801
913
  new THREE.Vector2(1 / 3, 1 / 2),
802
914
  new THREE.Vector2(2 / 3, 1 / 2),
803
915
  new THREE.Vector2(2 / 3, 1),
804
- new THREE.Vector2(1 / 3, 1)
805
- ];
916
+ new THREE.Vector2(1 / 3, 1),
917
+ ]
806
918
  const left = [
807
919
  new THREE.Vector2(2 / 3, 1 / 2),
808
920
  new THREE.Vector2(1, 1 / 2),
809
921
  new THREE.Vector2(1, 1),
810
- new THREE.Vector2(2 / 3, 1)
811
- ];
922
+ new THREE.Vector2(2 / 3, 1),
923
+ ]
812
924
  const bottom = [
813
925
  new THREE.Vector2(1 / 3, 0),
814
926
  new THREE.Vector2(1 / 3, 1 / 2),
815
927
  new THREE.Vector2(0, 1 / 2),
816
- new THREE.Vector2(0, 0)
817
- ];
928
+ new THREE.Vector2(0, 0),
929
+ ]
818
930
  const back = [
819
931
  new THREE.Vector2(1 / 3, 1 / 2),
820
932
  new THREE.Vector2(1 / 3, 0),
821
933
  new THREE.Vector2(2 / 3, 0),
822
- new THREE.Vector2(2 / 3, 1 / 2)
823
- ];
934
+ new THREE.Vector2(2 / 3, 1 / 2),
935
+ ]
824
936
  const top = [
825
937
  new THREE.Vector2(1, 0),
826
938
  new THREE.Vector2(1, 1 / 2),
827
939
  new THREE.Vector2(2 / 3, 1 / 2),
828
- new THREE.Vector2(2 / 3, 0)
829
- ];
940
+ new THREE.Vector2(2 / 3, 0),
941
+ ]
830
942
 
831
943
  for (const face of [right, front, left, bottom, back, top]) {
832
- const height = this.videoTexture.image.videoHeight;
833
- let lowY = 1;
834
- let highY = 0;
944
+ const height = this.videoTexture.image.videoHeight
945
+ let lowY = 1
946
+ let highY = 0
835
947
 
836
948
  for (const vector of face) {
837
949
  if (vector.y < lowY) {
838
- lowY = vector.y;
950
+ lowY = vector.y
839
951
  }
840
952
  if (vector.y > highY) {
841
- highY = vector.y;
953
+ highY = vector.y
842
954
  }
843
955
  }
844
956
 
845
957
  for (const vector of face) {
846
958
  if (Math.abs(vector.y - lowY) < Number.EPSILON) {
847
- vector.y += contCorrect / height;
959
+ vector.y += contCorrect / height
848
960
  }
849
961
  if (Math.abs(vector.y - highY) < Number.EPSILON) {
850
- vector.y -= contCorrect / height;
962
+ vector.y -= contCorrect / height
851
963
  }
852
964
 
853
- vector.x = vector.x / height * (height - contCorrect * 2) + contCorrect / height;
965
+ vector.x =
966
+ (vector.x / height) * (height - contCorrect * 2) +
967
+ contCorrect / height
854
968
  }
855
969
  }
856
970
 
857
- this.movieGeometry.faceVertexUvs[0] = [];
971
+ this.movieGeometry.faceVertexUvs[0] = []
858
972
 
859
- this.movieGeometry.faceVertexUvs[0][0] = [right[2], right[1], right[3]];
860
- this.movieGeometry.faceVertexUvs[0][1] = [right[1], right[0], right[3]];
973
+ this.movieGeometry.faceVertexUvs[0][0] = [right[2], right[1], right[3]]
974
+ this.movieGeometry.faceVertexUvs[0][1] = [right[1], right[0], right[3]]
861
975
 
862
- this.movieGeometry.faceVertexUvs[0][2] = [left[2], left[1], left[3]];
863
- this.movieGeometry.faceVertexUvs[0][3] = [left[1], left[0], left[3]];
976
+ this.movieGeometry.faceVertexUvs[0][2] = [left[2], left[1], left[3]]
977
+ this.movieGeometry.faceVertexUvs[0][3] = [left[1], left[0], left[3]]
864
978
 
865
- this.movieGeometry.faceVertexUvs[0][4] = [top[2], top[1], top[3]];
866
- this.movieGeometry.faceVertexUvs[0][5] = [top[1], top[0], top[3]];
979
+ this.movieGeometry.faceVertexUvs[0][4] = [top[2], top[1], top[3]]
980
+ this.movieGeometry.faceVertexUvs[0][5] = [top[1], top[0], top[3]]
867
981
 
868
- this.movieGeometry.faceVertexUvs[0][6] = [bottom[2], bottom[1], bottom[3]];
869
- this.movieGeometry.faceVertexUvs[0][7] = [bottom[1], bottom[0], bottom[3]];
982
+ this.movieGeometry.faceVertexUvs[0][6] = [
983
+ bottom[2],
984
+ bottom[1],
985
+ bottom[3],
986
+ ]
987
+ this.movieGeometry.faceVertexUvs[0][7] = [
988
+ bottom[1],
989
+ bottom[0],
990
+ bottom[3],
991
+ ]
870
992
 
871
- this.movieGeometry.faceVertexUvs[0][8] = [front[2], front[1], front[3]];
872
- this.movieGeometry.faceVertexUvs[0][9] = [front[1], front[0], front[3]];
993
+ this.movieGeometry.faceVertexUvs[0][8] = [front[2], front[1], front[3]]
994
+ this.movieGeometry.faceVertexUvs[0][9] = [front[1], front[0], front[3]]
873
995
 
874
- this.movieGeometry.faceVertexUvs[0][10] = [back[2], back[1], back[3]];
875
- this.movieGeometry.faceVertexUvs[0][11] = [back[1], back[0], back[3]];
996
+ this.movieGeometry.faceVertexUvs[0][10] = [back[2], back[1], back[3]]
997
+ this.movieGeometry.faceVertexUvs[0][11] = [back[1], back[0], back[3]]
876
998
 
877
- this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
878
- this.movieScreen.position.set(position.x, position.y, position.z);
879
- this.movieScreen.rotation.y = -Math.PI;
999
+ this.movieScreen = new THREE.Mesh(
1000
+ this.movieGeometry,
1001
+ this.movieMaterial,
1002
+ )
1003
+ this.movieScreen.position.set(position.x, position.y, position.z)
1004
+ this.movieScreen.rotation.y = -Math.PI
880
1005
 
881
- return this.movieScreen;
882
- };
1006
+ return this.movieScreen
1007
+ }
883
1008
 
884
1009
  if (projection === 'EAC') {
885
- this.scene.add(makeScreen(new THREE.Matrix3(), new THREE.Matrix3()));
1010
+ this.scene.add(makeScreen(new THREE.Matrix3(), new THREE.Matrix3()))
886
1011
  } else {
887
- const scaleMatrix = new THREE.Matrix3().set(
888
- 0, 0.5, 0,
889
- 1, 0, 0,
890
- 0, 0, 1
891
- );
892
-
893
- makeScreen(new THREE.Matrix3().set(
894
- 0, -0.5, 0.5,
895
- 1, 0, 0,
896
- 0, 0, 1
897
- ), scaleMatrix);
1012
+ const scaleMatrix = new THREE.Matrix3().set(0, 0.5, 0, 1, 0, 0, 0, 0, 1)
1013
+
1014
+ makeScreen(
1015
+ new THREE.Matrix3().set(0, -0.5, 0.5, 1, 0, 0, 0, 0, 1),
1016
+ scaleMatrix,
1017
+ )
898
1018
  // display in left eye only
899
- this.movieScreen.layers.set(1);
900
- this.scene.add(this.movieScreen);
901
-
902
- makeScreen(new THREE.Matrix3().set(
903
- 0, -0.5, 1,
904
- 1, 0, 0,
905
- 0, 0, 1
906
- ), scaleMatrix);
1019
+ this.movieScreen.layers.set(1)
1020
+ this.scene.add(this.movieScreen)
1021
+
1022
+ makeScreen(
1023
+ new THREE.Matrix3().set(0, -0.5, 1, 1, 0, 0, 0, 0, 1),
1024
+ scaleMatrix,
1025
+ )
907
1026
  // display in right eye only
908
- this.movieScreen.layers.set(2);
909
- this.scene.add(this.movieScreen);
1027
+ this.movieScreen.layers.set(2)
1028
+ this.scene.add(this.movieScreen)
910
1029
  }
911
1030
  }
912
1031
  }
913
1032
 
914
1033
  destroy() {
915
- this.reset();
1034
+ this.reset()
916
1035
  }
917
1036
 
918
1037
  shouldRender() {
919
1038
  if (!this.container) {
920
- return false;
1039
+ return false
921
1040
  }
922
1041
 
923
- this.currentPlayback = this.core.activePlayback;
924
- if (this.currentPlayback && this.currentPlayback.tagName !== 'video' && this.currentPlayback.tagName !== 'audio') {
1042
+ this.currentPlayback = this.core.activePlayback
1043
+ if (
1044
+ this.currentPlayback &&
1045
+ this.currentPlayback.tagName !== 'video' &&
1046
+ this.currentPlayback.tagName !== 'audio'
1047
+ ) {
925
1048
  //console.warn('PlaybackRatePlugin#shouldRender: Cannot affect rate for playback', currentPlayback);
926
- return false;
1049
+ return false
927
1050
  }
928
1051
 
929
1052
  try {
930
- const { video360 } = this.options;
1053
+ const { video360 } = this.options
931
1054
 
932
- if (!video360 || !video360.projection || (!video360.forceCardboard && !Browser.isiOS && !Browser.isAndroid)) {
933
- return false;
1055
+ if (
1056
+ !video360 ||
1057
+ !video360.projection ||
1058
+ (!video360.forceCardboard && !Browser.isiOS && !Browser.isAndroid)
1059
+ ) {
1060
+ return false
934
1061
  }
935
1062
  } catch (error) {
936
- LogManager.exception(error);
1063
+ LogManager.exception(error)
937
1064
 
938
- return false;
1065
+ return false
939
1066
  }
940
1067
 
941
- return true;
1068
+ return true
942
1069
  }
943
1070
 
944
1071
  render() {
945
1072
  //console.log('PlaybackRatePlugin#render()');
946
1073
  if (this.shouldRender()) {
947
- const t = template(pluginHtml);
948
- const html = t();
1074
+ const t = template(pluginHtml)
1075
+ const html = t()
949
1076
 
950
- this.$el.html(html);
1077
+ this.$el.html(html)
951
1078
 
952
1079
  if (
953
- Object.prototype.hasOwnProperty.call(this.core.mediaControl, '$vrButton') &&
1080
+ Object.prototype.hasOwnProperty.call(
1081
+ this.core.mediaControl,
1082
+ '$vrButton',
1083
+ ) &&
954
1084
  this.core.mediaControl.$vrButton.length > 0
955
1085
  ) {
956
- this.$el.find('.vr-button').append(cardBoard);
957
- this.core.mediaControl.$vrButton.append(this.$el);
1086
+ this.$el.find('.vr-button').append(cardBoard)
1087
+ this.core.mediaControl.$vrButton.append(this.$el)
958
1088
  } else {
959
- this.core.mediaControl.$('.media-control-right-panel').append(this.el);
1089
+ this.core.mediaControl.$('.media-control-right-panel').append(this.el)
960
1090
  }
961
1091
  }
962
1092
  }
963
1093
 
964
1094
  get template() {
965
- return template(pluginHtml);
1095
+ return template(pluginHtml)
966
1096
  }
967
1097
 
968
1098
  onStartAd() {
969
- this.advertisement = true;
970
- this.reset();
1099
+ this.advertisement = true
1100
+ this.reset()
971
1101
  }
972
1102
 
973
1103
  onFinishAd() {
974
- this.advertisement = false;
1104
+ this.advertisement = false
975
1105
  if (this.loadMetadata) {
976
- this.init();
1106
+ this.init()
977
1107
  }
978
1108
  }
979
1109
  }