【问题标题】:react native audio - playback failed due to audio decoding error?反应原生音频 - 由于音频解码错误而播放失败?
【发布时间】:2021-07-04 02:48:17
【问题描述】:

我尝试从 react-native-audio 中的 url 播放音频文件。音频管理器在加载音频文件之前尝试播放音频文件...

我在 git hub 中查找了这个问题,但没有一个解决方案有效...希望它对您有所帮助,因为它在 android 中对我有用...

playback failed due to audio decoding error
static play(audioPath) {
    setTimeout(() => {
      if (Platform.OS === "ios") { 
        Sound.enable(true);
      }
      const sound = new Sound(audioPath, "", (error) => {
        if (error) {
          console.log("failed to load the sound", error);
        }
      });

      setTimeout(() => {
        sound.play((success) => {
          if (success) {
            console.log("successfully finished playing");
          } else {
            // HERE WhAT I Did was just recurr this same function until and unless the audio is download properly and played successfully
            console.log("Error Occurred Retrying");

          }
        });
      }, 100);
    }, 100);

【问题讨论】:

    标签: reactjs react-native react-redux rxjs react-router


    【解决方案1】:

    由于音频解码错误,播放失败

    static play(audioPath) {
        setTimeout(() => {
          if (Platform.OS === "ios") { 
            Sound.enable(true);
          }
          const sound = new Sound(audioPath, "", (error) => {
            if (error) {
              console.log("failed to load the sound", error);
            }
          });
    
          setTimeout(() => {
            sound.play((success) => {
              if (success) {
                console.log("successfully finished playing");
              } else {
                // HERE WhAT I Did was just recurr this same function until and unless the audio is download properly and played successfully
                console.log("Error Occurred Retrying");
    
                this.play(audioPath);
              }
            });
          }, 100);
        }, 100);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-24
      • 2022-08-23
      • 1970-01-01
      • 1970-01-01
      • 2018-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多