-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviroTheatre.js
151 lines (131 loc) · 3.79 KB
/
viroTheatre.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
import React, { Component } from 'react';
import { StatusBar } from 'react-native';
import {
ViroScene,
ViroVideo,
ViroMaterials,
Viro360Image,
ViroButton,
ViroImage,
ViroNode,
ViroAnimations,
} from '@viro-community/react-viro';
var createReactClass = require('create-react-class');
var buttonSize = 0.25;
var VIDEO_REF = "videoref";
var videos = [
{uri:'./res/rickRoll.mp4'},
{uri:'./res/rickRoll.mp4'}
];
var ViroTheatre = createReactClass({
getInitialState() {
return {
videoControlsAnimation:"fadeIn",
videoPaused: false,
loopVideo: true,
videoIndex: 0,
runAnimation: false,
}
},
render: function() {
const source = this.props.sceneNavigator.viroAppProps
console.log(source)
return (
<ViroScene onClick={this._onVideoTapped} reticleEnabled={this.state.videoControlsAnimation=="fadeIn"}>
<StatusBar hidden={true} />
<Viro360Image source={require('./res/dark_theatre.jpg')} />
<ViroVideo ref={VIDEO_REF} source={source?require('./res/DocSta.mp4'):require('./res/rickRoll.mp4')} volume={1.0}
position={[0, 3.9, -45]} scale={[44, 22, 1]} loop={this.state.loopVideo}
paused={this.state.videoPaused} />
{this._renderVideoControl()}
</ViroScene>
);
},
_onVideoTapped(){
var videoControlsAnimationState = this.state.videoControlsAnimation;
if (videoControlsAnimationState=="fadeIn"){
videoControlsAnimationState="fadeOut";
} else {
videoControlsAnimationState="fadeIn";
}
this.setState({
videoControlsAnimation:videoControlsAnimationState,
runAnimation:true,
});
},
_renderVideoControl(){
return(
<ViroNode position={[0,-0.8,0]} opacity={1.0}
animation={{ name : this.state.videoControlsAnimation, run : this.state.runAnimation, loop : false}} >
<ViroImage
scale={[1.4, 1.2, 1]}
position={[0, -0.27,-2.1]}
source={require("./res/player_controls_container.png")} />
{this._renderPlayControl()}
</ViroNode>
);
},
_renderPlayControl(){
if (this.state.videoPaused){
return (
<ViroButton
position={[0,0,-2]}
scale={[1, 1, 1]}
width={buttonSize}
height={buttonSize}
source={require("./res/play.png")}
hoverSource={require("./res/play_hover.png")}
clickSource={require("./res/play_hover.png")}
onClick={this._togglePauseVideo}/>
);
} else {
return (
<ViroButton
position={[0,0,-2]}
scale={[1, 1, 1]}
width={buttonSize}
height={buttonSize}
source={require("./res/pause.png")}
hoverSource={require("./res/pause_hover.png")}
clickSource={require("./res/pause_hover.png")}
onClick={this._togglePauseVideo}/>
);
}
},
_togglePauseVideo() {
this.setState({
videoPaused: !this.state.videoPaused,
})
},
_playPreviousVideo(){
var currentVideo = this.state.videoIndex;
if (currentVideo - 1 > -1){
this.setState({
videoIndex: (currentVideo - 1),
videoPaused: false
});
}
},
_playNextVideo(){
var currentVideo = this.state.videoIndex;
if (currentVideo + 1 < videos.length){
this.setState({
videoIndex: (currentVideo + 1),
videoPaused: false
});
}
},
});
ViroAnimations.registerAnimations({
fadeOut:{properties:{opacity: 0.0}, duration: 500},
fadeIn:{properties:{opacity: 1.0}, duration: 500},
});
ViroMaterials.createMaterials({
opaqueWhite: {
shininess: 2.0,
lightingModel: "Lambert",
diffuseColor: "#FFFFFF"
},
});
module.exports = ViroTheatre;