How to use custom video player in a webview?

Inan Mahmud :

I want to make a simple browser app in android webview. Whenever I enter a website, if there's a video in that url, the video would be played into my custom video player automatically. Can anyone help me with this?

Masoud Mokhtari :

You must use javascript for this purpose. First, set a key in your content that load in your WebView, then with below code show any video with your custom VideoPlayer. Everywhere you have video at your url that load with webView, you must have like this:

"your_key:video_url"

Try this code:

web_view = (WebView) view.findViewById(R.id.web_view);
web_view.getSettings().setJavaScriptEnabled(true);
web_view.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                //your_key is your javaScript key
                final String videoUrl = url.replace("your_key:", "");

                Intent intent=new Intent(getContext(), VideoPlayerActivity.class);
                intent.putExtra("url",videoUrl);
                startActivity(intent);
                return false;
            }
        });
web_view.loadUrl(yourUrl);

As you see at above, when you click on any video, you get it's url and pass it to your videoPlayerActivity for showing with your custom videoPlayer.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to check if webview YouTube video player was started

How to use Custom Font with Youtube Player?

How to capture still image from custom video player screen in iOS?

WebView NOT opening android default video player?

how to use nvidia vdpau decoding for mplayer video player in linux?

How to use OpenCV video capture with custom video input?

custom NSView with video player is not showing (MacOS)

Playing Vimeo Videos with Custom Video Player in iOS

How to put video playlist next to the video player?

Youtube video player inside app(which plays inside webview itself)

How to stop video playing in WebView

How to show video in webView on Android

How to use plyr npm module in angular to create a video player in Angular2?

How do I use SVP (Smooth Video Project) with my Media Player Classic?

WKWebView how display video content in website player and don't use fullscreen AVPlayer

How to play more video on the same player with Vimeo player.js

how to get youtube player id and stop video

How to make a Youtube player popout and play a video?

How to mute an html5 video player

How to get current duration of video in exo player?

How to interact with Netflix Cadmium video player on the client?

Netflix video player in Chrome - how to seek?

How to make video player in java using vlcj?

How to make video player size smaller ?

how to reduce html video player size in bootstrap

How to align the Grid to the height of the video player?

How to have border radius in flutter video player?

How to autoplay video through YouTube Player

how to play Youtube Video in VLC Player