10

I have found many threads discussing the support of tag on Android. So far it looks, that even Android Froyo 2.2 cannot play audio (i have made tests on nexus One).

According to the www.html5test.com web page, the tag itself is supported, but no codecs are in the browser (mp3, ogg..). So how I can solve the problem?

So far I see only one solution, use the embedded Flex or Flash player, which can stream mp3. Is that correct? Is that the only way I can play the .mp3 or other audio stream in Android web browser?

Does Android 2.3 Gingerbread support some audio stream???

Thanks a lot BR STeN

Added later:The working solution I finally used is a small Flex .swf for streaming. It can be pretty easily integrated with the HTML web page (Flex-Javascript communication works pretty well). The only problem is that on some phones the Flash Player is not reinstalled and must be downloaded from Android Market first.

Added even later: Well, the <audio> element is buggy even on Android 2.3 - I do not know what are doing in Google that such a simple thing is a problem. Using the Flex Player is okey, but the problem is that on some phones the Adobe Flash player cannot be installed from Android market, because there are some Adobe HW requirements like 1Ghz CPU, etc. Some vendors like HTC are providing the own Flash players, but those are pretty bad and do not work correctly with the AS 3.0... So far everything works perfectly especially on Samsung phones (like Nexus S or Galaxy S).

STeN
  • 6,262
  • 22
  • 80
  • 125
  • I have been experimenting a bit with the audio tag to get it to work with Android 2.3, but have come up short (using the emulator). However, using the – Emil L Dec 29 '11 at 17:42

2 Answers2

6

What you dug up agrees with what I've run into as well. 2.2 supports the audio tag but has no codecs to back it, this is apparently a bug that's been fixed in releases beyond Froyo:

http://code.google.com/p/android/issues/detail?id=9372

I've used the audio tag with an mp3 file on my Nexus S, it's working correctly there (for the most recent firmware release at least).

mikerowehl
  • 2,222
  • 1
  • 17
  • 20
  • Hi, so minimum version is Android OS 2.3, is that right? What are the fallback solutions? Flash/Flex embedded players? Thanks a lot for a comment. BR STeN – STeN Feb 04 '11 at 08:53
  • I assume flash might be an option, but afraid I can't offer any practical advice there. I'm just waiting for 2.3 to be widely available instead. – mikerowehl Feb 04 '11 at 09:27
  • Hi, I decided to embed the small Flex stream player into my web application as a kind of temporary solution until the 2.3 will be used widely. Do you know how to check in JavaScript if the Flash Player is installed? Thanks – STeN Feb 07 '11 at 06:37
6

I forgot to ask first. Are you thinking on developing an Android application or just a regular web-app? Cause for this solution you would need Android code.

If you're not considering using Android code, then you can skip the rest of the message, sorry!

==================================================================================

Here it's some trick: You can use regular links to your audio files, or use javascript to redirect to one of the files (if you let Javascript do it), then override the Url loading, like this:

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.endsWith(".ogg")){
            Log.d(TAG, "Reproducir archivo OGG");
            Uri tempPath = Uri.parse(url);
            MediaPlayer player = MediaPlayer.create(WebViewVideo.this, tempPath);
            player.start();
            return true;
        }else{
            return super.shouldOverrideUrlLoading(view, url);
        }
    }

});

Hope this helps, it does for me!

Regards.

mdelolmo
  • 6,417
  • 3
  • 40
  • 58
  • Hi, thanks for interesting tip - might be usefull for me in other application... Unfortunately this time I am doing really pure web application...:(( BR STeN – STeN Feb 04 '11 at 09:00