【问题标题】:React-Native play video using expo sdkReact-Native 使用 expo sdk 播放视频
【发布时间】:2017-07-06 08:30:17
【问题描述】:

我想使用 expo sdk 播放来自 url 的视频以进行本机反应。我阅读了 sdk,但我无法理解如何使其工作。 Here is link for expo sdk video docs.

这是我的代码

 import React from 'react';
import { StyleSheet, Text, View,Button } from 'react-native';
import { Video } from 'expo';

export default class App extends React.Component {
    _handleVideoRef = component => {

    }

    onPlayPressed(){

    }

  render() {

    return (
      <View style={styles.container}>
            <Expo.Video
            source = {{uri :'url for video'}}
            ref={this._handleVideoRef}

            />
            <Text>Open up App.js to start working on your app! </Text>
            <Button onPress={this.onPlayPressed.bind(this)} title = "Play"/>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

文档说视频标签作为内联标签工作,但我不确定为什么它不播放视频或需要其他任何东西。

感谢您的帮助

【问题讨论】:

    标签: android ios react-native expo


    【解决方案1】:
    import { Video } from 'expo';
    

    您将Expo.Video 模块导入为Video,但您正尝试通过Expo.Video 使用该组件。

    <Video
      source = {{uri :'url for vide'}}
      ref={this._handleVideoRef}
    />
    

    像这样使用它。不是Expo.Video

    【讨论】:

    • 我按你说的改了,但是不能播放视频。
    猜你喜欢
    • 1970-01-01
    • 2022-08-10
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    • 2022-12-15
    • 2021-02-04
    • 1970-01-01
    相关资源
    最近更新 更多