我在iPad上运行一个非常简单的反应原生(使用Expo)测试应用程序(参见下面的代码)。
问题是,每当我暂停播放视频后,应用程序会挂起一段时间,然后播放速度非常快,就像试图补偿一样。
我在Android设备上尝试过相同的代码,但它按预期工作。
还有其他人经历过这个吗?我有什么不同的做法吗?
这是应用程序:
import React from "react";
import { StyleSheet, Text, View, TouchableWithoutFeedback } from "react-native";
import { Video } from "expo";
export default class App extends React.Component {
state = { isPlaying: true };
toggleVideo = () => {
const { isPlaying } = this.state;
if (isPlaying) {
this.video.pauseAsync();
} else {
this.video.playAsync();
}
this.setState({ isPlaying: !isPlaying });
};
render() {
return (
<View style={styles.container}>
<TouchableWithoutFeedback onPress={this.toggleVideo}>
<Video
source={{
uri: "http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4"
}}
rate={1.0}
volume={1.0}
isMuted={false}
resizeMode="contain"
shouldPlay
isLooping
style={{ width: "100%", height: "100%" }}
ref={video => (this.video = video)}
/>
</TouchableWithoutFeedback>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});