android - Android WebView调整默认音频播放器的大小

标签 android audio webview

我在我的应用程序中使用webview,在其中给它提供音频URL。

在某些设备中,它的工作原理绝对不错。见下面的截图:

here is the screenshot

但是在某些设备中,它看起来并不友好。

webview 1

webview 2

有什么方法可以设置Webview音频播放器的大小?

更新:代码段:

//打开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);

//从podcastListingFragment调用:podcast名称
       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>

最佳答案

在您要初始化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

关于android - Android WebView调整默认音频播放器的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40521179/

相关文章:

audio - 从庞大的WAV文件中提取一定级别的音频部分

iphone - 如何在WebView中读取Resource文件夹子文件夹中的PDF文件?

javascript - Webview不加载javascript获取内容

android - 协程异常抛出 KotlinNullPointerException

actionscript-3 - Wowza的流播放在Flash Player上发出声音audio啪声

ios - AVAudioPlayer 在中断后从相同状态恢复音频剪辑

ios - 如何设置背景色为透明,以显示运营商信息、时间和电池状态

java - 自定义监听器/接口(interface)在 Android 中不起作用

android - 如何在 Android 设备上识别用户?

Android 权限、签名和开发者 key