2017-02-09 37 views
1

我试图用react-native-video插件显示视频。在设备上进行测试时,视频正在工作,但在iOS模拟器上显示黑屏(模拟器上的测试对我来说更快,更容易)。有人有同样的问题。这里是我的代码:在iOS模拟器上测试时的黑屏视频

    <Video 
        source={{ uri: 'url' }} // Can be a URL or a local file. 
        ref={(ref) => { this.player = ref; }}        // Store reference 
        rate={1.0}      // 0 is paused, 1 is normal. 
        volume={1.0}     // 0 is muted, 1 is normal. 
        muted={false}     // Mutes the audio entirely. 
        paused={this.state.paused}     // Pauses playback entirely. 
        resizeMode="cover"    // Fill the whole screen at aspect ratio. 
        repeat={false}    // Repeat forever. 
        playInBackground={false}  // Audio continues to play when app entering background. 
        playWhenInactive={false}  // [iOS] Video continues to play when control or notification center are shown. 
        progressUpdateInterval={250.0} // [iOS] Interval to fire onProgress (default to ~250ms) 
        onLoadStart={this.loadStart} // Callback when video starts to load 
        onLoad={this.setDuration}  // Callback when video loads 
        onProgress={this.setTime}  // Callback every ~250ms with currentTime 
        onEnd={this.onEnd}    // Callback when playback finishes 
        onError={this.videoError}  // Callback when video cannot be loaded 
        onBuffer={this.onBuffer} // Callback when remote video is buffering 
        style={styles.backgroundVideo} 
       /> 

回答

0

模拟器旨在帮助您设计,快速原型和测试您的应用程序,但它不应该成为你的唯一的测试平台。其中一个原因是,并非所有的应用程序都可以在模拟器中使用。例如,相机应用程序仅在硬件设备上可用,并且不能在模拟器中复制。

模拟器不会使用您电脑的相机,所以无论何时您使用相机进行任何操作,它都会默认为黑屏。

更多信息:https://developer.apple.com/library/content/documentation/IDEs/Conceptual/iOS_Simulator_Guide/GettingStartedwithiOSSimulator/GettingStartedwithiOSSimulator.html

0

你的代码是好的,但你不能在任何模拟器播放视频,你需要运行在真实设备Android或iOS版应用。