Android上的Javascript音频播放静音 [英] Javascript audio play muted on Android

查看:140
本文介绍了Android上的Javascript音频播放静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想播放mp3声音,当事件发生时我正在使用以下代码:

I want to play an mp3 sound, when an event occurs and I am using the following piece of code:

var audio = new Audio('coins.mp3');
audio.play();

它在Chrome浏览器的Windows下工作得很好,但是如果我在我的4.4 Android上打开它,它会被静音。我测试了另一个Android版本(2.3,而不是Chrome),它正在运行。如果我从4.4 Android上的onClick事件调用代码,它似乎也有效。

It works great under windows in Chrome, however if I open it on my 4.4 Android, it is muted. I tested on another android version (2.3, not Chrome) and it was working. It seems it is also working if I call the code from an onClick event on 4.4 Android.

任何人都可以为我解释这个行为,因为我找不到答案经过几个小时的谷歌搜索。 :(

Can anyone please explain this behaviour for me, as I can not find the answer after some hours of googling. :(

提前致谢!

推荐答案

这是链接到谷歌Android漏洞,因为Android中缺少对AUDIO标签的支持。

Here is link to Google Android bug, which filed for lack of support of AUDIO tag in Android.

https://code.google.com/p/android/issues/detail?id=10546

希望这会有所帮助,还有一件事是

Hope this will help and One more thing is

由于编解码器许可问题和操作系统实施/支持,HTML5音频支持在不同设备/操作系统之间并不一致。如果你只是在播放MP3文件,你可以通过使用PhoneGap的 Media 课程,将在所有平台上提供一致且可靠的音频编程。

HTML5 Audio support is not consistent across different devices/OSes due to codec licensing issues and OS implementation/support. If you are just playing MP3 files, you can reliably handle those by using PhoneGap's Media class, which will provide consistent and reliable audio programming on all platforms.

这篇关于Android上的Javascript音频播放静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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