从Webview下载Android视频

时间:2019-01-02 08:38:02

标签: android android-studio

我正在制作视频下载应用程序,但是当我从dailymotion下载视频时,它仅下载10秒钟的视频,不完整的视频找不到我的代码错误

if (extension != null) {
            MimeTypeMap mime = MimeTypeMap.getSingleton();
            String mimeType = mime.getMimeTypeFromExtension(extension);
            // Toast.makeText(context, "abc", Toast.LENGTH_SHORT).show();
            Log.i("runing", "shouldInterceptRequest: "+mimeType);
            if (mimeType != null) {
                if (mimeType.toLowerCase().contains("mp4") || mimeType.toLowerCase().contains("video")
                        || mimeType.toLowerCase().contains("mov") || mimeType.toLowerCase().contains("video/mp2ts") ||
                        mimeType.toLowerCase().contains("mp2ts")
                        || mimeType.toLowerCase().contains("mp3")) {


            final WebViewClient webViewClient=new WebViewClient();

                                            DownloadManager mdDownloadManager = (DownloadManager)
                                                    getSystemService(Context.DOWNLOAD_SERVICE);
                                            DownloadManager.Request request = new DownloadManager.Request(
                                                    Uri.parse(urls));
                                            File destinationFile = new File(
                                                    Environment.getExternalStorageDirectory()+"/All Video Downloader",
                                                    webViewClient.getFileName(urls));
                                            request.setDescription("Downloading via Your app name..");
                                            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                                            request.setDestinationUri(Uri.fromFile(destinationFile));
                                            mdDownloadManager.enqueue(request);
                                            value[0] = false;



                }
            }
        }

}

0 个答案:

没有答案