2017-02-09 38 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版應用。