我已经使用react-native视频播放音频文件,它在android上工作正常,但在ios上它无法触发onLoad和onProgress函数,我用它来获取持续时间和进度。以下是我的代码。
<Video source={{ uri: songPlaying.url }}
ref="audio"
volume={this.state.muted ? 0 : 1.0}
muted={false}
paused={!this.state.playing}
onLoad={this.onLoad.bind(this)}
onProgress={this.setTime.bind(this)}
onEnd={this.onEnd.bind(this)}
resizeMode="cover"
repeat={false} />
onLoad(params) {
this.setState({ songDuration: params.duration });
}
//called in onProgress to set time.
setTime(params) {
if (!this.state.sliding) {
this.setState({ currentTime: params.currentTime });
}
}