简体   繁体   English

iPhone Web应用程序:HTML5数据库和音频文件

[英]iPhone web-app: HTML5 database and audio files

I'm having issues with audio files on the iPhone web-app. 我在iPhone网络应用程序上的音频文件有问题。 Seems as each time an audio file is played, it's loaded first then played, even if repeating the same audio on a page that hasn't refreshed (done via javascript). 似乎每次播放音频文件时,先加载它,然后再播放,即使在未刷新的页面上重复相同的音频(通过javascript完成)。 From what I've research manifest files would be great but they are for offline application. 根据我的研究,清单文件可能很棒,但是它们是供离线应用程序使用的。 I'm now researching HTML5 databases. 我现在正在研究HTML5数据库。

Does anyone know if HTML5 databases can store audio files such as mp3? 有谁知道HTML5数据库是否可以存储mp3等音频文件? The end result it then to pull the mp3 from the database. 最终结果便是从数据库中提取mp3。 It might still have to load the file each time from the database but I'm hoping it's quicker than retrieving it from a server. 每次仍可能必须从数据库加载文件,但我希望它比从服务器检索文件更快。

Thank you. 谢谢。

I think what you are after is possible , however you have a significant hurdle in that the implementation of HTML5 databases on most browsers is limited to 5mb as per w3c recommendations: 我认为您可以追求的目标是可能的 ,但是按照w3c的建议,大多数浏览器上的HTML5数据库实施限制为5mb ,这是您遇到的重大障碍

A mostly arbitrary limit of five megabytes per origin is recommended. 建议每个源的最大限制为5 MB。

Having said that the way its implemented in iPhone Safari is that databases can grow until they reach 5MB in size at which point the browser will ask the user if they wish to allow for the extra size, asking again at 10, 50, 100 and 500MB (see section "Estimated Database Size" in this post by html5doctor ). 话虽如此,它在iPhone Safari中的实现方式是数据库可以增长直到达到5MB大小,此时浏览器将询问用户是否希望允许额外的大小,并再次询问10、50、100和500MB (请参阅html5doctor此文章中的 “估计的数据库大小” 部分 )。

There is no limit on the number of databases you can build per domain in safari, however according to this post by Cantina Consulting you can have a total of 50MB across all databases in a single domain . 对于 每个域可以在safari中建立的数据库数量没有限制 ,但是根据Cantina Consulting的这篇文章单个域中的所有数据库总共可以有50MB

Given these parameters, a possible work-around for this implementation is to split your mp3 blobs across multiple databases , creating a new database each time your reach 4.9MB, however even if you follow this design it may not be ideal as you will still experience the following: 给定这些参数,此实现的一种可能的解决方法是将mp3 blob分散到多个数据库中 ,每次达到4.9MB时创建一个新数据库,但是,即使按照这种设计,它仍然不是理想的选择,因为您仍然会遇到下列:

  • 50MB is not a lot of audio files, a typical 5/6min song is about 5MB at 128Khz, so that only gives you space for about 1CD (60 min) of mp3 songs, after this you will need user cooperation to use additional database space. 50MB并不是很多音频文件,典型的5 / 6min歌曲在128Khz时约为5MB,因此仅给您约1CD(60分钟)的mp3歌曲空间,此后,您需要用户合作才能使用额外的数据库空间。
  • You will still have significant security issues trying to play the mp3 blobs from the javascript runtime, it may be possible to bypass these tricking flash into thinking they are mp3 stream but I'm not sure how you'd go about it. 尝试从javascript运行时播放mp3 blob时,您仍然会遇到重大的安全问题,可能有可能绕过这些欺骗性的闪存,以为它们是mp3流,但我不确定您会怎么做。

Feel free to have a play around with this iPhone HTML5 SQL Client I put together, you may want to use something similar for experimenting with your local mp3 Database. 随意玩一下我放在一起的iPhone HTML5 SQL Client ,您可能想使用类似的方法来尝试本地mp3数据库。

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

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