So I need to play an audio which streaming on the internet. For my android app. I am using webview but can't figure out how to do it. Any suggestions?
Asked
Active
Viewed 5,765 times
2 Answers
3
// Added in API level 8 mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
This method was deprecated in API level 18. Plugins will not be supported in future, and should not be used.

Davidjburgos
- 73
- 1
- 6
1
You just need to enable the plugins for the webview, like this :
WebView mWebView = (WebView) findViewById(R.id.WebView01);
mWebView.getSettings().setPluginsEnabled(true);
// Added in API level 8
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
Android Documentation WebSettings.PluginState
But it might be better to use native player see below:
Android Supported Media Formats: http://developer.android.com/guide/appendix/media-formats.html
(offline media player related links)
-
It is not a URL exactly. The music is streamed on a flash player on the streaming website. I will somehow extract mp3 from that flash and play it in webview. You know how I can do that? – ankit rawat Mar 09 '13 at 17:44
-
have you tested any of the suggested? – madlymad Mar 09 '13 at 17:47
-
it depends on the site / radio / streaming mechanism and it is not always possible to stream the extracted url on android. see added url for Android Supported Media Formats – madlymad Mar 09 '13 at 17:56
-
The flash player is flash based(obviously) but I think the audio its streaming is mp3.. Can that mp3 be extracted and played? Is this possible by any method? – ankit rawat Mar 10 '13 at 11:26
-
programmatically is quite impossible... get through html-source-code and try to find the url. – madlymad Mar 10 '13 at 11:29
-
OK, I got the mp3's url through the html source code. It looks like this(but not this, mine is a live stream): http://www.whatisthatsong.net/charts-lists/charts%20and%20lists-mp3/classic%20rock/37.%20Pink%20Floyd%20-%20Comfortably%20Numb.mp3 . Can this be played in android? I tried after enabling the plugins you said to earlier, but the webview now doesn't even open the page, it just shows a white screen. It's working fine with google.com. How can I get it to play? Thanks! – ankit rawat Mar 10 '13 at 15:20
-
Try the url with the media player! – madlymad Mar 10 '13 at 23:19