@gcorevideo/player 2.18.3 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/audio-selector/style.scss +156 -0
- package/assets/audio-selector/track-selector.ejs +12 -0
- package/assets/big-mute-button/big-mute-button.ejs +3 -0
- package/assets/big-mute-button/big-mute-button.scss +57 -0
- package/assets/bottom-gear/bottomgear.ejs +12 -0
- package/assets/bottom-gear/gear-sub-menu.scss +95 -0
- package/assets/bottom-gear/gear.scss +79 -0
- package/assets/clappr-nerd-stats/button.ejs +4 -0
- package/assets/clappr-nerd-stats/clappr-nerd-stats.ejs +212 -0
- package/assets/clappr-nerd-stats/clappr-nerd-stats.scss +488 -0
- package/assets/clappr-nerd-stats/options-list.ejs +9 -0
- package/assets/clappr-nerd-stats/settings.ejs +12 -0
- package/assets/clappr-nerd-stats/speedtest/speedtest.worker.js +775 -0
- package/assets/clips/clips.scss +3 -0
- package/assets/context-menu/context_menu.ejs +8 -0
- package/assets/context-menu/context_menu.scss +31 -0
- package/assets/dvr-controls/dvr_controls.scss +136 -0
- package/assets/dvr-controls/index.ejs +2 -0
- package/assets/error-screen/error_screen.ejs +13 -0
- package/assets/error-screen/error_screen.scss +40 -0
- package/assets/icons/new/arrow-left.svg +5 -0
- package/assets/icons/new/arrow-right.svg +5 -0
- package/assets/icons/new/check.svg +5 -0
- package/assets/icons/new/close.svg +12 -0
- package/assets/icons/new/full.svg +8 -0
- package/assets/icons/new/fullscreen-off.svg +14 -0
- package/assets/icons/new/fullscreen-on.svg +14 -0
- package/assets/icons/new/gear-hd.svg +16 -0
- package/assets/icons/new/gear.svg +12 -0
- package/assets/icons/new/hd.svg +8 -0
- package/assets/icons/new/pause.svg +5 -0
- package/assets/icons/new/pip.svg +5 -0
- package/assets/icons/new/play.svg +10 -0
- package/assets/icons/new/replayleft.svg +5 -0
- package/assets/icons/new/replayright.svg +5 -0
- package/assets/icons/new/speed.svg +5 -0
- package/assets/icons/new/stats.svg +3 -0
- package/assets/icons/new/stop.svg +3 -0
- package/assets/icons/new/subtitles-off.svg +5 -0
- package/assets/icons/new/subtitles-on.svg +6 -0
- package/assets/icons/new/volume-max.svg +5 -0
- package/assets/icons/new/volume-min.svg +5 -0
- package/assets/icons/new/volume-off.svg +5 -0
- package/assets/icons/old/cardboard.svg +4 -0
- package/assets/icons/old/close-share.svg +13 -0
- package/assets/icons/old/close.svg +13 -0
- package/assets/icons/old/fb.svg +13 -0
- package/assets/icons/old/fullscreen.svg +12 -0
- package/assets/icons/old/language.svg +1 -0
- package/assets/icons/old/pause.svg +12 -0
- package/assets/icons/old/play.svg +12 -0
- package/assets/icons/old/quality-arrow.svg +13 -0
- package/assets/icons/old/reload.svg +4 -0
- package/assets/icons/old/share.svg +13 -0
- package/assets/icons/old/sound-off.svg +15 -0
- package/assets/icons/old/sound-on.svg +15 -0
- package/assets/icons/old/streams.svg +3 -0
- package/assets/icons/old/twitter.svg +13 -0
- package/assets/icons/old/wn.svg +15 -0
- package/assets/icons/standard/01-play.svg +3 -0
- package/assets/icons/standard/02-pause.svg +3 -0
- package/assets/icons/standard/03-stop.svg +3 -0
- package/assets/icons/standard/04-volume.svg +3 -0
- package/assets/icons/standard/05-mute.svg +3 -0
- package/assets/icons/standard/06-expand.svg +3 -0
- package/assets/icons/standard/07-shrink.svg +3 -0
- package/assets/icons/standard/08-hd.svg +3 -0
- package/assets/icons/standard/09-cc.svg +8 -0
- package/assets/icons/standard/10-reload.svg +4 -0
- package/assets/level-selector/button.ejs +8 -0
- package/assets/level-selector/list.ejs +22 -0
- package/assets/level-selector/style.scss +4 -0
- package/assets/logo/styles/logo.scss +10 -0
- package/assets/logo/templates/logo.ejs +3 -0
- package/assets/media-control/closed-hand.cur +0 -0
- package/assets/media-control/container.scss +57 -0
- package/assets/media-control/media-control.ejs +133 -0
- package/assets/media-control/media-control.scss +390 -0
- package/assets/media-control/plugins.scss +94 -0
- package/assets/media-control/width270.scss +50 -0
- package/assets/media-control/width370.scss +263 -0
- package/assets/multi-camera/multicamera.ejs +29 -0
- package/assets/multi-camera/style.scss +176 -0
- package/assets/picture-in-picture/button.ejs +3 -0
- package/assets/picture-in-picture/button.scss +11 -0
- package/assets/playback-rate/button.ejs +6 -0
- package/assets/playback-rate/list.ejs +14 -0
- package/assets/playback-rate/playback-rate-selector.ejs +9 -0
- package/assets/poster/poster.ejs +1 -0
- package/assets/poster/poster.scss +32 -0
- package/assets/seek-time/seek-time.html +2 -0
- package/assets/seek-time/seek-time.scss +38 -0
- package/assets/share/share.ejs +37 -0
- package/assets/share/style.scss +104 -0
- package/assets/skip-time/skip-time.ejs +8 -0
- package/assets/skip-time/style.scss +24 -0
- package/assets/spinner-three-bounce/spinner.ejs +3 -0
- package/assets/spinner-three-bounce/spinner.scss +44 -0
- package/assets/style/main.scss +50 -0
- package/assets/style/theme.scss +42 -0
- package/assets/style/variables.scss +7 -0
- package/assets/subtitles/combobox copy.ejs +16 -0
- package/assets/subtitles/combobox.ejs +16 -0
- package/assets/subtitles/string.ejs +3 -0
- package/assets/subtitles/style.scss +99 -0
- package/assets/thumbnails/scrub-thumbnails.ejs +10 -0
- package/assets/thumbnails/style.scss +75 -0
- package/assets/vast-ads/style.scss +112 -0
- package/assets/video360/button.ejs +1 -0
- package/assets/video360/style.scss +8 -0
- package/build/vite-raw-plugin.js +18 -0
- package/dist/index.js +1 -1
- package/dist/plugins/index.css +2164 -0
- package/dist/plugins/index.js/index.plugins.js +40837 -0
- package/dist/plugins/index.plugins.js +40837 -0
- package/lib/index.core.d.ts +15 -0
- package/lib/index.core.d.ts.map +1 -0
- package/lib/index.core.js +14 -0
- package/lib/index.d.ts +2 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -14
- package/lib/index.plugins.d.ts +38 -0
- package/lib/index.plugins.d.ts.map +1 -0
- package/lib/index.plugins.js +40 -0
- package/lib/plugins/audio-selector/AudioSelector.d.ts +3 -3
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -1
- package/lib/plugins/audio-selector/AudioSelector.js +6 -12
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +2 -2
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -1
- package/lib/plugins/big-mute-button/BigMuteButton.js +7 -12
- package/lib/plugins/bottom-gear/BottomGear.d.ts +4 -3
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -1
- package/lib/plugins/bottom-gear/BottomGear.js +11 -16
- package/lib/plugins/build.d.ts +2 -0
- package/lib/plugins/build.d.ts.map +1 -0
- package/lib/plugins/build.js +1 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts +44 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/ClapprNerdStats.js +294 -0
- package/lib/plugins/clappr-nerd-stats/formatter.d.ts +8 -0
- package/lib/plugins/clappr-nerd-stats/formatter.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/formatter.js +91 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts +54 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/Speedtest.js +335 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts +9 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/index.js +154 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts +6 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/speedtest/types.js +1 -0
- package/lib/plugins/clappr-nerd-stats/types.d.ts +4 -0
- package/lib/plugins/clappr-nerd-stats/types.d.ts.map +1 -0
- package/lib/plugins/clappr-nerd-stats/types.js +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts +56 -0
- package/lib/plugins/clappr-stats/ClapprStats.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/ClapprStats.js +332 -0
- package/lib/plugins/clappr-stats/types.d.ts +50 -0
- package/lib/plugins/clappr-stats/types.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/types.js +5 -0
- package/lib/plugins/clappr-stats/utils.d.ts +3 -0
- package/lib/plugins/clappr-stats/utils.d.ts.map +1 -0
- package/lib/plugins/clappr-stats/utils.js +40 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts +2 -2
- package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -1
- package/lib/plugins/click-to-pause/ClickToPause.js +4 -6
- package/lib/plugins/clips/Clips.d.ts +23 -0
- package/lib/plugins/clips/Clips.d.ts.map +1 -0
- package/lib/plugins/clips/Clips.js +109 -0
- package/lib/plugins/context-menu/ContextMenu.d.ts +36 -0
- package/lib/plugins/context-menu/ContextMenu.d.ts.map +1 -0
- package/lib/plugins/context-menu/ContextMenu.js +102 -0
- package/lib/plugins/disable-controls/DisableControls.d.ts +1 -1
- package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -1
- package/lib/plugins/disable-controls/DisableControls.js +3 -5
- package/lib/plugins/dvr-controls/DVRControls.d.ts +4 -4
- package/lib/plugins/dvr-controls/DVRControls.d.ts.map +1 -1
- package/lib/plugins/dvr-controls/DVRControls.js +5 -4
- package/lib/plugins/error-screen/ErrorScreen.d.ts +44 -0
- package/lib/plugins/error-screen/ErrorScreen.d.ts.map +1 -0
- package/lib/plugins/error-screen/ErrorScreen.js +179 -0
- package/lib/plugins/favicon/Favicon.d.ts +24 -0
- package/lib/plugins/favicon/Favicon.d.ts.map +1 -0
- package/lib/plugins/favicon/Favicon.js +106 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts +30 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.d.ts.map +1 -0
- package/lib/plugins/google-analytics/GoogleAnalytics.js +114 -0
- package/lib/plugins/index.d.ts +38 -0
- package/lib/plugins/index.d.ts.map +1 -0
- package/lib/plugins/index.js +40 -0
- package/lib/plugins/kibo/index.d.ts +23 -0
- package/lib/plugins/kibo/index.d.ts.map +1 -0
- package/lib/plugins/kibo/index.js +199 -0
- package/lib/plugins/level-selector/LevelSelector.d.ts +48 -17
- package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -1
- package/lib/plugins/level-selector/LevelSelector.js +169 -155
- package/lib/plugins/logo/Logo.d.ts +29 -0
- package/lib/plugins/logo/Logo.d.ts.map +1 -0
- package/lib/plugins/logo/Logo.js +181 -0
- package/lib/plugins/logo/utils/index.d.ts +22 -0
- package/lib/plugins/logo/utils/index.d.ts.map +1 -0
- package/lib/plugins/logo/utils/index.js +32 -0
- package/lib/plugins/media-control/MediaControl.d.ts +20 -25
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -1
- package/lib/plugins/media-control/MediaControl.js +136 -106
- package/lib/plugins/multi-camera/MultiCamera.d.ts +59 -0
- package/lib/plugins/multi-camera/MultiCamera.d.ts.map +1 -0
- package/lib/plugins/multi-camera/MultiCamera.js +353 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts +20 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.d.ts.map +1 -0
- package/lib/plugins/picture-in-picture/PictureInPicture.js +68 -0
- package/lib/plugins/playback-rate/PlaybackRate.d.ts +42 -0
- package/lib/plugins/playback-rate/PlaybackRate.d.ts.map +1 -0
- package/lib/plugins/playback-rate/PlaybackRate.js +205 -0
- package/lib/plugins/poster/Poster.d.ts +18 -17
- package/lib/plugins/poster/Poster.d.ts.map +1 -1
- package/lib/plugins/poster/Poster.js +83 -37
- package/lib/plugins/seek-time/SeekTime.d.ts +38 -0
- package/lib/plugins/seek-time/SeekTime.d.ts.map +1 -0
- package/lib/plugins/seek-time/SeekTime.js +153 -0
- package/lib/plugins/share/Share.d.ts +38 -0
- package/lib/plugins/share/Share.d.ts.map +1 -0
- package/lib/plugins/share/Share.js +122 -0
- package/lib/plugins/skip-time/SkipTime.d.ts +28 -0
- package/lib/plugins/skip-time/SkipTime.d.ts.map +1 -0
- package/lib/plugins/skip-time/SkipTime.js +86 -0
- package/lib/plugins/source-controller/SourceController.d.ts +41 -0
- package/lib/plugins/source-controller/SourceController.d.ts.map +1 -0
- package/lib/plugins/source-controller/SourceController.js +199 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts +26 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.d.ts.map +1 -0
- package/lib/plugins/spinner-three-bounce/SpinnerThreeBounce.js +117 -0
- package/lib/plugins/statistics/Statistics.d.ts +52 -0
- package/lib/plugins/statistics/Statistics.d.ts.map +1 -0
- package/lib/plugins/statistics/Statistics.js +130 -0
- package/lib/plugins/subtitles/Subtitles.d.ts +61 -0
- package/lib/plugins/subtitles/Subtitles.d.ts.map +1 -0
- package/lib/plugins/subtitles/Subtitles.js +354 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts +47 -0
- package/lib/plugins/thumbnails/Thumbnails.d.ts.map +1 -0
- package/lib/plugins/thumbnails/Thumbnails.js +414 -0
- package/lib/plugins/types.d.ts +8 -0
- package/lib/plugins/types.d.ts.map +1 -0
- package/lib/plugins/types.js +1 -0
- package/lib/plugins/utils.d.ts +5 -0
- package/lib/plugins/utils.d.ts.map +1 -0
- package/lib/plugins/utils.js +68 -0
- package/lib/plugins/vast-ads/VastAds.d.ts +72 -0
- package/lib/plugins/vast-ads/VastAds.d.ts.map +1 -0
- package/lib/plugins/vast-ads/VastAds.js +686 -0
- package/lib/plugins/vast-ads/loaderxml.d.ts +32 -0
- package/lib/plugins/vast-ads/loaderxml.d.ts.map +1 -0
- package/lib/plugins/vast-ads/loaderxml.js +226 -0
- package/lib/plugins/vast-ads/roll.d.ts +60 -0
- package/lib/plugins/vast-ads/roll.d.ts.map +1 -0
- package/lib/plugins/vast-ads/roll.js +415 -0
- package/lib/plugins/vast-ads/rollmanager.d.ts +62 -0
- package/lib/plugins/vast-ads/rollmanager.d.ts.map +1 -0
- package/lib/plugins/vast-ads/rollmanager.js +347 -0
- package/lib/plugins/vast-ads/sctemanager.d.ts +18 -0
- package/lib/plugins/vast-ads/sctemanager.d.ts.map +1 -0
- package/lib/plugins/vast-ads/sctemanager.js +116 -0
- package/lib/plugins/vast-ads/types.d.ts +12 -0
- package/lib/plugins/vast-ads/types.d.ts.map +1 -0
- package/lib/plugins/vast-ads/types.js +1 -0
- package/lib/plugins/vast-ads/urlhandler.d.ts +4 -0
- package/lib/plugins/vast-ads/urlhandler.d.ts.map +1 -0
- package/lib/plugins/vast-ads/urlhandler.js +30 -0
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts +6 -0
- package/lib/plugins/vast-ads/xmlhttprequest.d.ts.map +1 -0
- package/lib/plugins/vast-ads/xmlhttprequest.js +39 -0
- package/lib/plugins/vast-ads/xmlmerge.d.ts +12 -0
- package/lib/plugins/vast-ads/xmlmerge.d.ts.map +1 -0
- package/lib/plugins/vast-ads/xmlmerge.js +82 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts +21 -0
- package/lib/plugins/volume-fade/VolumeFade.d.ts.map +1 -0
- package/lib/plugins/volume-fade/VolumeFade.js +90 -0
- package/package.json +10 -2
- package/rollup.config.js +32 -2
- package/src/index.core.ts +15 -0
- package/src/index.plugins.ts +42 -0
- package/src/index.ts +2 -15
- package/src/plugins/audio-selector/AudioSelector.ts +370 -0
- package/src/plugins/big-mute-button/BigMuteButton.ts +187 -0
- package/src/plugins/bottom-gear/BottomGear.ts +122 -0
- package/src/plugins/build.ts +1 -0
- package/src/plugins/clappr-nerd-stats/ClapprNerdStats.ts +369 -0
- package/src/plugins/clappr-nerd-stats/formatter.ts +109 -0
- package/src/plugins/clappr-nerd-stats/speedtest/Speedtest.ts +414 -0
- package/src/plugins/clappr-nerd-stats/speedtest/index.ts +183 -0
- package/src/plugins/clappr-nerd-stats/speedtest/types.ts +5 -0
- package/src/plugins/clappr-nerd-stats/types.ts +3 -0
- package/src/plugins/clappr-stats/ClapprStats.ts +441 -0
- package/src/plugins/clappr-stats/types.ts +52 -0
- package/src/plugins/clappr-stats/utils.ts +42 -0
- package/src/plugins/click-to-pause/ClickToPause.ts +93 -0
- package/src/plugins/clips/Clips.ts +152 -0
- package/src/plugins/context-menu/ContextMenu.ts +134 -0
- package/src/plugins/disable-controls/DisableControls.ts +81 -0
- package/src/plugins/dvr-controls/DvrControls.ts +131 -0
- package/src/plugins/error-screen/ErrorScreen.ts +241 -0
- package/src/plugins/favicon/Favicon.ts +137 -0
- package/src/plugins/ga-events/GaEvents.js +395 -0
- package/src/plugins/ga-events/ga-tracking.js +46 -0
- package/src/plugins/google-analytics/GoogleAnalytics.ts +147 -0
- package/src/plugins/index.ts +42 -0
- package/src/plugins/kibo/index.ts +244 -0
- package/src/plugins/level-selector/LevelSelector.ts +400 -0
- package/src/plugins/level-selector/__tests__/LevelSelector.test.ts +72 -0
- package/src/plugins/level-selector/__tests__/__snapshots__/LevelSelector.test.ts.snap +11 -0
- package/src/plugins/logo/Logo.ts +233 -0
- package/src/plugins/logo/utils/index.ts +46 -0
- package/src/plugins/media-control/MediaControl.ts +1383 -0
- package/src/plugins/multi-camera/MultiCamera copy.xts +414 -0
- package/src/plugins/multi-camera/MultiCamera.ts +426 -0
- package/src/plugins/picture-in-picture/PictureInPicture.ts +87 -0
- package/src/plugins/playback-rate/PlaybackRate.ts +269 -0
- package/src/plugins/poster/Poster.ts +298 -0
- package/src/plugins/seek-time/SeekTime.ts +191 -0
- package/src/plugins/share/Share.ts +148 -0
- package/src/plugins/skip-time/SkipTime.ts +109 -0
- package/src/plugins/source-controller/SourceController.ts +239 -0
- package/src/plugins/source-controller/__tests__/SourceController.test.ts +230 -0
- package/src/plugins/spinner-three-bounce/SpinnerThreeBounce.ts +135 -0
- package/src/plugins/statistics/Statistics copy.xts +296 -0
- package/src/plugins/statistics/Statistics.ts +207 -0
- package/src/plugins/subtitles/Subtitles.ts +505 -0
- package/src/plugins/thumbnails/Thumbnails.ts +530 -0
- package/src/plugins/types.ts +7 -0
- package/src/plugins/typings/globals.d.ts +10 -0
- package/src/plugins/typings/parse-srt.d.ts +14 -0
- package/src/plugins/typings/workers.d.ts +3 -0
- package/src/plugins/utils.ts +77 -0
- package/src/plugins/vast-ads/VastAds.ts +915 -0
- package/src/plugins/vast-ads/loaderxml.ts +260 -0
- package/src/plugins/vast-ads/roll.ts +492 -0
- package/src/plugins/vast-ads/rollmanager.ts +403 -0
- package/src/plugins/vast-ads/sctemanager.ts +134 -0
- package/src/plugins/vast-ads/types.ts +14 -0
- package/src/plugins/vast-ads/urlhandler.ts +37 -0
- package/src/plugins/vast-ads/xmlhttprequest.ts +44 -0
- package/src/plugins/vast-ads/xmlmerge.ts +96 -0
- package/src/plugins/video360/VRControls.js +104 -0
- package/src/plugins/video360/VREffect.js +422 -0
- package/src/plugins/video360/Video360.js +979 -0
- package/src/plugins/video360/orbit-oriention-controls.js +1002 -0
- package/src/plugins/video360/utils.js +49 -0
- package/src/plugins/volume-fade/VolumeFade.ts +109 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,979 @@
|
|
|
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
|
+
|
|
15
|
+
export default class Video360 extends UICorePlugin {
|
|
16
|
+
get name() {
|
|
17
|
+
return 'video_360';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get supportedVersion() {
|
|
21
|
+
return { min: process.env.CLAPPR_VERSION };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get mediaControl() {
|
|
25
|
+
return this.core.mediaControl;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get attributes() {
|
|
29
|
+
return {
|
|
30
|
+
'class': this.name,
|
|
31
|
+
'data-vr': ''
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get events() {
|
|
36
|
+
return {
|
|
37
|
+
'click [data-vr-button]': 'onVRChanged',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
// custom videojs-errors integration boolean
|
|
44
|
+
|
|
45
|
+
// IE 11 does not support enough webgl to be supported
|
|
46
|
+
// older safari does not support cors, so it wont work
|
|
47
|
+
if (Browser.isIE || Browser.isIE || !utils.corsSupport) {
|
|
48
|
+
console.error('There isn\'t vr');
|
|
49
|
+
this.destroy();
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.active_ = false;
|
|
55
|
+
|
|
56
|
+
this.polyfill_ = new WebVRPolyfill();
|
|
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);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
handleResize() {
|
|
66
|
+
if (!this.container) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const width = this.container.$el.width();
|
|
70
|
+
const height = this.container.$el.height();
|
|
71
|
+
|
|
72
|
+
this.effect && this.effect.setSize(width, height, false);
|
|
73
|
+
if (this.camera) {
|
|
74
|
+
this.camera.aspect = width / height;
|
|
75
|
+
this.camera.updateProjectionMatrix();
|
|
76
|
+
}
|
|
77
|
+
this.checkFullscreen();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
animate_() {
|
|
81
|
+
if (!this.initialized_) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
if (!this.activated && this.getVideoEl_() && this.getVideoEl_().readyState === 4) {
|
|
86
|
+
this.activated = true;
|
|
87
|
+
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (this.getVideoEl_() && this.getVideoEl_().readyState === this.getVideoEl_().HAVE_ENOUGH_DATA) {
|
|
91
|
+
if (this.videoTexture) {
|
|
92
|
+
this.videoTexture.needsUpdate = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
LogManager.exception(error);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.controls3d) {
|
|
100
|
+
this.controls3d.update();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.effect.render(this.scene, this.camera);
|
|
104
|
+
|
|
105
|
+
if (window.navigator.getGamepads) {
|
|
106
|
+
// Grab all gamepads
|
|
107
|
+
const gamepads = window.navigator.getGamepads();
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < gamepads.length; ++i) {
|
|
110
|
+
const gamepad = gamepads[i];
|
|
111
|
+
|
|
112
|
+
// Make sure gamepad is defined
|
|
113
|
+
// Only take input if state has changed since we checked last
|
|
114
|
+
if (!gamepad || !gamepad.timestamp || gamepad.timestamp === this.prevTimestamps_[i]) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
for (let j = 0; j < gamepad.buttons.length; ++j) {
|
|
118
|
+
if (gamepad.buttons[j].pressed) {
|
|
119
|
+
this.prevTimestamps_[i] = gamepad.timestamp;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
bindEvents() {
|
|
128
|
+
this.listenToOnce(this.core, Events.CORE_READY, this.onCoreReady);
|
|
129
|
+
|
|
130
|
+
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));
|
|
133
|
+
}
|
|
134
|
+
|
|
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);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
bindContainerEvents() {
|
|
141
|
+
if (this.container) {
|
|
142
|
+
this.listenTo(this.container, 'container:destroyed', this.destroy);
|
|
143
|
+
this.listenTo(this.container, Events.CONTAINER_LOADEDMETADATA, () => {
|
|
144
|
+
this.loadMetadata = true;
|
|
145
|
+
});
|
|
146
|
+
this.listenTo(this.container, Events.CONTAINER_LOADEDMETADATA, this.init);
|
|
147
|
+
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);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
unbindContainerEvents() {
|
|
156
|
+
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);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
onCoreReady() {
|
|
165
|
+
const element = this.findElementBySource(this.options.source);
|
|
166
|
+
|
|
167
|
+
if (!this.options.video360) {
|
|
168
|
+
this.options.video360 = {};
|
|
169
|
+
}
|
|
170
|
+
this.options.video360.projection = element.projection;
|
|
171
|
+
this.container = this.core.activeContainer;
|
|
172
|
+
if (window.DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission === 'function') {
|
|
173
|
+
if (this.container && this.container.$el) {
|
|
174
|
+
this.container.$el.click(() => {
|
|
175
|
+
DeviceOrientationEvent.requestPermission()
|
|
176
|
+
.then(() => {})
|
|
177
|
+
.catch((error) => {
|
|
178
|
+
LogManager.exception(error);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
containerChanged() {
|
|
186
|
+
this.container = this.core.activeContainer;
|
|
187
|
+
const element = this.findElementBySource(this.options.source);
|
|
188
|
+
|
|
189
|
+
if (
|
|
190
|
+
Object.prototype.hasOwnProperty.call(element, 'projection') &&
|
|
191
|
+
element.projection &&
|
|
192
|
+
this.container &&
|
|
193
|
+
this.container.el
|
|
194
|
+
) {
|
|
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();
|
|
203
|
+
} else {
|
|
204
|
+
this.listenToOnce(this.container, Events.CONTAINER_LOADEDMETADATA, this.reset);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
findElementBySource(source) {
|
|
209
|
+
return this.options.multisources.find((element) => {
|
|
210
|
+
if (element.source === source) {
|
|
211
|
+
return element;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return false;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
onVRChanged() {
|
|
219
|
+
this.vrSwitch();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
vrSwitch() {
|
|
223
|
+
if (this.shouldRender()) {
|
|
224
|
+
this.active_ = !this.active_;
|
|
225
|
+
if (this.active_) {
|
|
226
|
+
// This starts playback mode when the cardboard button
|
|
227
|
+
// is clicked on Andriod. We need to do this as the controls
|
|
228
|
+
// disappear
|
|
229
|
+
if (this.container && !this.container.playback.isPlaying() && Browser.isAndroid) {
|
|
230
|
+
this.container.play();
|
|
231
|
+
}
|
|
232
|
+
window.dispatchEvent(new window.Event('vrdisplayactivate'));
|
|
233
|
+
} else {
|
|
234
|
+
window.dispatchEvent(new window.Event('vrdisplaydeactivate'));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
onFullscreenChange() {
|
|
240
|
+
this.checkFullscreen();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
checkFullscreen() {
|
|
244
|
+
if (this.container && this.container.el) {
|
|
245
|
+
const fs = isFullscreen(this.container.el);
|
|
246
|
+
|
|
247
|
+
if (Browser.isAndroid && fs) {
|
|
248
|
+
this.$el.hide();
|
|
249
|
+
} else {
|
|
250
|
+
this.$el.show();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
init() {
|
|
256
|
+
if (this.initialized_) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (this.advertisement) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
this.reset();
|
|
263
|
+
|
|
264
|
+
this.camera = new THREE.PerspectiveCamera(
|
|
265
|
+
75,
|
|
266
|
+
this.container.$el.width() / this.container.$el.height(),
|
|
267
|
+
1,
|
|
268
|
+
1100
|
|
269
|
+
);
|
|
270
|
+
// Store vector representing the direction in which the camera is looking, in world space.
|
|
271
|
+
this.cameraVector = new THREE.Vector3();
|
|
272
|
+
|
|
273
|
+
if (
|
|
274
|
+
this.options.video360.projection === '360_LR' ||
|
|
275
|
+
this.options.video360.projection === '360_TB' ||
|
|
276
|
+
this.options.video360.projection === '180' ||
|
|
277
|
+
this.options.video360.projection === 'EAC_LR'
|
|
278
|
+
) {
|
|
279
|
+
// Render left eye when not in VR mode
|
|
280
|
+
this.camera.layers.enable(1);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
this.scene = new THREE.Scene();
|
|
284
|
+
this.videoTexture = new THREE.VideoTexture(this.getVideoEl_());
|
|
285
|
+
|
|
286
|
+
// shared regardless of wether THREE.VideoTexture is used or
|
|
287
|
+
// 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;
|
|
292
|
+
|
|
293
|
+
this.changeProjection_(this.options.video360.projection);
|
|
294
|
+
|
|
295
|
+
if (this.options.video360.projection === 'NONE') {
|
|
296
|
+
console.warn('Projection is NONE, dont init');
|
|
297
|
+
this.reset();
|
|
298
|
+
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
this.camera.position.set(0, 0, 0);
|
|
303
|
+
this.renderer = new THREE.WebGLRenderer({
|
|
304
|
+
devicePixelRatio: window.devicePixelRatio,
|
|
305
|
+
alpha: false,
|
|
306
|
+
clearColor: 0xffffff,
|
|
307
|
+
antialias: true
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
this.renderer.setAnimationLoop(this.animate_);
|
|
311
|
+
|
|
312
|
+
const webglContext = this.renderer.getContext('webgl');
|
|
313
|
+
const oldTexImage2D = webglContext.texImage2D;
|
|
314
|
+
|
|
315
|
+
/* this is a workaround since threejs uses try catch */
|
|
316
|
+
webglContext.texImage2D = (...args) => {
|
|
317
|
+
try {
|
|
318
|
+
return oldTexImage2D.apply(webglContext, args);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
LogManager.exception(error);
|
|
321
|
+
this.reset();
|
|
322
|
+
this.container.pause();
|
|
323
|
+
|
|
324
|
+
throw new Error(error);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
this.renderer.setSize(this.container.$el.width(), this.container.$el.height(), false);
|
|
329
|
+
this.effect = new VREffect(this.renderer);
|
|
330
|
+
|
|
331
|
+
this.effect.setSize(this.container.$el.width(), this.container.$el.height(), false);
|
|
332
|
+
|
|
333
|
+
// 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;');
|
|
337
|
+
|
|
338
|
+
// TODO: fix that hack
|
|
339
|
+
if (Browser.isiOS) {
|
|
340
|
+
this.renderedCanvas.style.pointerEvents = 'none';
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const videoElStyle = this.getVideoEl_().style;
|
|
344
|
+
|
|
345
|
+
this.container.el.appendChild(this.renderedCanvas);
|
|
346
|
+
videoElStyle.zIndex = '-1';
|
|
347
|
+
videoElStyle.opacity = '0';
|
|
348
|
+
|
|
349
|
+
if (window.navigator.getVRDisplays) {
|
|
350
|
+
this.getVRDisplays((device) => {
|
|
351
|
+
if (device) {
|
|
352
|
+
this.vrDisplay = device;
|
|
353
|
+
if (window.self !== window.top) {
|
|
354
|
+
this.vrDisplay.poseSensor_.useDeviceMotion();
|
|
355
|
+
}
|
|
356
|
+
if (!device.isPolyfilled) {
|
|
357
|
+
this.controls3d = new VRControls(this.camera);
|
|
358
|
+
} else {
|
|
359
|
+
const options = {
|
|
360
|
+
camera: this.camera,
|
|
361
|
+
canvas: this.renderedCanvas,
|
|
362
|
+
// check if its a half sphere view projection
|
|
363
|
+
halfView: this.options.video360.projection === '180',
|
|
364
|
+
orientation: Browser.isiOS || Browser.isAndroid || false
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
this.controls3d = new OrbitOrientationControls(options);
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
const options = {
|
|
371
|
+
camera: this.camera,
|
|
372
|
+
canvas: this.renderedCanvas,
|
|
373
|
+
// check if its a half sphere view projection
|
|
374
|
+
halfView: this.options.video360.projection === '180',
|
|
375
|
+
orientation: Browser.isiOS || Browser.isAndroid || false
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
this.controls3d = new OrbitOrientationControls(options);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
} else if (window.navigator.getVRDevices) {
|
|
382
|
+
console.error('There isn\'t vr');
|
|
383
|
+
} else {
|
|
384
|
+
console.error('There isn\'t vr');
|
|
385
|
+
}
|
|
386
|
+
|
|
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;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
getVRDisplays(onDisplay) {
|
|
396
|
+
if ('getVRDisplays' in navigator) {
|
|
397
|
+
navigator.getVRDisplays()
|
|
398
|
+
.then(function (displays) {
|
|
399
|
+
onDisplay(displays[0]);
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
getVideoEl_() {
|
|
405
|
+
return this.container.$el.find('video')[0];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
reset() {
|
|
409
|
+
if (this.controls3d) {
|
|
410
|
+
this.controls3d.dispose();
|
|
411
|
+
this.controls3d = null;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// reset the ios touch to click workaround
|
|
415
|
+
if (this.iosRevertTouchToClick_) {
|
|
416
|
+
this.iosRevertTouchToClick_();
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (this.effect) {
|
|
420
|
+
this.effect.dispose();
|
|
421
|
+
this.effect = null;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (this.movieGeometry) {
|
|
425
|
+
this.movieGeometry.dispose();
|
|
426
|
+
}
|
|
427
|
+
if (this.movieMaterial) {
|
|
428
|
+
this.movieMaterial.dispose();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (this.videoTexture) {
|
|
432
|
+
this.videoTexture.dispose();
|
|
433
|
+
}
|
|
434
|
+
|
|
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);
|
|
440
|
+
|
|
441
|
+
// reset the video element style so that it will be displayed
|
|
442
|
+
if (this.getVideoEl_()) {
|
|
443
|
+
const videoElStyle = this.getVideoEl_().style;
|
|
444
|
+
|
|
445
|
+
videoElStyle.zIndex = '';
|
|
446
|
+
videoElStyle.opacity = '';
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// reset the ios touch to click workaround
|
|
450
|
+
if (this.iosRevertTouchToClick_) {
|
|
451
|
+
this.iosRevertTouchToClick_();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (this.renderer) {
|
|
455
|
+
this.renderer.setAnimationLoop(null);
|
|
456
|
+
this.renderer = null;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// remove the old canvas
|
|
460
|
+
if (this.renderedCanvas && this.container && this.container.el) {
|
|
461
|
+
try {
|
|
462
|
+
this.container.el.removeChild(this.renderedCanvas);
|
|
463
|
+
this.renderedCanvas = null;
|
|
464
|
+
} catch (error) {
|
|
465
|
+
LogManager.exception(error);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
this.initialized_ = false;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
handleVrDisplayPresentChange_() {
|
|
472
|
+
if (this.vrDisplay) {
|
|
473
|
+
if (!this.vrDisplay.isPresenting && this.active_) {
|
|
474
|
+
this.handleVrDisplayDeactivate_();
|
|
475
|
+
}
|
|
476
|
+
if (this.vrDisplay.isPresenting && !this.active_) {
|
|
477
|
+
this.handleVrDisplayActivate_();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
handleVrDisplayDeactivate_() {
|
|
483
|
+
if (!this.vrDisplay) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
this.active_ = false;
|
|
487
|
+
if (this.iosRevertTouchToClick_) {
|
|
488
|
+
this.iosRevertTouchToClick_();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
setTimeout(() => {
|
|
492
|
+
this.vrDisplay.exitPresent().then(() => {
|
|
493
|
+
}).catch((error) => {
|
|
494
|
+
LogManager.exception(error);
|
|
495
|
+
});
|
|
496
|
+
}, 0);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
handleVrDisplayActivate_() {
|
|
500
|
+
if (!this.vrDisplay) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
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]);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
const iosCardboardTouchEnd_ = () => {
|
|
520
|
+
if (!touches.length) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
|
|
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
|
+
});
|
|
531
|
+
|
|
532
|
+
this.renderedCanvas.dispatchEvent(simulatedClick);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
touches = [];
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
this.renderedCanvas.addEventListener('touchstart', iosCardboardTouchStart_);
|
|
539
|
+
this.renderedCanvas.addEventListener('touchend', iosCardboardTouchEnd_);
|
|
540
|
+
|
|
541
|
+
this.iosRevertTouchToClick_ = () => {
|
|
542
|
+
this.renderedCanvas.removeEventListener('touchstart', iosCardboardTouchStart_);
|
|
543
|
+
this.renderedCanvas.removeEventListener('touchend', iosCardboardTouchEnd_);
|
|
544
|
+
this.iosRevertTouchToClick_ = null;
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
changeProjection_(projection) {
|
|
550
|
+
// don't change to an invalid projection
|
|
551
|
+
if (!projection) {
|
|
552
|
+
console.error('none projection');
|
|
553
|
+
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const position = { x: 0, y: 0, z: 0 };
|
|
557
|
+
|
|
558
|
+
if (this.scene) {
|
|
559
|
+
this.scene.remove(this.movieScreen);
|
|
560
|
+
}
|
|
561
|
+
if (projection === 'AUTO') {
|
|
562
|
+
// mediainfo cannot be set to auto or we would infinite loop here
|
|
563
|
+
// each source should know wether they are 360 or not, if using AUTO
|
|
564
|
+
return this.changeProjection_('NONE');
|
|
565
|
+
} 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);
|
|
575
|
+
} else if (projection === '360_LR' || projection === '360_TB') {
|
|
576
|
+
// Left eye view
|
|
577
|
+
let geometry = new THREE.SphereGeometry(256, 32, 32);
|
|
578
|
+
|
|
579
|
+
let uvs = geometry.faceVertexUvs[0];
|
|
580
|
+
|
|
581
|
+
for (let i = 0; i < uvs.length; i++) {
|
|
582
|
+
for (let j = 0; j < 3; j++) {
|
|
583
|
+
if (projection === '360_LR') {
|
|
584
|
+
uvs[i][j].x *= 0.5;
|
|
585
|
+
} else {
|
|
586
|
+
uvs[i][j].y *= 0.5;
|
|
587
|
+
uvs[i][j].y += 0.5;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
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);
|
|
598
|
+
// display in left eye only
|
|
599
|
+
this.movieScreen.layers.set(1);
|
|
600
|
+
this.scene.add(this.movieScreen);
|
|
601
|
+
|
|
602
|
+
// Right eye view
|
|
603
|
+
geometry = new THREE.SphereGeometry(256, 32, 32);
|
|
604
|
+
|
|
605
|
+
uvs = geometry.faceVertexUvs[0];
|
|
606
|
+
|
|
607
|
+
for (let i = 0; i < uvs.length; i++) {
|
|
608
|
+
for (let j = 0; j < 3; j++) {
|
|
609
|
+
if (projection === '360_LR') {
|
|
610
|
+
uvs[i][j].x *= 0.5;
|
|
611
|
+
uvs[i][j].x += 0.5;
|
|
612
|
+
} else {
|
|
613
|
+
uvs[i][j].y *= 0.5;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
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);
|
|
624
|
+
// display in right eye only
|
|
625
|
+
this.movieScreen.layers.set(2);
|
|
626
|
+
this.scene.add(this.movieScreen);
|
|
627
|
+
} 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 });
|
|
630
|
+
|
|
631
|
+
const left = [
|
|
632
|
+
new THREE.Vector2(0, 0.5),
|
|
633
|
+
new THREE.Vector2(0.333, 0.5),
|
|
634
|
+
new THREE.Vector2(0.333, 1), new THREE.Vector2(0, 1)
|
|
635
|
+
];
|
|
636
|
+
const right = [
|
|
637
|
+
new THREE.Vector2(0.333, 0.5),
|
|
638
|
+
new THREE.Vector2(0.666, 0.5),
|
|
639
|
+
new THREE.Vector2(0.666, 1),
|
|
640
|
+
new THREE.Vector2(0.333, 1)
|
|
641
|
+
];
|
|
642
|
+
const top = [
|
|
643
|
+
new THREE.Vector2(0.666, 0.5),
|
|
644
|
+
new THREE.Vector2(1, 0.5),
|
|
645
|
+
new THREE.Vector2(1, 1),
|
|
646
|
+
new THREE.Vector2(0.666, 1)
|
|
647
|
+
];
|
|
648
|
+
const bottom = [
|
|
649
|
+
new THREE.Vector2(0, 0),
|
|
650
|
+
new THREE.Vector2(0.333, 0),
|
|
651
|
+
new THREE.Vector2(0.333, 0.5),
|
|
652
|
+
new THREE.Vector2(0, 0.5)
|
|
653
|
+
];
|
|
654
|
+
const front = [
|
|
655
|
+
new THREE.Vector2(0.333, 0),
|
|
656
|
+
new THREE.Vector2(0.666, 0),
|
|
657
|
+
new THREE.Vector2(0.666, 0.5),
|
|
658
|
+
new THREE.Vector2(0.333, 0.5)
|
|
659
|
+
];
|
|
660
|
+
const back = [
|
|
661
|
+
new THREE.Vector2(0.666, 0),
|
|
662
|
+
new THREE.Vector2(1, 0),
|
|
663
|
+
new THREE.Vector2(1, 0.5),
|
|
664
|
+
new THREE.Vector2(0.666, 0.5)
|
|
665
|
+
];
|
|
666
|
+
|
|
667
|
+
this.movieGeometry.faceVertexUvs[0] = [];
|
|
668
|
+
|
|
669
|
+
this.movieGeometry.faceVertexUvs[0][0] = [right[2], right[1], right[3]];
|
|
670
|
+
this.movieGeometry.faceVertexUvs[0][1] = [right[1], right[0], right[3]];
|
|
671
|
+
|
|
672
|
+
this.movieGeometry.faceVertexUvs[0][2] = [left[2], left[1], left[3]];
|
|
673
|
+
this.movieGeometry.faceVertexUvs[0][3] = [left[1], left[0], left[3]];
|
|
674
|
+
|
|
675
|
+
this.movieGeometry.faceVertexUvs[0][4] = [top[2], top[1], top[3]];
|
|
676
|
+
this.movieGeometry.faceVertexUvs[0][5] = [top[1], top[0], top[3]];
|
|
677
|
+
|
|
678
|
+
this.movieGeometry.faceVertexUvs[0][6] = [bottom[2], bottom[1], bottom[3]];
|
|
679
|
+
this.movieGeometry.faceVertexUvs[0][7] = [bottom[1], bottom[0], bottom[3]];
|
|
680
|
+
|
|
681
|
+
this.movieGeometry.faceVertexUvs[0][8] = [front[2], front[1], front[3]];
|
|
682
|
+
this.movieGeometry.faceVertexUvs[0][9] = [front[1], front[0], front[3]];
|
|
683
|
+
|
|
684
|
+
this.movieGeometry.faceVertexUvs[0][10] = [back[2], back[1], back[3]];
|
|
685
|
+
this.movieGeometry.faceVertexUvs[0][11] = [back[1], back[0], back[3]];
|
|
686
|
+
|
|
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;
|
|
690
|
+
|
|
691
|
+
this.scene.add(this.movieScreen);
|
|
692
|
+
} else if (projection === '180') {
|
|
693
|
+
let geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI);
|
|
694
|
+
|
|
695
|
+
// Left eye view
|
|
696
|
+
geometry.scale(-1, 1, 1);
|
|
697
|
+
let uvs = geometry.faceVertexUvs[0];
|
|
698
|
+
|
|
699
|
+
for (let i = 0; i < uvs.length; i++) {
|
|
700
|
+
for (let j = 0; j < 3; j++) {
|
|
701
|
+
uvs[i][j].x *= 0.5;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
|
|
706
|
+
this.movieMaterial = new THREE.MeshBasicMaterial({
|
|
707
|
+
map: this.videoTexture
|
|
708
|
+
});
|
|
709
|
+
this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
|
|
710
|
+
// display in left eye only
|
|
711
|
+
this.movieScreen.layers.set(1);
|
|
712
|
+
this.scene.add(this.movieScreen);
|
|
713
|
+
|
|
714
|
+
// 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];
|
|
718
|
+
|
|
719
|
+
for (let i = 0; i < uvs.length; i++) {
|
|
720
|
+
for (let j = 0; j < 3; j++) {
|
|
721
|
+
uvs[i][j].x *= 0.5;
|
|
722
|
+
uvs[i][j].x += 0.5;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
this.movieGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
|
|
727
|
+
this.movieMaterial = new THREE.MeshBasicMaterial({
|
|
728
|
+
map: this.videoTexture
|
|
729
|
+
});
|
|
730
|
+
this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
|
|
731
|
+
// display in right eye only
|
|
732
|
+
this.movieScreen.layers.set(2);
|
|
733
|
+
this.scene.add(this.movieScreen);
|
|
734
|
+
} else if (projection === 'EAC' || projection === 'EAC_LR') {
|
|
735
|
+
const makeScreen = (mapMatrix, scaleMatrix) => {
|
|
736
|
+
// "Continuity correction?": because of discontinuous faces and aliasing,
|
|
737
|
+
// we truncate the 2-pixel-wide strips on all discontinuous edges,
|
|
738
|
+
const contCorrect = 2;
|
|
739
|
+
|
|
740
|
+
this.movieGeometry = new THREE.BoxGeometry(256, 256, 256);
|
|
741
|
+
this.movieMaterial = new THREE.ShaderMaterial({
|
|
742
|
+
side: THREE.BackSide,
|
|
743
|
+
uniforms: {
|
|
744
|
+
mapped: {
|
|
745
|
+
value: this.videoTexture
|
|
746
|
+
},
|
|
747
|
+
mapMatrix: {
|
|
748
|
+
value: mapMatrix
|
|
749
|
+
},
|
|
750
|
+
contCorrect: {
|
|
751
|
+
value: contCorrect
|
|
752
|
+
},
|
|
753
|
+
faceWH: {
|
|
754
|
+
value: new THREE.Vector2(1 / 3, 1 / 2).applyMatrix3(scaleMatrix)
|
|
755
|
+
},
|
|
756
|
+
vidWH: {
|
|
757
|
+
value: new THREE.Vector2(
|
|
758
|
+
this.videoTexture.image.videoWidth,
|
|
759
|
+
this.videoTexture.image.videoHeight
|
|
760
|
+
).applyMatrix3(scaleMatrix)
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
vertexShader: `
|
|
764
|
+
varying vec2 vUv;
|
|
765
|
+
uniform mat3 mapMatrix;
|
|
766
|
+
|
|
767
|
+
void main() {
|
|
768
|
+
vUv = (mapMatrix * vec3(uv, 1.)).xy;
|
|
769
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);
|
|
770
|
+
}`,
|
|
771
|
+
fragmentShader: `
|
|
772
|
+
varying vec2 vUv;
|
|
773
|
+
uniform sampler2D mapped;
|
|
774
|
+
uniform vec2 faceWH;
|
|
775
|
+
uniform vec2 vidWH;
|
|
776
|
+
uniform float contCorrect;
|
|
777
|
+
|
|
778
|
+
const float PI = 3.1415926535897932384626433832795;
|
|
779
|
+
|
|
780
|
+
void main() {
|
|
781
|
+
vec2 corner = vUv - mod(vUv, faceWH) + vec2(0, contCorrect / vidWH.y);
|
|
782
|
+
|
|
783
|
+
vec2 faceWHadj = faceWH - vec2(0, contCorrect * 2. / vidWH.y);
|
|
784
|
+
|
|
785
|
+
vec2 p = (vUv - corner) / faceWHadj - .5;
|
|
786
|
+
vec2 q = 2. / PI * atan(2. * p) + .5;
|
|
787
|
+
|
|
788
|
+
vec2 eUv = corner + q * faceWHadj;
|
|
789
|
+
|
|
790
|
+
gl_FragColor = texture2D(mapped, eUv);
|
|
791
|
+
}`
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
const right = [
|
|
795
|
+
new THREE.Vector2(0, 1 / 2),
|
|
796
|
+
new THREE.Vector2(1 / 3, 1 / 2),
|
|
797
|
+
new THREE.Vector2(1 / 3, 1),
|
|
798
|
+
new THREE.Vector2(0, 1)
|
|
799
|
+
];
|
|
800
|
+
const front = [
|
|
801
|
+
new THREE.Vector2(1 / 3, 1 / 2),
|
|
802
|
+
new THREE.Vector2(2 / 3, 1 / 2),
|
|
803
|
+
new THREE.Vector2(2 / 3, 1),
|
|
804
|
+
new THREE.Vector2(1 / 3, 1)
|
|
805
|
+
];
|
|
806
|
+
const left = [
|
|
807
|
+
new THREE.Vector2(2 / 3, 1 / 2),
|
|
808
|
+
new THREE.Vector2(1, 1 / 2),
|
|
809
|
+
new THREE.Vector2(1, 1),
|
|
810
|
+
new THREE.Vector2(2 / 3, 1)
|
|
811
|
+
];
|
|
812
|
+
const bottom = [
|
|
813
|
+
new THREE.Vector2(1 / 3, 0),
|
|
814
|
+
new THREE.Vector2(1 / 3, 1 / 2),
|
|
815
|
+
new THREE.Vector2(0, 1 / 2),
|
|
816
|
+
new THREE.Vector2(0, 0)
|
|
817
|
+
];
|
|
818
|
+
const back = [
|
|
819
|
+
new THREE.Vector2(1 / 3, 1 / 2),
|
|
820
|
+
new THREE.Vector2(1 / 3, 0),
|
|
821
|
+
new THREE.Vector2(2 / 3, 0),
|
|
822
|
+
new THREE.Vector2(2 / 3, 1 / 2)
|
|
823
|
+
];
|
|
824
|
+
const top = [
|
|
825
|
+
new THREE.Vector2(1, 0),
|
|
826
|
+
new THREE.Vector2(1, 1 / 2),
|
|
827
|
+
new THREE.Vector2(2 / 3, 1 / 2),
|
|
828
|
+
new THREE.Vector2(2 / 3, 0)
|
|
829
|
+
];
|
|
830
|
+
|
|
831
|
+
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;
|
|
835
|
+
|
|
836
|
+
for (const vector of face) {
|
|
837
|
+
if (vector.y < lowY) {
|
|
838
|
+
lowY = vector.y;
|
|
839
|
+
}
|
|
840
|
+
if (vector.y > highY) {
|
|
841
|
+
highY = vector.y;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
for (const vector of face) {
|
|
846
|
+
if (Math.abs(vector.y - lowY) < Number.EPSILON) {
|
|
847
|
+
vector.y += contCorrect / height;
|
|
848
|
+
}
|
|
849
|
+
if (Math.abs(vector.y - highY) < Number.EPSILON) {
|
|
850
|
+
vector.y -= contCorrect / height;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
vector.x = vector.x / height * (height - contCorrect * 2) + contCorrect / height;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
this.movieGeometry.faceVertexUvs[0] = [];
|
|
858
|
+
|
|
859
|
+
this.movieGeometry.faceVertexUvs[0][0] = [right[2], right[1], right[3]];
|
|
860
|
+
this.movieGeometry.faceVertexUvs[0][1] = [right[1], right[0], right[3]];
|
|
861
|
+
|
|
862
|
+
this.movieGeometry.faceVertexUvs[0][2] = [left[2], left[1], left[3]];
|
|
863
|
+
this.movieGeometry.faceVertexUvs[0][3] = [left[1], left[0], left[3]];
|
|
864
|
+
|
|
865
|
+
this.movieGeometry.faceVertexUvs[0][4] = [top[2], top[1], top[3]];
|
|
866
|
+
this.movieGeometry.faceVertexUvs[0][5] = [top[1], top[0], top[3]];
|
|
867
|
+
|
|
868
|
+
this.movieGeometry.faceVertexUvs[0][6] = [bottom[2], bottom[1], bottom[3]];
|
|
869
|
+
this.movieGeometry.faceVertexUvs[0][7] = [bottom[1], bottom[0], bottom[3]];
|
|
870
|
+
|
|
871
|
+
this.movieGeometry.faceVertexUvs[0][8] = [front[2], front[1], front[3]];
|
|
872
|
+
this.movieGeometry.faceVertexUvs[0][9] = [front[1], front[0], front[3]];
|
|
873
|
+
|
|
874
|
+
this.movieGeometry.faceVertexUvs[0][10] = [back[2], back[1], back[3]];
|
|
875
|
+
this.movieGeometry.faceVertexUvs[0][11] = [back[1], back[0], back[3]];
|
|
876
|
+
|
|
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;
|
|
880
|
+
|
|
881
|
+
return this.movieScreen;
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
if (projection === 'EAC') {
|
|
885
|
+
this.scene.add(makeScreen(new THREE.Matrix3(), new THREE.Matrix3()));
|
|
886
|
+
} 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);
|
|
898
|
+
// 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);
|
|
907
|
+
// display in right eye only
|
|
908
|
+
this.movieScreen.layers.set(2);
|
|
909
|
+
this.scene.add(this.movieScreen);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
destroy() {
|
|
915
|
+
this.reset();
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
shouldRender() {
|
|
919
|
+
if (!this.container) {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
this.currentPlayback = this.core.activePlayback;
|
|
924
|
+
if (this.currentPlayback && this.currentPlayback.tagName !== 'video' && this.currentPlayback.tagName !== 'audio') {
|
|
925
|
+
//console.warn('PlaybackRatePlugin#shouldRender: Cannot affect rate for playback', currentPlayback);
|
|
926
|
+
return false;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
try {
|
|
930
|
+
const { video360 } = this.options;
|
|
931
|
+
|
|
932
|
+
if (!video360 || !video360.projection || (!video360.forceCardboard && !Browser.isiOS && !Browser.isAndroid)) {
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
} catch (error) {
|
|
936
|
+
LogManager.exception(error);
|
|
937
|
+
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
render() {
|
|
945
|
+
//console.log('PlaybackRatePlugin#render()');
|
|
946
|
+
if (this.shouldRender()) {
|
|
947
|
+
const t = template(pluginHtml);
|
|
948
|
+
const html = t();
|
|
949
|
+
|
|
950
|
+
this.$el.html(html);
|
|
951
|
+
|
|
952
|
+
if (
|
|
953
|
+
Object.prototype.hasOwnProperty.call(this.core.mediaControl, '$vrButton') &&
|
|
954
|
+
this.core.mediaControl.$vrButton.length > 0
|
|
955
|
+
) {
|
|
956
|
+
this.$el.find('.vr-button').append(cardBoard);
|
|
957
|
+
this.core.mediaControl.$vrButton.append(this.$el);
|
|
958
|
+
} else {
|
|
959
|
+
this.core.mediaControl.$('.media-control-right-panel').append(this.el);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
get template() {
|
|
965
|
+
return template(pluginHtml);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
onStartAd() {
|
|
969
|
+
this.advertisement = true;
|
|
970
|
+
this.reset();
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
onFinishAd() {
|
|
974
|
+
this.advertisement = false;
|
|
975
|
+
if (this.loadMetadata) {
|
|
976
|
+
this.init();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|