在 ReactVR for VideoPano的文档中
它演示了指向代码库中的视频。
是否可以链接到外部链接(又名 Youtube)?
let videoUrl = 'video.webm';
const supportedFormats = NativeModules.VideoModule.supportedFormats;
for (let i = 0; i < supportedFormats.length; i++) {
if (supportedFormats[i] === 'mp4') {
videoUrl = 'video.mp4';
}
}
其余代码如下所示。
class WelcomeToVR extends React.Component {
constructor(props) {
super(props);
this.state = {
playerState: new MediaPlayerState({autoPlay: true, muted: true}), // init with muted, autoPlay
};
}
render() {
return (
<View>
<VideoPano
playerState={this.state.playerState}
source={asset(videoUrl, {layout: 'SPHERE'})}
/>
<VideoControl
style={{
height: 0.2,
width: 4,
layoutOrigin: [0.5, 0.5, 0],
transform: [{translate: [0, 0, -4]}],
}}
playerState={this.state.playerState}