如何以本机播放背景视频?

时间:2020-11-11 10:40:04

标签: react-native expo

我正在尝试以本机方式播放背景视频,但我遇到的问题/错误对我来说真的没有意义。

我是本机反应的新手。

这是我的完整代码:

  import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
import { Video } from 'expo'

// You can import from local files
import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default function App() {
  return (
    <View style={styles.container}>
      <Text style={styles.paragraph}>
        Change code in the editor and watch it change on your phone! Save to get a shareable url.
      </Text>
      <Card>
        <AssetExample />
      </Card>


      <Video
      source={{ uri: "https://s3-eu-west-1.amazonaws.com/video.gallereplay.com/artistarea/Lighthouse%20stands%20in%20Istanbul%E2%80%99s%20harbour_0554659b-5dc1-43d6-8a93-b31ec6b67f63/Cinemagraph_plain/1920x1080/cinemagraph.mp4"}}
      style={styles.backgroundVideo}
      rate={1}
      shouldPlay={true}
      isLooping={true}
      volume={1}
      muted={true}
      resizeMode="cover"
      />


    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  }, 
  backgroundVideo: {
    position: 'absolute',
    top: 0,
    left: 0,
    bottom: 0,
    right: 0,
  },
});

我得到的错误是:

Error: Minified React error #130; visit [snack internals]
    at Fl ([snack internals]
    at p ([snack internals]
    at g ([snack internals]
    at [snack internals]
    at ki ([snack internals]
    at ms ([snack internals]
    at dl ([snack internals]
    at sl ([snack internals]
    at Zs ([snack internals]
    at https://snack.expo.io/web-player/39/static/js/2.208ff912.chunk.js:2:4091769

如果仅将我的代码复制/粘贴到快餐.expo.io网站上,您也会在该位置看到错误。

有人可以请教这个问题吗?

1 个答案:

答案 0 :(得分:0)

尝试将onInit: function () { this.getView().byId("myInputLinkId").attachBrowserEvent('click',function(){ window.open("https://stackoverflow.com/");}); }更改为import {Video} from 'expo'