Maihan Nijat
Maihan Nijat

Reputation: 9344

How to embed custom media player in Android app?

I am broadcasting live audio using MIXLR website. The website provides iframe code for embedding it into website. I used the iframe code into html file and integrate it with Android app using WebView method. The application loads html file including the player but it loads the Android video player when I click on play button instead of playing in the player embedded. The iframe code doesn't have any audio file to use it in HTML5 audio tag. Is there anyway to play the audio in same player embedded instead of opening android player?

Upvotes: 0

Views: 3135

Answers (1)

Randyka Yudhistira
Randyka Yudhistira

Reputation: 3652

Can you try this code with these setting :

WebSettings webViewSettings = webView.getSettings();
webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webViewSettings.setJavaScriptEnabled(true);
webViewSettings.setPluginsEnabled(true);
webViewSettings.setBuiltInZoomControls(true);
webViewSettings.setPluginState(PluginState.ON);

webView.setWebViewClient(new WebViewClient(){
   public boolean shouldOverrideUrlLoading(Webview view, String url){
     return false; 
}});

webView.loadData("<iframe src=\"http://mixlr.com/enikaasradio/embed/?autoplay=true\"></iframe>", "text/html", "utf-8");

in your manifest add this permission :

<uses-permission android:name="android.permission.INTERNET" />

and in your application tag, add this :

android:hardwareAccelerated="true"

Upvotes: 2

Related Questions