小编Ant*_* h.的帖子

我无法正确使用 Expo 实例中的 Audio.Sound。我无法暂停或更新播放状态

当我尝试暂停或更新由 创建的声音对象的状态时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)

audio reactjs react-native expo

5
推荐指数
1
解决办法
5843
查看次数

标签 统计

audio ×1

expo ×1

react-native ×1

reactjs ×1