HTML 5音频标签问题(没有声音)与Android 4.x上的phonegap [英] HTML 5 audio tag issues (no sound) with phonegap on android 4.x

查看:838
本文介绍了HTML 5音频标签问题(没有声音)与Android 4.x上的phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

平台:Android版本4.x



问题:HTML 5音频标签



编译:Framework Phonegap



我一直试图用HTML 5,不能得到它的工作。



我读到Android有一个一般的不支持的事情,但正如我所理解的,版本4.x支持HTML 5音频标签。 p>

Config.xml
我已经启用了一些功能。文件访问,设备访问等,我甚至试图包括所有功能。



HTML
这是我在atm工作,我想我也许应该去然后使用JQ进行costum控制。

 < audio controls =true > 
< source src =media / sound.mp3type =audio / mpeg>
< source src =media / sound.oggtype =audio / ogg>
< source src =media / sound.wavtype =audio / wav>
您的浏览器并不支援HTML5音讯。
< / audio>

结论
到目前为止,我没有听到任何声音,尝试以不同的方式触发它:

  var Newsound = new Audio(sound.ogg); 
Newsound.play();

欢迎任何想法或建议。



提前感谢: - )

解决方案

您通常需要一段JavaScript才能使其工作。尝试以下操作:

 < audio id =acontrols =true> ... 

var audio = document.getElementById('a');
audio.addEventListener('touchstart',function(){audio.play();},false);

当用户触摸音频元素时,声音现在应该播放。


Platform: Android version 4.x

Issue: HTML 5 Audio Tag

Compiled: Framework Phonegap

I have been trying to play a simple sound with HTML 5, i cant get it to work.

I read that there is a general "not supporting" thing going on with Android, but as i understand it, version 4.x supports HTML 5 Audio tag.

Config.xml I did enable some of the features in it eg. File access, device access and so, i even tried to include all features. Just to let u guys know.

HTML This is what i am working with atm, i figured that maybe i should go back to directly try and get a sound out, then make the costum controls with JQ.

<audio controls="true">
    <source src="media/sound.mp3" type="audio/mpeg">
    <source src="media/sound.ogg"  type="audio/ogg">
    <source src="media/sound.wav"  type="audio/wav">
    Your browser does not support HTML5 audio.
</audio>  

Conclusion So far i havent hear any sounds, i tried to trigger it different ways like:

var Newsound = new Audio("sound.ogg");
Newsound.play();    

Any idea or suggestion is welcome.

Thanks in advance :-)

解决方案

You generally need a piece of JavaScript to get this working. Try the following:

<audio id="a" controls="true">...

var audio = document.getElementById('a');
audio.addEventListener('touchstart', function() { audio.play(); }, false);

When a user touches the audio element the sound should now play.

这篇关于HTML 5音频标签问题(没有声音)与Android 4.x上的phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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