HTML5音频无法在移动设备上播放

时间:2012-03-30 11:50:19

标签: html5 audio mobile tablet html5-audio

亲爱的HTML5开发者,

我对这个HTML5音频有些麻烦...所以让我们跳进去吧。

ap  = "<audio width='200' height='30' preload='auto' controls autobuffer>";
ap += "<source src='util/blob_audio.php?i=" + w + "&ogg=1' type='audio/ogg' />";
ap += "<source src='util/blob_audio.php?i=" + w + "&mp3=1' type='audio/mpeg' />";
ap += "</audio>";

我在JavaScript中生成它,并且方法在需要时返回它。我想我不应该提到“w”变量,这是一个参数( YouDon'tSay ),它的工作正常。

应该没问题吧?它们出现在台式机上,但它们在移动设备上遇到了麻烦(我已经在iPad2,Android 3.2.1平​​板电脑,Android 2.3.6智能手机上进行了测试)。

它在iPad 2上显示:“无法播放音频文件。”在元素中。 Droid显示默认的音频元素,但没有音量控制,从视觉上看它正在播放 - 从头到尾跳跃。

PHP标题看起来像这样(在blob_audio.php中)(我们将音频存储为数据库中的blob [不要问我为什么,这不是我的想法]):

header("Content-Type: audio/ogg"); // this is inside of a condition, this is the "ogg" part of it
header('Content-Length: ' . $length);
header('Content-Disposition: inline');
header('X-Pad: avoid browser bug');
header('Cache-Control: no-cache');

这很好用,因为一切都适用于台式机。

我在想这些格式(mp3,ogg)可能不适合(不支持编解码器)编码用于ARM体系结构CPU。如果是mp3,可能会发生这种情况吗?

一个想法?任何人? =)

谢谢你, 本

3 个答案:

答案 0 :(得分:15)

好的,我们已经弄明白了。 =)

以下是事实(见下文):

iStuff上的问题 - &gt;我们正在通过安全连接(HTTPS)。这搞砸了iShit HTML5音频处理。他们需要一些&#34; intermedia证书&#34; - 可能是用于身份验证或我不知道 - 在服务器的证书链之间。所以事情不是通过SSL在我们的测试服务器上工作。谁知道......当你正常部署它时它会起作用。但是,Android来了,小心!

Android很有趣,因为(如文档-_O所示)Droid不支持3.1版本以下的任何媒体格式。这是一个完整的&#34;搞砸了人性&#34; ...我不明白为什么这样的问题让af * cking系统能够通过f * cking SECURE连接播放任何多媒体在21世纪......这必须是一些版权法,我必须再次呕吐......

如果你想知道我们做了什么来解决这个问题: 我们发现如果我们真的想让我们的应用跨浏览器和跨设备兼容&#34; (不知道如果这是正确的命名,但我确定你得到它;)),我们需要&#34;取出&#34; SSL下的音频(多媒体/媒体)。 因此,为了简单起见,我们为音频文件创建了一个简单的HTTP子域(层次结构中的单独文件夹)(我们现在只需要音频),并通过该子域可以访问它,并通过脚本文件进行身份验证/验证。 所以一切都在HTTPS下,但多媒体/媒体在HTTP上是分开的。

随时随地在每个f * cking设备上正常工作。我知道这是一个更大的&#34;解决方案,但这是最可实施的&#34;我们正在测试这些东西。

希望有人帮助过! =) 干杯!

答案 1 :(得分:0)

您应该使用AAC instead of MP3

看起来您的内容类型已硬编码为audio / ogg - 您希望确保在请求MP3 / M4A时设置正确。

答案 2 :(得分:0)

没有属性“autobuffer”。 根据文档,以下是可能的属性:

src
crossorigin
preload
autoplay
mediagroup
loop
muted
controls

type属性提供媒体资源的类型,以帮助用户代理确定它是否可以在获取之前播放此媒体资源。如果指定,则其值必须是有效的MIME类型。某些MIME类型定义的codecs参数可能是准确指定资源编码方式所必需的(根据 [RFC4281]

以下列表显示了如何在codecs= MIME属性中使用type参数的一些示例,这些参数不仅对音频有效,对视频文件也有效。

H.264 Constrained baseline profile video (main and extended video compatible) level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
H.264 Extended profile video (baseline-compatible) level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.58A01E, mp4a.40.2"'>
H.264 Main profile video level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'>
H.264 'High' profile video (incompatible with main, baseline, or extended profiles) level 3 and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="avc1.64001E, mp4a.40.2"'>
MPEG-4 Visual Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="mp4v.20.8, mp4a.40.2"'>
MPEG-4 Advanced Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container
<source src='video.mp4' type='video/mp4; codecs="mp4v.20.240, mp4a.40.2"'>
MPEG-4 Visual Simple Profile Level 0 video and AMR audio in 3GPP container
<source src='video.3gp' type='video/3gpp; codecs="mp4v.20.8, samr"'>
Theora video and Vorbis audio in Ogg container
<source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'>
Theora video and Speex audio in Ogg container
<source src='video.ogv' type='video/ogg; codecs="theora, speex"'>
Vorbis audio alone in Ogg container
<source src='audio.ogg' type='audio/ogg; codecs=vorbis'>
Speex audio alone in Ogg container
<source src='audio.spx' type='audio/ogg; codecs=speex'>
FLAC audio alone in Ogg container
<source src='audio.oga' type='audio/ogg; codecs=flac'>
Dirac video and Vorbis audio in Ogg container

有关详细信息,请参阅http://www.whatwg.org/specs/web-apps/current-work/#the-audio-element