React native 视频启动时调用react native video ONED

React native 视频启动时调用react native video ONED,react-native,React Native,当Iconsole.log()位于视频组件的oned函数中时,它会在加载页面时立即被调用。同时调用的onPress菜单中的console.log()。我使用reporeact native router flux中的Actions.videoPlayer()在点击此视频的缩略图时转到此页面 render() { let video = require('../videos/HISTORISCHETUIN.mp4'); return ( <View> <Touch

当I
console.log()
位于视频组件的
oned
函数中时,它会在加载页面时立即被调用。同时调用
onPress
菜单中的
console.log()
。我使用repo
react native router flux
中的
Actions.videoPlayer()
在点击此视频的缩略图时转到此页面

render() {
let video = require('../videos/HISTORISCHETUIN.mp4');

 return (
  <View>
    <TouchableHighlight onPress={console.log("Test")}>
      <View>
        <Video source={video}   // 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={true}                 // Pauses playback entirely.
               resizeMode="stretch"             // Fill the whole screen at aspect ratio.
               repeat={true}                  // 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.player.seek(30);
                          }}      // Callback when video loads
               onProgress={this.setTime}      // Callback every ~250ms with currentTime
               onEnd={console.log("Test")}             // Callback when playback finishes
               onError={this.videoError}      // Callback when video cannot be loaded
               style={styles.video} />
      </View>
    </TouchableHighlight>
  </View>
)
render(){
let video=require('../videos/HISTORISCHETUIN.mp4');
返回(
this.player=ref}//存储引用
速率={1.0}//0暂停,1正常。
卷={1.0}//0为静音,1为正常。
静音={false}//完全静音音频。
暂停={true}//完全暂停播放。
resizeMode=“stretch”//以纵横比填充整个屏幕。
repeat={true}//永远重复。
playInBackground={false}//当应用程序进入后台时,音频将继续播放。
playWhenInactive={false}/[iOS]视频在显示控制或通知中心时继续播放。
progressUpdateInterval={250.0}/[iOS]在Progress上触发的间隔(默认为~250ms)
onLoadStart={this.loadStart}//视频开始加载时的回调
onLoad={()=>{
这个.player.seek(30);
}}//加载视频时回调
onProgress={this.setTime}//使用currentTime每隔250ms进行一次回调
onEnd={console.log(“Test”)}//回放完成时回调
OneError={this.videoError}//无法加载视频时回调
style={style.video}/>
)
}


为什么在视频结束后它不调用
console.log()
?当我按下视频时,它也不会做任何事情。

那是因为你需要将它包装成一个收尾

此代码:

onEnd={console.log('123')}
当呈现组件时,当道具实际需要功能时,将立即执行
控制台.log

要修复它,请使用:

onEnd={() => console.log('123')}
在这里,您给了prop一个它可以执行的函数,而不是
console.log
的结果