Javascript:如何获取当前正在播放的视频的网址?

时间:2018-07-16 16:12:18

标签: javascript android performance url video

这是我的JavaScript的代码:

$("video").on("play", function() { App.show_success(); });

所以我想获得视频的直接URL。

这就是我的MainActivity的代码:

class MyJavaScriptInterface
{
    @JavascriptInterface
    public void show_success()
    {
        //called by javascript

        AlertDialog.Builder video_downloaden = new AlertDialog.Builder(SearchActivity.this);
        video_downloaden.setTitle("Download Video?");
        video_downloaden.setMessage("Download this video?");
        video_downloaden.setPositiveButton("YES", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                video_number++;
                DownloadManager.Request request_video = new DownloadManager.Request(Uri.parse(url_of_loaded_video));
                request_video.allowScanningByMediaScanner();

                request_video.setVisibleInDownloadsUi(false);

                DownloadManager downloadManager2 = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);

                request_video.setDestinationInExternalFilesDir(getApplicationContext(), DIRECTORY_DOWNLOADS, File.separator + ".Videos" + File.separator + "video" + video_number);

                downloadManager2.enqueue(request_video);
                Toast.makeText(getApplicationContext(),"Video Download gestartet...",Toast.LENGTH_SHORT).show();

            }
        });
        video_downloaden.setNegativeButton("NEIN", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
        });

        video_downloaden.show();
    }
}

那么是否有可能获得正在播放的视频的http:// .... .mp4 url,并将此url设置为DownloadManager

0 个答案:

没有答案