在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}
                />

模拟器旨在帮助您设计、快速原型设计和测试您的应用,但它绝不应作为您唯一的测试平台。一个原因是并非所有应用程序在模拟器中都可用。例如,"相机"应用仅在硬件设备上可用,无法在模拟器中复制。

模拟器不会使用您计算机的摄像头,因此无论何时您使用摄像头进行任何操作,它都会默认为黑屏。

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

您的代码很好,但您无法在任何模拟器中播放视频,您需要在 android 或 iOS 的真实设备中运行该应用程序。

最新更新