gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 22:38:11 25 4
gpt4 key购买 nike

我在我的应用程序中使用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com