音频元素源的 HTML5 本地存储 - 有可能吗? [英] HTML5 Local Storage of audio element source - is it possible?

查看:19
本文介绍了音频元素源的 HTML5 本地存储 - 有可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在试验 html5 的音频和本地存储功能,但遇到了一些让我难堪的事情.

I've been experimenting with the audio and local storage features of html5 of late and have run into something that has me stumped.

我希望能够在本地缓存或存储音频元素的源,以实现更快的离线播放.问题是我看不到当前的实现是如何实现的.

I'd like to be able to cache or store the source of the audio element locally to enable speedier and offline playback. The problem is I can't see how this is possible with the current implementation.

我使用 WebKit 尝试了以下操作:

I have tried the following using WebKit:

  1. 正在创建清单文件以设置本地缓存,但音频文件似乎不是可缓存的项目,可能是因为它是流式传输方式或其他原因

  1. Creating a manifest file to set up local caching but the audio file appears not to be a cacheable item maybe due to the way it is stream or something

我还尝试使用 javascript 将音频对象放入本地存储,但由于内存问题(我认为),mp3 的大小使这无法实现.

I have also attempted to use javascript to put an audio object into local storage but the size of the mp3 makes this impossible due to memory issues (i think).

我尝试使用数据 uri 和 base64 将 html 用作可以缓存的音频传输,但文件大小再次使这令人望而却步.此外,音频元素在 WebKit 中似乎不喜欢这个(在 mozilla 中工作正常)

I have tried to use the data uri and base64 to use the html as a audio transport that can be cached but again the filesize makes this prohibitive. Also the audio element does not seem to like this in WebKit (works fine in mozilla)

我尝试了几种将数据放入本地数据库存储的方法.再次遇到与其他案例相同的问题.

I have tried several methods of putting the data into the local database store. Again suffering the same issues as the other cases.

我很想听听大家对如何使用 WebKit 中的缓存/本地存储实现离线播放目标的任何其他想法.

I'd love to hear any other ideas anyone may have as to how I could achieve my goal of offline playback using caching/local storage in WebKit.

推荐答案

所以我问这个问题已经有一段时间了,我想我会提供一些关于我们如何解决它的信息.基本上,我们使用与此类似的技术将数据编码为 PNG:

So it's been a while since I asked this question and I thought i'd give some info about how we solved it. Basically we encoded the data into PNG's using a similar technique to this:

http://audioscene.org/scene-files/yury/pngencoding/sample.html

然后使用html5本地存储将图像缓存在移动设备上并根据需要访问它.PNG 非常大,但这对我们有用.

Then cached the image on the mobile device using html5 local storage and accessed it as needed. The PNG's were pretty big but this worked for us.

这篇关于音频元素源的 HTML5 本地存储 - 有可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆