gpt4 book ai didi

ios - react-native-video onLoad onProgress 不工作 IOS

转载 作者:行者123 更新时间:2023-12-05 07:38:58 25 4
gpt4 key购买 nike

我已经使用 react-native video 播放音频文件,它在 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 });
}
}

最佳答案

我正在使用 react-native-video-player 并且我在 IOS 上遇到了这个 onLoad 问题。因此,作为解决方法,我在 onLoadStart 事件中将加载设置为 true,并在 onVideoBuffer 以及 onLoad 中将加载设置为 false >onVideoLoad。这对我来说在 IOS 和 Android 上都运行良好。这是示例代码

<VideoPlayer 
onVideoBuffer={() => setisLoading(false)}
onLoadStart={() => setisLoading(true)}
onVideoLoad={() => setisLoading(false)}
onLoad={() => setisLoading(false)}
thumbnail={{ uri: item?.thumbnailUrl }}
controls={false}

paused={!autoplay || pause}
video={{
uri: item?.videoUrl,
}}
/>

关于ios - react-native-video onLoad onProgress 不工作 IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47453511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com