首页 > 解决方案 > 播放存储在 AWS S3 中的音频文件

问题描述

我已经通过 Nodejs 成功将一些音频文件上传到 AWS,文件 url 也从我的函数返回。我计划将此 url 保存在 MongoDB Atlas 中作为对原始文件的引用,但在此之前,我尝试在我的移动应用程序中播放该文件(来自该 url),但它不会播放。

该文件是.m4a格式。如何让它在任何移动和网络音频播放器中工作?我对两者都使用颤振。我不想piping, chunking and streaming手动进行,因为这只是系统的虚拟测试。应用程序中使用的原始文件会大得多。

这是文件网址https://empty-bouquet.s3.af-south-1.amazonaws.com/Dax+-Dear+God.m4a。谢谢

标签: node.jsamazon-web-servicesflutteramazon-s3audio-streaming

解决方案


.m4a audios aren't natively streamed from S3, but after a test I can verify that .mp3 files are. Most browsers will recognize that filetype and render a built-in player for you.

You can convert from one format to another using a lot of free tools. I used Audacity.

And yes, you need to make at least the file public. Or if you're going to do this a lot I would recommend making a bucket policy that makes everything public, no matter what you throw in there.


推荐阅读