假"用户发起的" <音频> iPad上的标签 [英] Fake "user initiated" <audio> tag on iPad

查看:166
本文介绍了假"用户发起的" <音频> iPad上的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,苹果的文档说内的℃的MP3,音频>在iPhone OS标签不能无需用户干预进行播放(他们引用了带宽问题,完全合理)。但是,有没有人成功地编造一个用户操作播放音频?也许,伪造使用JavaScript事件来关闭屏幕原生音频控制?我使用jPlayer现在它工作在桌面Safari浏览器不错,但在我的iPad上保持沉默。

I know that Apple's docs say that an mp3 within an <audio> tag on iPhone OS can't be played without user intervention (they cite bandwidth concerns, totally reasonable). However, has anyone succeeded in faking a user action to play the audio? Perhaps faking events to off screen native audio controls with JavaScript? I'm using jPlayer right now which works great on desktop Safari, but is silent on my iPad.

我用原型在iPad上的WebKit触摸界面,以及音频的体验中不可或缺的一部分,所以的的,我有一个很好的理由要覆盖这个约定。

I'm prototyping a touch interface using WebKit on the iPad, and audio is an integral part of the experience, so yes, I do have a good reason to want to override this convention.

我倒是AP preciate任何帮助。谢谢你。

I'd appreciate any help. Thanks.

推荐答案

我有这个同样的问题...希望在从声音的回放控制得去,因为它是。

I had this same problem ... wanting to be in control of the playback of sound from the "get go" as it were.

我的解决办法是把音频标签在一个隐藏的DIV是这样的。

My solution was to put the audio tags in a hidden DIV like this.

<div id="junk" style="display: none">
  <audio id="effect1" src="..." autobuffer="autobuffer" controls="" ></audio>
  <audio id="effect2" src="..." autobuffer="autobuffer" controls="" ></audio>
  <audio id="effect3" src="..." autobuffer="autobuffer" controls="" ></audio>
</div>

然后在我的javascript我有code这样一出戏程序。

Then in my javascript I have code like this in a play routine.

function playEffect(x) {
  var a = document.getElementById('effect' + x);
  if (a && a instanceof Audio) {
    if (a.currentTime) { a.currentTime = 0; }
    a.play();
  }
}

所以...你遵守规则,因为需要UI控件是有,但它当然不会与网页干涉。在playEffect功能currentTime的检查倒带的声音......如果你不这样做,它不会玩第二次。

So ... you follow the rules because the "required" UI Control is there but of course it doesn't interfere with the web page. The check for currentTime in the playEffect function "rewinds" the sound ... if you don't do that, it won't play a second time.

这为我工作在iPad和iPhone以及Safari浏览器作为我的Mac上。我没有遵守测试IE浏览器。我的页面被整合与谷歌地图API V3。

This worked for me on iPad and iPhone as well as Safari on my Mac. I haven't tested IE for compliance. My page was integrated with Google Maps API v3.

这篇关于假&QUOT;用户发起的&QUOT; &LT;音频&GT; iPad上的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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