当我尝试暂停或更新由 创建的声音对象的状态时Audio.Sound(),出现错误指示声音未加载。
Error : Cannot complete operation because sound is not loaded.
我不明白,因为我从加载文件并播放它的同一对象调用了该方法。
这是我的代码:
import React, { useState, useEffect } from "react";
import { Feather } from "@expo/vector-icons";
import {
StyleSheet,
Text,
View,
Button,
FlatList,
TouchableOpacity,
Image
} from "react-native";
import { Audio } from "expo-av";
const imageLocation = "./../assets/bibliotheque";
const soundLocation = "./../sounds/bibliotheque";
export default BibliothequeScreen = ({ navigation }) => {
const [playing, setPlaying] = useState(false);
const [soundPlaying, setSoundPlaying] = useState(false);
const soundObject = new Audio.Sound(); …Run Code Online (Sandbox Code Playgroud)