2016-11-10 47 views
2

我在我的應用程序中使用webview,我給它一個音頻url。Android WebView調整默認音頻播放器

它在某些設備上工作絕對正常。見下圖:

here is the screenshot

但在有些設備它不是找用戶友好。

webview 1

webview 2

有什麼辦法來設置的WebView音頻播放器的尺寸是多少?

更新:代碼片段:

//開放DOI活動

Intent podcastIntent = new Intent(mContext, DoiWebActivity.class); 
podcastIntent.setAction(Constants.INTENT_VIEW_LINK); 
podcastIntent.putExtra(Constants.EXTRA_DOI_LINK_URL, podcasts.get(0).getPodcastLink()); 
     podcastIntent.putExtra(Constants.CALLING_FRAGMENT,Constants.CALLING_FRAGMENT_PODCAST_LISTING); 
     podcastIntent.putExtra(Constants.EXTRA_PODCAST_NAME,mContext.getString(R.string.podcast)); 

mContext.startActivity(podcastIntent); 

//從podcastListingFragment調用:播客名稱

 if (bundle != null && bundle.containsKey(Constants.CALLING_FRAGMENT) && 
       bundle.containsKey(Constants.EXTRA_PODCAST_NAME)) { 

String title = bundle.getString(SilverChairConstants.EXTRA_PODCAST_NAME); 

      } 
if (Utility.isNetworkAvailable(mActivity)) { 
      /** 
      * Showing external link. 
      */ 
      mWebView.loadUrl(mIntentText); 

     } else { 

      networkNotAvailable(); 

     } 

XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    tools:context=".fragments.WebFragment"> 

    <WebView 
     android:layout_below="@+id/toolbar" 
     android:id="@+id/wv_webcontainer" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <!--progress bar--> 
    <include layout="@layout/silverchair_progress" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignTop="@id/wv_webcontainer" 
     android:layout_alignBottom="@id/wv_webcontainer"/> 


    <include layout="@layout/empty_view" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_centerInParent="true" 
     /> 

</RelativeLayout> 
+0

分享您的代碼片段 –

+0

添加。 @VikashKumarVerma請檢查 – Sangeeta

+0

編寫與webview及其佈局有關的代碼。 –

回答

0

加這個在你的代碼中你正在初始化你的webview。 mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);

如果您已經完成此操作,我會建議您使用MediaPlayer進行佈線。

MediaPlayer mediaPlayer = MediaPlayer.create(this, Uri.parse("http://vprbbc.streamguys.net:80/vprbbc24.mp3")); 
mediaPlayer.start(); 

約MediaPlayer的流媒體更多詳情請參見本answer