如何在web中显示youtube视频查看Android

时间:2015-05-01 11:34:59

标签: android video webview youtube

我有一个网页视图,显示了一些嵌入了YouTube视频的网站。它适用于我的THL 5000(4.4),但是当我尝试在我的Nexus 4(Android 5)上启动视频时,视频将开始缓冲,但没有音频也没有显示视频。

这就是我的所作所为:

final WebView mWebView = (WebView) v.findViewById(R.id.webview);
        mWebView.setVisibility(View.GONE);
        //mWebView.getSettings().setLoadWithOverviewMode(true);
        //mWebView.getSettings().setUseWideViewPort(true);
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;

        mWebView.setInitialScale(100*width/768 +10);
        // disable scroll on touch
        mWebView.setOnTouchListener(new View.OnTouchListener() {
           @Override
            public boolean onTouch(View v, MotionEvent event) {
               return (event.getAction() == MotionEvent.ACTION_MOVE);
            }
        });
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
        mWebView.getSettings().setAllowContentAccess(true);
        WebSettings webSettings = mWebView.getSettings();
        mWebView.setWebViewClient(new WebViewClient());
        webSettings.setUseWideViewPort(true);
        webSettings.setLoadWithOverviewMode(true);


        mWebView.setWebChromeClient(new WebChromeClient() {});

这是我尝试在nexus上运行时遇到的logcat错误:

05-01 13:27:13.170    8662-8662/com....... E/SysUtils﹕       ApplicationContext is null in ApplicationStatus
05-01 13:27:21.057    8662-9038/com...... E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
05-01 13:27:21.178    8662-9047/com....... E/ACodec﹕ [OMX.qcom.video.decoder.avc] storeMetaDataInBuffers failed w/ err -2147483648
05-01 13:27:21.196    8662-9047/com....... E/ACodec﹕ registering GraphicBuffer 0 with OMX IL component failed: -2147483648
05-01 13:27:21.196    8662-9047/com....... E/ACodec﹕ Failed to allocate buffers after transitioning to IDLE state (error 0x80000000)
05-01 13:27:21.196    8662-9047/com....... E/ACodec﹕ signalError(omxError 0x80001001, internalError -2147483648)
05-01 13:27:21.196    8662-9046/com..... E/MediaCodec﹕ Codec reported err 0x80001001, actionCode 0, while in state 5
05-01 13:27:21.198    8662-8662/com........ E/MediaCodecBridge﹕ Cannot start the media codec
    android.media.MediaCodec$CodecException: start failed
            at android.media.MediaCodec.native_start(Native Method)
            at android.media.MediaCodec.start(MediaCodec.java:612)
            at org.chromium.media.MediaCodecBridge.start(MediaCodecBridge.java:370)
            at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
            at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

感谢您的帮助!

亲切的问候 帕特里克

0 个答案:

没有答案