简体   繁体   English

是否可以将音频作为Blob数据存储在javascript / jQuery中?

[英]Is it possible to store audio as blob data in javascript/jQuery?

I know you can store images as blob data and then have that blob data put within an image tag, which will display as it would with a regular image file. 我知道您可以将图像存储为Blob数据,然后将该Blob数据放入image标记中,该标记将像常规图像文件一样显示。 Is this possible with audio as well? 音频也可以吗? I want to do this because I want it so that the audio is recorded, saved as blob data, and then sent to a server where then other users can access that blob data and replay the audio simply from that blob data. 我想要这样做是因为我想要记录音频,将其保存为Blob数据,然后将其发送到服务器,然后其他用户可以访问该Blob数据并仅从该Blob数据中重放音频。

Yes, it is also possible with Audio - in browsers that implement Blob URLs, anyway. 是的,无论如何,在实现Blob URL的浏览器中,音频也可以实现。

The browser simply (and universally) knows how to 'read' blob URLs, as it does any valid URL. 浏览器简单(并且普遍)知道如何“读取” blob URL,因为它可以处理任何有效的URL。 Only, instead of making a request it accesses the local blob cache. 仅,不是发出请求,而是访问本地Blob缓存。

Data URLs work in the same manner and are probably easier to use when 'transferring data from the server' - as their name implies they contain all the data embedded within the URL. 数据URL以相同的方式工作,并且在“从服务器传输数据”时可能更易于使用-因为它们的名称暗示它们包含URL中嵌入的所有数据。 For downloading previously shared content, consider keeping the Audio stream a separate resource and using normal URLs / resources. 要下载以前共享的内容,请考虑将音频流保留为单独的资源,并使用常规的URL /资源。

Anyway, for the details like how to actually capture the data, see Capturing Audio & Video in HTML5 . 无论如何,有关如何实际捕获数据的详细信息,请参阅在HTML5中捕获音频和视频

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM