使用iframe在Android中播放vimeo嵌入视频时不允许操作

时间:2015-07-21 12:26:48

标签: android iframe video webview vimeo

我使用webView播放vimeo嵌入视频。在播放YouTube视频时,我的网页浏览效果很好。但是当我加载vimeo视频时,缩略图显示在webview中,但是当我点击播放按钮时,会显示一条带有消息的祝酒词:不允许操作。然后整个屏幕变灰,中间有视频图标。

这是我的webView代码:

<WebView
            android:background="@android:color/white"
            android:id="@+id/webViewYoutube"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

我的片段代码在webView中加载视频。

 String vimeoFrame="<html><body><iframe src=\"http://player.vimeo.com/video/113067409?autoplay=1&loop=1\" width=\"300\" height=\"200\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></body></html>";
    WebView vimeoPlayer = (WebView) getView().findViewById(R.id.webViewYoutube);
    WebSettings webSettings2 = vimeoPlayer.getSettings();
    webSettings2.setJavaScriptEnabled(true);
    webSettings2.setBuiltInZoomControls(false);
    webSettings2.setAppCacheEnabled(true);
    webSettings2.setDomStorageEnabled(true);
    webSettings2.setPluginState(WebSettings.PluginState.ON);

    vimeoPlayer.setWebChromeClient(new WebChromeClient());
    vimeoPlayer.setWebViewClient(new WebViewClient());
    vimeoPlayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    vimeoPlayer.loadData(vimeoFrame, "text/html", "utf-8");

更新 深入了解Logcat,我发现了警告堆栈跟踪,如下所示:

java.io.FileNotFoundException: No content provider: https://s.vimeocdn.com/vimeo-prod-std-us/video/393408632.mp4?token=55afa9c1_0x34d715bffb7e3c81b0c424ee5a62862913e2c1e6
        at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:710)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:614)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:985)
        at android.webkit.HTML5VideoView.prepareDataCommon(HTML5VideoView.java:309)
        at android.webkit.HTML5VideoView.prepareDataAndDisplayMode(HTML5VideoView.java:346)
        at android.webkit.HTML5VideoInline.prepareDataAndDisplayMode(HTML5VideoInline.java:57)
        at android.webkit.HTML5VideoViewProxy$VideoPlayer.play(HTML5VideoViewProxy.java:265)
        at android.webkit.HTML5VideoViewProxy.handleMessage(HTML5VideoViewProxy.java:416)

似乎解析了Embed Vimeo视频网址并没有被android正确完成。我用iOS测试了同样的嵌入式网址,效果很好。此问题仅适用于Android。有谁知道如何解决这个问题?

0 个答案:

没有答案