0
我有一個帶有4個選項卡的Android應用程序,我試圖在每個選項卡中加載一個不同的webview。其中一個網頁瀏覽包含音頻流。我有兩個問題:音頻流不在Android中玩webview片段
音頻流頁面不會加載。片段加載到音頻流webview的空白頁面。
ListenLiveFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment` View v= inflater.inflate(R.layout.fragment_listen_live, container, false); web_v=(WebView)v.findViewById(R.id.webView); WebSettings web_sett=web_v.getSettings(); web_sett.setJavaScriptEnabled(true); web_v.setWebViewClient(new MyWebClient()); web_v.loadUrl("http://stream.us.gslb.liquidcompass.net/WPWXFMMP3"); return inflater.inflate(R.layout.fragment_listen_live, container, false); //return v; } private class MyWebClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // TODO Auto-generated method stub web_v.loadUrl(url); return true; } }
fragment_listen_live.xml
<FrameLayout 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"
tools:context="com.peekatu.maintemplate.ListenLiveFragment">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center" />
</FrameLayout>
HTML
<html>
<head>
<meta name="viewport" content="width=device-width">
</head>
<body>
<video controls="" autoplay="" name="media">
<source src="http://stream.us.gslb.liquidcompass.net/WPWXFMMP3" type="audio/mpeg">
</video>
</body>
</html>
2.我的第二個問題是,如何在每次片段暫停時停止重新加載網頁瀏覽。謝謝。
謝謝你的幫助。一個問題。我正在檢查您發送示例的鏈接,並在該示例中使用extends Activity將MainActivity加載的流。如何將此示例加載到片段中。我只是擴展FragmentActivity?謝謝。 – TWeeKeD