Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用webview从嵌入链接获取.m3u8链接_Android_Video Streaming_Android Webview_Android Videoview_Webviewclient - Fatal编程技术网

Android 如何使用webview从嵌入链接获取.m3u8链接

Android 如何使用webview从嵌入链接获取.m3u8链接,android,video-streaming,android-webview,android-videoview,webviewclient,Android,Video Streaming,Android Webview,Android Videoview,Webviewclient,我是Android开发的新手,我想从dailymotion的嵌入式链接中获取.m3u8链接,但我使用的是webview客户端,但我不知道如何实现 我的代码是: public class WebViewActivity extends Activity implements DownloadListener { private WebView webview; private static final String TAG = "WebViewActivity"

我是Android开发的新手,我想从dailymotion的嵌入式链接中获取.m3u8链接,但我使用的是webview客户端,但我不知道如何实现

我的代码是:

public class WebViewActivity extends Activity implements DownloadListener {

    private WebView webview;
    private static final String TAG = "WebViewActivity";
    private ProgressDialog progressBar;
    WebViewActivity myContxt;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_web_view);


        init();
    }

    public void init()
    {
        myContxt=this;

        webview = (WebView)findViewById(R.id.webview);

        WebSettings settings = webview.getSettings();
        settings.setJavaScriptEnabled(true);
        webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

        final AlertDialog alertDialog = new AlertDialog.Builder(this).create();

        progressBar = ProgressDialog.show(myContxt, "WebView Example", "Loading...");

        webview.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                Toast.makeText(myContxt,url,Toast.LENGTH_SHORT).show();
                Log.w(TAG, "Processing webview url click...");
                Log.w(TAG,url);
                webview.setDownloadListener(myContxt);
                view.loadUrl(url);
                return true;
            }

            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                Log.w(TAG,url);
                if (progressBar != null && progressBar.isShowing()) {
                    progressBar.dismiss();
                }
                progressBar = ProgressDialog.show(myContxt, "Application Name", "Loading...");
            }

            public void onPageFinished(WebView view, String url) {
                Log.w(TAG,url);
                Log.i(TAG, "Finished loading URL: " + url);
                if (progressBar.isShowing()) {
                    progressBar.dismiss();
                }
            }

            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Log.e(TAG, "Error: " + description);
                Toast.makeText(myContxt, "Oh no! " + description, Toast.LENGTH_SHORT).show();
                alertDialog.setTitle("Error");
                alertDialog.setMessage(description);
                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
                alertDialog.show();
            }
        });

        webview.loadUrl("http://www.dailymotion.com/embed/video/x2bnb3s");


    }

    @Override
    public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
        Log.w("m3u8888",url);
    }