IT박스

WebView 및 HTML5

itboxs 2020. 7. 11. 11:07
반응형

WebView 및 HTML5


웹 사이트 중 일부를 "프레임"하는 저렴한 앱을 함께 정리하고 WebViewClient있습니다. 내가 비디오를 칠때까지

비디오는 HTML5요소 로 수행되며 Chrome, iPhone에서 정상적으로 작동하며 이제 Android기본 브라우저에서 작동하는 인코딩 문제를 해결했습니다 .

이제 문지르 기 : WebView그것을 좋아하지 않습니다. 조금도. 포스터 이미지를 클릭해도 아무 변화가 없습니다.

인터넷 검색, 나는 이것이 가까운 것을 알았지 만 비디오 요소 대신 '링크'(href에서와 같이)를 기반으로 한 것 같습니다. (onDownloadListener가 비디오 요소에서 호출되지 않는 것으로 보입니다 ...)

또한 onShowCustomView를 재정의하는 것에 대한 참조가 있지만 비디오 요소에서 호출되지 않는 것 같습니다 ... shouldOverrideUrlLoading ..

차라리 "서버에서 XML을 가져 와서 앱에서 다시 포맷"하지 말고 서버에 스토리 레이아웃을 유지함으로써 사람들이 앱을 계속 업데이트하지 않고도 컨텐츠를 조금 더 잘 제어 할 수 있습니다. 따라서 WebView가 기본 브라우저와 같은 태그를 처리하도록 설득 할 수 있다면 가장 좋습니다.

나는 분명한 것을 놓치고있다. 그러나 나는 실마리가 없다.


나는 누군가가 그것을 읽고 결과에 관심이있는 경우에 대비 하여이 주제에 대답합니다. WebView 내에서 비디오 요소 (video html5 태그)를 볼 수는 있지만 며칠 동안 처리해야한다고 말해야합니다. 지금까지 따라야 할 단계는 다음과 같습니다.

제대로 인코딩 된 비디오를 찾으십시오

-WebView를 초기화 할 때 JavaScript를 설정하고 WebViewClient와 WebChromeClient를 플러그인하십시오.

url = 새 문자열 ( "http://broken-links.com/tests/video/"); 
mWebView = (WebView) findViewById (R.id.webview);
mWebView.setWebChromeClient (chromeClient);
mWebView.setWebViewClient (wvClient);
mWebView.getSettings (). setJavaScriptEnabled (true);
mWebView.getSettings (). setPluginState (PluginState.ON);
mWebView.loadUrl (url);

WebChromeClient 객체에서 onShowCustomView를 처리합니다.

@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
    super.onShowCustomView(view, callback);
    if (view instanceof FrameLayout){
        FrameLayout frame = (FrameLayout) view;
        if (frame.getFocusedChild() instanceof VideoView){
            VideoView video = (VideoView) frame.getFocusedChild();
            frame.removeView(video);
            a.setContentView(video);
            video.setOnCompletionListener(this);
            video.setOnErrorListener(this);
            video.start();
        }
    }
}

웹보기로 돌아가려면 비디오의 onCompletion 및 onError 이벤트를 처리하십시오.

public void onCompletion(MediaPlayer mp) {
    Log.d(TAG, "Video completo");
    a.setContentView(R.layout.main);
    WebView wb = (WebView) a.findViewById(R.id.webview);
    a.initWebView();
}

그러나 지금은 여전히 ​​중요한 문제가 있다고 말해야합니다. 한 번만 재생할 수 있습니다. 두 번째로 비디오 디스패처 (포스터 또는 일부 재생 버튼)를 클릭하면 아무 것도 수행하지 않습니다.

미디어 플레이어 창을 여는 대신 WebView 프레임 내에서 비디오를 재생하고 싶지만 이것은 2 차 문제입니다.

누군가에게 도움이되기를 바랍니다. 또한 의견이나 제안에 감사드립니다.

살루도, 테리 콜라


오랜 연구 끝에 나는이 일을했습니다. 다음 코드를 참조하십시오.

테스트

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;

public class Test extends Activity {

    HTML5WebView mWebView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mWebView = new HTML5WebView(this);

        if (savedInstanceState != null) {
            mWebView.restoreState(savedInstanceState);
        } else {    
            mWebView.loadUrl("http://192.168.1.18/xxxxxxxxxxxxxxxx/");
        }

        setContentView(mWebView.getLayout());
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mWebView.saveState(outState);
    }

    @Override
    public void onStop() {
        super.onStop();
        mWebView.stopLoading();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (mWebView.inCustomView()) {
                mWebView.hideCustomView();
            //  mWebView.goBack();
                //mWebView.goBack();
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }
}

HTML % VIDEO.java

package com.ivz.idemandtest;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.webkit.GeolocationPermissions;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;

public class HTML5WebView extends WebView {

    private Context                             mContext;
    private MyWebChromeClient                   mWebChromeClient;
    private View                                mCustomView;
    private FrameLayout                         mCustomViewContainer;
    private WebChromeClient.CustomViewCallback  mCustomViewCallback;

    private FrameLayout                         mContentView;
    private FrameLayout                         mBrowserFrameLayout;
    private FrameLayout                         mLayout;

    static final String LOGTAG = "HTML5WebView";

    private void init(Context context) {
        mContext = context;     
        Activity a = (Activity) mContext;

        mLayout = new FrameLayout(context);

        mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(a).inflate(R.layout.custom_screen, null);
        mContentView = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.main_content);
        mCustomViewContainer = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.fullscreen_custom_content);

        mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);

        // Configure the webview
        WebSettings s = getSettings();
        s.setBuiltInZoomControls(true);
        s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        s.setUseWideViewPort(true);
        s.setLoadWithOverviewMode(true);
      //  s.setSavePassword(true);
        s.setSaveFormData(true);
        s.setJavaScriptEnabled(true);
        mWebChromeClient = new MyWebChromeClient();
        setWebChromeClient(mWebChromeClient);

        setWebViewClient(new WebViewClient());

setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

        // enable navigator.geolocation 
       // s.setGeolocationEnabled(true);
       // s.setGeolocationDatabasePath("/data/data/org.itri.html5webview/databases/");

        // enable Web Storage: localStorage, sessionStorage
        s.setDomStorageEnabled(true);

        mContentView.addView(this);
    }

    public HTML5WebView(Context context) {
        super(context);
        init(context);
    }

    public HTML5WebView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public HTML5WebView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }

    public FrameLayout getLayout() {
        return mLayout;
    }

    public boolean inCustomView() {
        return (mCustomView != null);
    }

    public void hideCustomView() {
        mWebChromeClient.onHideCustomView();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if ((mCustomView == null) && canGoBack()){
                goBack();
                return true;
            }
        }
        return super.onKeyDown(keyCode, event);
    }

    private class MyWebChromeClient extends WebChromeClient {
        private Bitmap      mDefaultVideoPoster;
        private View        mVideoProgressView;

        @Override
        public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback)
        {
            //Log.i(LOGTAG, "here in on ShowCustomView");
            HTML5WebView.this.setVisibility(View.GONE);

            // if a view already exists then immediately terminate the new one
            if (mCustomView != null) {
                callback.onCustomViewHidden();
                return;
            }

            mCustomViewContainer.addView(view);
            mCustomView = view;
            mCustomViewCallback = callback;
            mCustomViewContainer.setVisibility(View.VISIBLE);
        }

        @Override
        public void onHideCustomView() {
            System.out.println("customview hideeeeeeeeeeeeeeeeeeeeeeeeeee");
            if (mCustomView == null)
                return;        

            // Hide the custom view.
            mCustomView.setVisibility(View.GONE);

            // Remove the custom view from its container.
            mCustomViewContainer.removeView(mCustomView);
            mCustomView = null;
            mCustomViewContainer.setVisibility(View.GONE);
            mCustomViewCallback.onCustomViewHidden();

            HTML5WebView.this.setVisibility(View.VISIBLE);
            HTML5WebView.this.goBack();
            //Log.i(LOGTAG, "set it to webVew");
        }


        @Override
        public View getVideoLoadingProgressView() {
            //Log.i(LOGTAG, "here in on getVideoLoadingPregressView");

            if (mVideoProgressView == null) {
                LayoutInflater inflater = LayoutInflater.from(mContext);
                mVideoProgressView = inflater.inflate(R.layout.video_loading_progress, null);
            }
            return mVideoProgressView; 
        }

         @Override
         public void onReceivedTitle(WebView view, String title) {
            ((Activity) mContext).setTitle(title);
         }

         @Override
         public void onProgressChanged(WebView view, int newProgress) {
             ((Activity) mContext).getWindow().setFeatureInt(Window.FEATURE_PROGRESS, newProgress*100);
         }

         @Override
         public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
             callback.invoke(origin, true, false);
         }
    }


    static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS =
        new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}

custom_screen.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
    <FrameLayout android:id="@+id/fullscreen_custom_content"
        android:visibility="gone"
        android:background="@color/black"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    />
    <LinearLayout android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout android:id="@+id/error_console"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
        />

        <FrameLayout android:id="@+id/main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
        />
    </LinearLayout>
</FrameLayout>

video_loading_progress.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/progress_indicator"
         android:orientation="vertical"
         android:layout_centerInParent="true"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content">

       <ProgressBar android:id="@android:id/progress"
           style="?android:attr/progressBarStyleLarge"
           android:layout_gravity="center"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content" />

       <TextView android:paddingTop="5dip"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_gravity="center"
           android:text="@string/loading_video" android:textSize="14sp"
           android:textColor="?android:attr/textColorPrimary" />
 </LinearLayout>

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/any/http_authentication_colors.xml
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License"); 
** you may not use this file except in compliance with the License. 
** You may obtain a copy of the License at 
**
**     http://www.apache.org/licenses/LICENSE-2.0 
**
** Unless required by applicable law or agreed to in writing, software 
** distributed under the License is distributed on an "AS IS" BASIS, 
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
** See the License for the specific language governing permissions and 
** limitations under the License.
*/
-->
<!-- FIXME: Change the name of this file!  It is now being used generically
    for the browser -->
<resources>
    <color name="username_text">#ffffffff</color>
    <color name="username_edit">#ff000000</color>

    <color name="password_text">#ffffffff</color>
    <color name="password_edit">#ff000000</color>

    <color name="ssl_text_label">#ffffffff</color>
    <color name="ssl_text_value">#ffffffff</color>

    <color name="white">#ffffffff</color>
    <color name="black">#ff000000</color>



    <color name="geolocation_permissions_prompt_background">#ffdddddd</color>
</resources>

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Test"
                  android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:configChanges="orientation|keyboardHidden|keyboard">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>  
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
</manifest>

당신이 이해할 수있는 나머지 것들을 기대하십시오.


mdelolmo의 답변은 엄청나게 도움이되었지만 그가 말했듯이 비디오는 한 번만 재생되면 다시 열 수 없습니다.

나는 이것을 조금 살펴 보았고, 나 자신과 같은 피곤한 WebView 여행자가 미래 에이 게시물을 우연히 발견 한 경우를 대비하여 내가 찾은 것이 있습니다.

먼저 VideoViewMediaPlayer 의 설명서를 살펴보고 그 작동 방식을 더 잘 이해했습니다. 나는 그들을 강력히 추천합니다.

그런 다음 소스 코드를 살펴보고 Android 브라우저어떻게 작동하는지 확인 했습니다. 페이지를 찾아서 어떻게 처리하는지 살펴보십시오 onShowCustomView(). 이들은 CustomViewCallback및 사용자 정의보기에 대한 참조를 유지합니다 .

이 모든 것들과 mdelolmo의 대답을 염두에두고 비디오 작업을 마쳤 으면 두 가지 작업 만하면됩니다. 먼저 VideoView참조를 저장 한 후에는 나중에 다른 곳에서 사용할 수 있도록 호출 stopPlayback()합니다 MediaPlayer. VideoView 소스 코드 에서 볼 수 있습니다 . 둘째,에 CustomViewCallback대한 참조를 저장했습니다 CustomViewCallback.onCustomViewHidden().

이 두 가지 작업을 수행 한 후에는 동일한 비디오 또는 다른 비디오를 클릭하면 이전과 같이 열립니다. 전체 WebView를 다시 시작할 필요가 없습니다.

희망이 도움이됩니다.


사실, 재고 WebChromeClient를 클라이언트보기에 간단히 첨부하는 것으로 충분합니다.

mWebView.setWebChromeClient(new WebChromeClient());

하드웨어 가속을 켜야합니다!

최소한 전체 화면 비디오를 재생할 필요가없는 경우 VideoView를 WebView에서 끌어 와서 Activity의보기로 밀어 넣을 필요는 없습니다. 비디오 요소의 할당 된 rect에서 재생됩니다.

동영상 확장 버튼을 가로채는 방법에 대한 아이디어가 있습니까?


이 스레드가 몇 개월이 지난 것을 알고 있지만 WebView 내부에서 비디오를 전체 화면으로 재생하지 않고도 비디오를 재생할 수있는 솔루션을 찾았습니다 (그러나 여전히 미디어 플레이어에서는 ...). 지금까지 인터넷에서 이것에 대한 힌트를 찾지 못 했으므로 다른 사람들에게도 흥미 롭습니다. 나는 여전히 몇 가지 문제에 어려움을 겪고 있습니다 (즉, 미디어 플레이어를 화면의 오른쪽 섹션에 배치하면 왜 내가 잘못하고 있는지 알지 못하지만 비교적 작은 문제라고 생각합니다 ...).

맞춤 ChromeClient에서 LayoutParams를 지정합니다.

// 768x512 is the size of my video
FrameLayout.LayoutParams LayoutParameters = 
                                     new FrameLayout.LayoutParams (768, 512); 

내 onShowCustomView 메서드는 다음과 같습니다.

public void onShowCustomView(final View view, final CustomViewCallback callback) {
     // super.onShowCustomView(view, callback);
     if (view instanceof FrameLayout) {
         this.mCustomViewContainer = (FrameLayout) view;
         this.mCustomViewCallback = callback;
         this.mContentView = (WebView) this.kameha.findViewById(R.id.webview);
         if (this.mCustomViewContainer.getFocusedChild() instanceof VideoView) {
             this.mCustomVideoView = (VideoView) 
                                     this.mCustomViewContainer.getFocusedChild();
             this.mCustomViewContainer.setVisibility(View.VISIBLE);
             final int viewWidth = this.mContentView.getWidth();
             final int viewLeft = (viewWidth - 1024) / 2;
             // get the x-position for the video (I'm porting an iPad-Webapp to Xoom, 
             // so I can use those numbers... you have to find your own of course...
             this.LayoutParameters.leftMargin = viewLeft + 256; 
             this.LayoutParameters.topMargin = 128;
             // just add this view so the webview underneath will still be visible, 
             // but apply the LayoutParameters specified above
             this.kameha.addContentView(this.mCustomViewContainer, 
                                             this.LayoutParameters); 
             this.mCustomVideoView.setOnCompletionListener(this);
             this.mCustomVideoView.setOnErrorListener(this);
             // handle clicks on the screen (turning off the video) so you can still
             // navigate in your WebView without having the video lying over it
             this.mCustomVideoView.setOnFocusChangeListener(this); 
             this.mCustomVideoView.start();
         }
     }
 }

그래서, 내가 도울 수 있기를 바랍니다 ... 나도 비디오 인코딩을 가지고 놀았고 html5 비디오와 함께 WebView를 사용하는 다른 종류를 보았습니다. 결국 내 작업 코드는 내가 찾은 다른 코드 부분의 야생 혼합이었습니다. 인터넷과 내가 스스로 알아 내야 할 것들. 실제로 a *의 고통이었다.


이 접근 방식은 2.3까지 매우 잘 작동합니다. hardwareaccelerated = true를 추가하면 3.0에서 ICS까지도 작동합니다. 현재 직면하고있는 한 가지 문제는 미디어 플레이어 응용 프로그램의 두 번째 시작시 재생을 중단하지 않고 미디어 플레이어를 해제했기 때문에 작동이 중단되는 것입니다. 3.0 OS에서 onShowCustomView 함수로 제공되는 VideoSurfaceView 객체는 2.3 OS까지 VideoView 객체가 아닌 브라우저에만 적용됩니다. 어떻게 액세스하고 재생을 중지하고 리소스를 해제 할 수 있습니까?


AM은 BrowerActivity 와 유사합니다 . FrameLayout.LayoutParams의 경우 LayoutParameters = 새 FrameLayout.LayoutParams (768, 512);

사용할 수있을 것 같아

FrameLayout.LayoutParams LayoutParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
            FrameLayout.LayoutParams.FILL_PARENT) 

대신에.

내가 만난 또 다른 문제는 비디오가 재생 중이고 사용자가 뒤로 버튼을 클릭하면 다음에이 활동 (singleTop one)으로 이동하여 비디오를 재생할 수 없다는 것입니다. 이 문제를 해결하기 위해

try { 
    mCustomVideoView.stopPlayback();  
    mCustomViewCallback.onCustomViewHidden();
} catch(Throwable e) { //ignore }

활동의 onBackPressed 메소드에서.


나는 이것이 매우 오래된 질문이라는 것을 알고 있지만 hardwareAccelerated="true"응용 프로그램이나 활동에 대해 매니페스트 플래그를 사용해 보셨습니까?

이 세트를 사용하면 WebChromeClient 수정없이 작동하는 것 같습니다 (DOM 요소에서 기대할 수 있습니다).


이 문제를 해결하기 위해 html5webview사용했습니다. 다운로드 하여 프로젝트에 넣으면 다음과 같이 코딩 할 수 있습니다.

private HTML5WebView mWebView;
String url = "SOMEURL";
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mWebView = new HTML5WebView(this);
    if (savedInstanceState != null) {
            mWebView.restoreState(savedInstanceState);
    } else {
            mWebView.loadUrl(url);
    }
    setContentView(mWebView.getLayout());
}
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    mWebView.saveState(outState);
}

비디오를 회전 가능하게하려면 android : configChanges = "orientation"코드를 활동에 넣으십시오 (예 : Androidmanifest.xml).

<activity android:name=".ui.HTML5Activity" android:configChanges="orientation"/>

onConfigurationChanged 메소드를 대체하십시오.

@Override
public void onConfigurationChanged(Configuration newConfig) {
     super.onConfigurationChanged(newConfig);
}

이 질문은 오래되었지만 내 대답은 오래된 Android 버전을 지원 해야하는 나와 같은 사람들에게 도움이 될 것입니다. 일부 안드로이드 버전에서 작동하는 많은 다른 접근법을 시도했지만 전부는 아닙니다. 내가 찾은 최고의 솔루션 은 HTML5 기능 지원에 최적화되어 Android 4.1 이상에서 작동 하는 Crosswalk Webview 를 사용하는 것 입니다. 기본 Android WebView처럼 사용하기가 쉽습니다. 라이브러리 만 포함하면됩니다. 여기에서 사용 방법에 대한 간단한 자습서를 찾을 수 있습니다. https://diego.org/2015/01/07/embedding-crosswalk-in-android-studio/


글쎄, 분명히 JNI를 사용하여 비디오 이벤트를 가져 오기 위해 플러그인을 등록하지 않으면 불가능할 것입니다. (개인적으로 ANI 기반 안드로이드 태블릿이 몇 개월 안에 나올 때 Java의 이식성을 잃을 때 혼란을 다루고 싶지 않기 때문에 개인적으로 JNI를 피하고 있습니다.)

유일한 대안은 WebView 전용으로 새 웹 페이지를 만들고 위의 Codelark url에 인용 된 것처럼 HREF 링크를 사용하여 구식 방식으로 비디오를 만드는 것 같습니다.

이키


벌집 사용에 hardwareaccelerated=truepluginstate.on_demand작동하는 것 같다


나는 비슷한 문제가 있었다. 내 앱의 자산 폴더에 HTML 파일과 비디오가 있습니다.

따라서 비디오는 APK 내부에있었습니다. APK는 실제로 ZIP 파일이므로 WebView에서 비디오 파일을 읽을 수 없습니다.

모든 HTML 및 비디오 파일을 SD 카드에 복사하면 나에게 도움이되었습니다.

참고 URL : https://stackoverflow.com/questions/3815090/webview-and-html5-video

반응형