首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Expo-AV播放S3音频

使用Expo-AV播放S3音频
EN

Stack Overflow用户
提问于 2019-08-16 21:24:01
回答 1查看 940关注 0票数 2

我正试着用s3 -av播放我的aws av存储桶中的音频,但它不起作用。这是我第一次使用expo-av,但我认为问题出在将源url指向我的aws API。下面是我的代码。我很确定我搞砸了,所以对答案的解释将是非常感谢的。

代码语言:javascript
复制
 Audio.setIsEnabledAsync(true)

    Audio.setAudioModeAsync(
      {playsInSilentModeIOS : true,
        allowsRecordingIOS : true,
        staysActiveInBackground : true,
        interruptionModeIOS : {
          interruptionModeIOS : true,
          INTERRUPTION_MODE_IOS_DO_NOT_MIX: true,
          INTERRUPTION_MODE_IOS_DUCK_OTHERS: true,
        },
        interruptionModeAndroid : {
          INTERRUPTION_MODE_ANDROID_DO_NOT_MIX: true,
          INTERRUPTION_MODE_ANDROID_DUCK_OTHERS: true,

        },
        playThroughEarpieceAndroid: true,
      }
    )

    export default class Audiol extends Component {

    state = {
        ...
      };

   componentDidMount() {
    Storage.get(this.props.a)
            .then(result =>{ console.log("Storageb");
             const Me = result;
             this.setState({Audio: Me})
             console.warn("geb")

            })
            .catch(err => console.log("S.ERROR",err))

    }

    async handleaudio() {
      const soundObject = new Audio.Sound;
        try {
          soundObject.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
          await soundObject.loadAsync({uri: this.state.Audio}, {}, true);

          console.warn("success")
        } catch (error) {
          console.warn("error", error, this.state.Audio)
          // An error occurred!
        }      
      }

更新:我注意到这个错误只有在我使用this.state.Audio的时候才会出现,如果我使用的是state.Audio给出的确切链接,如下所示。

代码语言:javascript
复制
await soundObject.loadAsync({uri: 'https://...amazonaws.com/...'});

但我需要它和州立大学合作。

希望有人能帮助我。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-08-16 23:27:11

您能在try期间向我们提供this.state.audio的结果吗

您还可以在handleaudio函数中尝试以下代码:

const myAudio = Audio.Sound.createAsync({uri: this.state.Audio}, {}, true); myAudio.playbackInstance.playAsync()

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57525468

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档