2

I am using webview in my application where i am giving it a audio url.

Its working absolutely fine in some devices. see below screenshot:

here is the screenshot

But in some device its not looking user friendly.

webview 1

webview 2

Is there any way to set the size of webview audio player?

Update: Code snippet:

// open DOI activity

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);

//Called from podcastListingFragment : podcast name

       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>
Sangeeta
  • 961
  • 2
  • 13
  • 34

1 Answers1

0

add this line in your code where you are initializing your webview. mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);

If you have already done this I would recommend you to use MediaPlayer for straming.

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

See this answer for more details about MediaPlayer streaming.

Community
  • 1
  • 1
Vikash Kumar Verma
  • 1,068
  • 2
  • 14
  • 30