HTML音频在Android的web视图 [英] Html Audio in Android Webview

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

问题描述

我在HTML和Java初学者,我试图播放音频文件在一个简单的Web应用程序,通过使用HTML和Java Web视图的机器人。我已经成功地得到这个工作在Android 4.0。然而,它不会对2.3.3或2.2工作。我已经做了很多研发的,到目前为止我所发现的是,它不支持。任何人都可以证实或否认这一点,并可能指向我的方向是正确的?以下是我所工作的4.0,但没有别的。

I am a beginner in HTML and Java and I am attempting to play audio files in a simple web app on the android through the Web view using HTML and Java. I have succeeded in getting this to work on Android 4.0. It however will not work on 2.3.3 or 2.2. I've done a lot of researching and so far all I have found is that it is not supported. Can anyone confirm or deny this and possibly point me in the right direction? Here is what I have working on 4.0 but nothing else.

WebView engine = (WebView) findViewById(R.id.web_engine);

String audioTest =  "< html >" + <br/>
                "< body >" + <br/>
                "< audio id='egSound' preload='auto'  autoplay ='autoplay'>" + <br/>
                "< source src=' www.egSoundUrl.com '>" +                    
                "< /audio>" + <br/>
                "< /body>"  +  
                "< /html>";

engine.loadData(audioTest, "text/html", null);

我怎样才能得到相同的code到工作2.3.3?在我的研究,我碰到别人谁能够播放使用视频标签的音频文件,但我无法得到那个工作。任何共享的知识会大大AP preciated。

How can I get the same code to work for 2.3.3? In my research I came across someone who was able to play the audio file using the video tag, but I was unable to get that working. Any shared knowledge will be greatly appreciated.

推荐答案

是的。可悲的是HTML5音频元素只能从姜饼的支持。

Yep. Sadly HTML5 audio element is supported only from Gingerbread.

我读的音频标签在2.2和放大器好歹支持; 2.3,但对于一些很奇怪的原因,mp3和放大器; OGG codeCS都没有。因此,即使它支持的是在手机上没用最多的Andr​​oid 2.3。

I read that the audio tag IS supported someway in 2.2 & 2.3, but for some very weird reason the mp3 & ogg codecs are not. Therefore, even if it's supported is useless on phones up to Android 2.3.

解决方案:1 视频标签的解决方法(1.6〜2.2)如下:

SOLUTION 1 The video tag workaround (1.6 to 2.2) is the following:

<video src="soundfile.mp3" onclick="this.play();"></video>

是你试过了吗?

is the one you tried?

解决方案2 另一种可能的解决方案(2.2 +)是实现一个jQuery播放器与Flash回退,像的 UbaPlayer

SOLUTION 2 Another possible solution (2.2+) is to implement a JQuery Player with Flash fallback, like UbaPlayer.

解决方案3 最后..有一个java解决方法通过计算器的其他用户,在这里:

SOLUTION 3 Lastly.. there's a java workaround by another user of StackOverflow, here:

..希望这会有所帮助:)

..Hope this helps :)

这篇关于HTML音频在Android的web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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