如何在通过 GPRS 在 iPhone 浏览器上播放的 HTML 页面上嵌入音频/视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/87290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to embed audio/video on HTML page that plays on iPhone browser over GPRS
提问by pythonquick
Although I don't have an iPhone to test this out, my colleague told me that embedded media files such as the one in the snippet below, only works when the iphone is connected over the WLAN connection or 3G, and does not work when connecting via GPRS.
虽然我没有 iPhone 来测试这一点,但我的同事告诉我,嵌入媒体文件(例如下面的片段中的那个)仅在 iPhone 通过 WLAN 连接或 3G 连接时有效,而在连接时无效通过GPRS。
<html><body>
<object data="http://joliclic.free.fr/html/object-tag/en/data/test.mp3" type="audio/mpeg">
<p>alternate text</p>
</object>
</body></html>
Is there an example URL with a media file, that will play in an iPhone browser when the iphone connects using GPRS (not 3G)?
是否有带有媒体文件的示例 URL,当 iPhone 使用 GPRS(不是 3G)连接时,它将在 iPhone 浏览器中播放?
采纳答案by benzado
The iPhone YouTube application automatically downloads lower quality video when connected via EDGE than when connected via Wi-Fi, because the network is much slower. That fact leads me to believe Apple would make the design decision to not bother downloading an MP3 over EDGE. The browser has no way to know in advance if the bit rate is low enough, and chances are, it won't be. So rather than frustrate the users with a sound file that takes too long to play (and prevents thems from receiving a call while downloading), it's better to spare them the grief and encourage them to find a Wi-Fi hotspot.
与通过 Wi-Fi 连接相比,iPhone YouTube 应用程序在通过 EDGE 连接时会自动下载质量较低的视频,因为网络速度要慢得多。这个事实让我相信 Apple 会做出设计决定,不再费心通过 EDGE 下载 MP3。浏览器无法提前知道比特率是否足够低,而且很有可能不会。因此,与其用播放时间过长的声音文件(并阻止他们在下载时接听电话)来挫败用户,不如让他们免于悲伤并鼓励他们找到 Wi-Fi 热点。
回答by Diogenes
Try something like this, it works on a web page. This is actually a 320kps mp3 but it is only 30 seconds long. You can use a program called LAME to convert mp3's to a bitrate you that will work for you.
尝试这样的事情,它适用于网页。这实际上是一个 320kps 的 mp3,但它只有 30 秒长。您可以使用名为 LAME 的程序将 mp3 转换为适合您的比特率。
<div class="music">
<p>Pachelbel's Canon</p>
<!--[if !IE]>-->
<object id="Cannon" type="audio/mpeg" data="http://calgarydj.ca/sound%20files/Pachebels%20Cannon.mp3" width="250" height="16">
<param name="autoplay" value="false" />
<param name="src" value="http://calgarydj.ca/sound%20files/Pachebels%20Cannon.mp3" />
<!--<![endif]-->
<object id="Cannon" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="250" height="60">
<param name="autostart" value="false" />
<param name="url" value="http://calgarydj.ca/sound%20files/Pachebels%20Cannon.mp3" />
<param name="showcontrols" value="true" />
<param name="volume" value="100" />
<!--[if !IE]>--></object><!--<![endif]-->
</object>
</div><!-- end of control -->
回答by Grank
I wasn't aware of that limitation. Although it does make sense to disable potentially data-hefty OBJECT or EMBED tags when on the cellular data service for which your provider may be charging by the byte, if that were the reason it wouldn't make sense that it would still work on 3G and only not on GPRS.
Perhaps the problem is one of basic data throughput? Not having an iPhone yourself (or myself) makes it difficult to test your colleague's statement.
Remember that GPRS is much slower than Wi-Fi or 3G. According to Wikipedia, GPRS will provide between 56 and 114 kbps of total duplex throughput, not all of which is in the download direction. You can already see that's not fast enough to instantly stream a typical 128 kbps mp3, even if you were getting the optimal throughput and getting it all as download speed.
Looking at this forum discussionas an example that came up on Google, the GPRS customers (the ones not using Telestra, which is an EDGE provider in that area) are getting around 40 kbps. So if as the question implies, you're stuck in EDGEland, NOT 3Gland or anything inbetween, it's going to take about 20 seconds of buffering to play a 30 second mp3. And when you use a behaviour-ambiguous tag like OBJECT or EMBED, there's no guarantee in how the browser will interpret it and whether it's going to try to intelligently stream the file rather than having to download the whole thing before starting it.
So, it's quite possible your colleague just didn't wait long enough to see if whatever embedded media he chose as a test started to play (assuming he wasn't using your 17KB test mp3 there). It's also possible that the iPhone does indeed have this limitation, though I'd think Google would be more forthcoming with it than my quick search uncovered, since people have been vocal enough with other things they don't like about iPhone. Another possibility would be that it's a limitation in the build of Safari that currently ships with the iPhone which might be changed in future versions or in another browser.
Ultimately though, the question is, what kind of user experience do you really want? Embedded audio on GPRS is going to take a long time to load, and users aren't going to enjoy the experience, or potentially even experience it at all if it's supposed to start playing on page visit and it doesn't load before they navigate away. It might not be a goal worth striving towards in that case.
我不知道这个限制。尽管在您的提供商可能按字节收费的蜂窝数据服务上禁用潜在数据量大的 OBJECT 或 EMBED 标签确实有意义,但如果这是原因,它仍然可以在 3G 上工作是没有意义的并且只是不在GPRS上。
也许问题是基本数据吞吐量之一?自己(或我自己)没有 iPhone 会很难测试你同事的陈述。
请记住,GPRS 比 Wi-Fi 或 3G 慢得多。根据维基百科,GPRS 将提供 56 到 114 kbps 的总双工吞吐量,并不是所有的都在下载方向。您已经可以看到,即使您获得了最佳吞吐量并将其全部用作下载速度,也不足以立即流式传输典型的 128 kbps mp3。
看这个论坛讨论作为 Google 上的一个例子,GPRS 客户(那些不使用 Telestra,这是该地区的 EDGE 提供商)获得大约 40 kbps。因此,如果正如问题所暗示的那样,您被困在 EDGEland,而不是 3Gland 或介于两者之间的任何东西,那么播放 30 秒的 mp3 将需要大约 20 秒的缓冲时间。当您使用诸如 OBJECT 或 EMBED 之类的行为不明确的标签时,无法保证浏览器将如何解释它以及它是否会尝试智能地流式传输文件,而不必在启动之前下载整个文件。
因此,很可能您的同事没有等待足够长的时间来查看他选择作为测试的任何嵌入式媒体是否开始播放(假设他没有在那里使用您的 17KB 测试 mp3)。iPhone 确实有这个限制也是可能的,尽管我认为谷歌会比我的快速搜索发现的更主动,因为人们已经对他们不喜欢 iPhone 的其他事情发表了足够的意见。另一种可能性是,这是当前 iPhone 附带的 Safari 构建的限制,可能会在未来版本或其他浏览器中更改。
但最终,问题是,您真正想要什么样的用户体验?GPRS 上的嵌入式音频将需要很长时间才能加载,如果它应该在页面访问时开始播放并且在他们导航之前没有加载,那么用户将不会享受这种体验,甚至可能根本体验不到它离开。在这种情况下,这可能不是值得努力的目标。