gpt4 book ai didi

react-native - 无法在 react 原生视频中暂停

转载 作者:行者123 更新时间:2023-12-01 19:36:03 25 4
gpt4 key购买 nike

我想播放一个音频文件,但它正在自动播放,我无法暂停。

我该如何解决?
必须在开始时暂停
我的代码:

import Video from 'react-native-video';

export default class Android extends Component {
constructor(props) {
super(props)
this.state = {
paused: true,
}
}

video: Video;

render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
<Video
ref={(ref: Video) => { this.video = ref }}
source={{ uri: "http://s3.picofile.com/d/7376893331/8b7bc5b4-4b5e-47c4-96dd-b0c13fd18157/Sara_Diba_Delbare_Man.mp3", mainVer: 1, patchVer: 0 }}
paused={this.state.paused}
/>
</View>
);
}
}

最佳答案

当前在 react-native-video 中有一个错误哪里pause首次加载组件时会忽略标志。你要改pause在组件加载后。

首先,确保您的 this.state.pause = false .然后:

<Video
paused={this.state.paused}
onLoad={() => {
this.setState({
paused: true
});
}}
</Video>

上下文: https://github.com/react-native-community/react-native-video/issues/494#issuecomment-281853423

关于react-native - 无法在 react 原生视频中暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45932478/

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