我只是尝试将youtube嵌入视频的iframe标签加载到网络视图中,但是该视频甚至无法加载缩略图。我尝试了Internet上可用的大多数解决方案,但无法解决问题。几个月前,它工作正常,但突然我发现webview甚至没有显示视频缩略图。我还尝试只加载youtube URL(https://www.youtube.com),但是又失败了,其他URL很好。
我尝试了以下解决方案:
youtubeWebView.setWebViewClient(new WebViewClient());
youtubeWebView.setWebChromeClient(new WebChromeClient());
WebSettings webSettings = youtubeWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
android:hardwareAccelerated="true" on application Tag
这是互联网上大多数可用的解决方案。
这是我的功能,负责在网络视图上呈现视频。 youtubeWebView已经初始化,并且mediaTrailerUrl的格式为https://www.youtube.com/embed/RiANSSgCuJk
private void prepareYouTubeFrame(String mediaTrailerUrl){
mediaTrailerUrl = mediaTrailerUrl + "?mode=opaque&rel=0&autohide=1&showinfo=0&wmode=transparent";
String frameVideo = "<!DOCTYPE HTML> <html><body style=\"margin:0 0 0 0; padding:0 0 0 0;\"> <iframe width=\"100%\" height=\"200%\" src=\"" + mediaTrailerUrl + "\" frameborder=\"0\" ></iframe> </body> </html> ";
youtubeWebView.setWebViewClient(new WebViewClient());
youtubeWebView.setWebChromeClient(new WebChromeClient());
WebSettings webSettings = youtubeWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
youtubeWebView.setBackgroundColor(Color.TRANSPARENT);
youtubeWebView.loadData(frameVideo, "text/html", "UTF-8");
}
我想要在android webview上播放youtube嵌入视频的frame标签。 Log cat会显示这种类型的消息:
2019-06-25 16:34:20.149 30775-31924/com.mobile.midtown
W/AudioCapabilities: Unsupported mime audio/mpeg-L1 2019-06-25
16:34:20.150 30775-31924/com.mobile.midtown W/AudioCapabilities:
Unsupported mime audio/mpeg-L2 2019-06-25 16:34:20.156
30775-31924/com.mobile.midtown W/AudioCapabilities: Unsupported mime
audio/x-ms-wma 2019-06-25 16:34:20.158 30775-31924/com.mobile.midtown
W/AudioCapabilities: Unsupported mime audio/x-ima 2019-06-25
16:34:20.159 30775-30775/com.mobile.midtown
D/ViewRootImpl@1ee6d17[ShowsDetailActivity]: setView =
DecorView@2d4aaed[ShowsDetailActivity] TM=true MM=false 2019-06-25
16:34:20.178 30775-30775/com.mobile.midtown D/ConnectivityManager:
requestNetwork; CallingUid : 11055, CallingPid : 30775 2019-06-25
16:34:20.188 30775-31924/com.mobile.midtown W/VideoCapabilities:
Unrecognized profile 2130706433 for video/avc 2019-06-25 16:34:20.188
30775-31924/com.mobile.midtown W/VideoCapabilities: Unrecognized
profile 2130706434 for video/avc 2019-06-25 16:34:20.204
30775-31924/com.mobile.midtown W/VideoCapabilities: Unrecognized
profile 2130706433 for video/avc 2019-06-25 16:34:20.204
30775-31924/com.mobile.midtown W/VideoCapabilities: Unrecognized
profile 2130706434 for video/avc 2019-06-25 16:34:20.259
30775-31924/com.mobile.midtown W/VideoCapabilities: Unsupported mime
video/wvc1 2019-06-25 16:34:20.264 30775-31924/com.mobile.midtown
W/VideoCapabilities: Unsupported mime video/x-ms-wmv 2019-06-25
16:34:20.270 30775-31924/com.mobile.midtown W/VideoCapabilities:
Unrecognized profile 2130706433 for video/avc 2019-06-25 16:34:20.270
30775-31924/com.mobile.midtown W/VideoCapabilities: Unrecognized
profile 2130706434 for video/avc 2019-06-25 16:34:20.319
30775-30775/com.mobile.midtown
D/ViewRootImpl@1ee6d17[ShowsDetailActivity]: dispatchAttachedToWindow
2019-06-25 16:34:20.368 30775-31924/com.mobile.midtown
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
2019-06-25 16:34:20.461 30775-31924/com.mobile.midtown
W/VideoCapabilities: Unrecognized profile/level 1/32 for video/mp4v-es
2019-06-25 16:34:20.461 30775-31924/com.mobile.midtown
W/VideoCapabilities: Unrecognized profile/level 32768/2 for
video/mp4v-es 2019-06-25 16:34:20.461 30775-31924/com.mobile.midtown
W/VideoCapabilities: Unrecognized profile/level 32768/64 for
video/mp4v-es 2019-06-25 16:34:20.465 30775-31924/com.mobile.midtown
W/VideoCapabilities: Unsupported mime video/wvc1 2019-06-25
16:34:20.467 30775-31924/com.mobile.midtown W/VideoCapabilities:
Unsupported mime video/x-ms-wmv 2019-06-25 16:34:20.470
30775-31924/com.mobile.midtown W/VideoCapabilities: Unsupported mime
video/x-ms-wmv7 2019-06-25 16:34:20.472 30775-31924/com.mobile.midtown
W/VideoCapabilities: Unsupported mime video/x-ms-wmv8 2019-06-25
16:34:20.475 30775-31924/com.mobile.midtown W/VideoCapabilities:
Unsupported mime video/mp43 2019-06-25 16:34:20.488
30775-31924/com.mobile.midtown W/VideoCapabilities: Unsupported mime
video/sorenson