Capture play event from mediaplayer on webview? - android

I need access to media controls of video player embedded in webview html page. Webpage is a client web page and cannot be modified to achieve javascript interaction.
Basically I need the video download url, tried using shouldOverrideUrlLoading() of webview client, it doesn't work for flash players on webpage.

If you play the video in videoview then you can control using mediaPlayer.
But in case of videoPlayer embedded in webview I don't think you'll have access to control the player.

Related

Android playing videos based on url

I got a problem related to playing videos based on Url i get. I made 2 cases, but each one has its problem.
1) using android VideoView
videoPlayer.setVideoURI(Uri.parse(videoUrl));
videoPlayer.setMediaController(new MediaController(this));
videoPlayer.requestFocus();
videoPlayer.start();
The problem is that it doesn't open such types of video url
https://www.facebook.com/zloishkolnik/videos/462625797256094/
https://www.youtube.com/watch?v=YVkUvmDQ3HY
2) using android WebView
videoPlayer.setWebViewClient(new WebViewClient());
videoPlayer.getSettings().setJavaScriptEnabled(true);
videoPlayer.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
videoPlayer.getSettings().setPluginState(WebSettings.PluginState.ON);
videoPlayer.setWebChromeClient(new WebChromeClient());
videoPlayer.loadUrl(videoUrl);
Webview opens the links above, but doesnt open such type of links
http://www.db.cartosnet.com/videos/EU5beThfNI.mp4
Am i doing something wrong or there is any library that reads any video url given?
To play videos through your way (setting a url to Videoview), your endpoint must be the video as itself. Example of a valid endpoint: https://ia600404.us.archive.org/1/items/popeye_patriotic_popeye/popeye_patriotic_popeye_512kb.mp4
If you want to play videos, in your case, embedded videos, you should use a API (like Youtube, Facebook...)

How to launch Youtube when clicking on an embedded video in my Android WebView

I have a webview which displays some HTML, and includes embedded YouTube videos. The videos are wrapped in an iframe tag and I have setJavascriptEnabled(true) in my Java file, so the video can play in the WebView. However, I would like to be able to launch Youtube when the user clicks the video.
Other posts on SO suggested that I parse out the video ID's and start an intent. However, this seems pretty tedious considering there can be multiple videos. In addition, I'm not sure how to set the iframe to clickable to listen for a click event.
Any suggestions?

VideoView or WebView in YouTube Android App

Now this is a really stupid one! Forgive me on this question please but I really don't know the answer to it. My question is What have Youtube used to play videos intheir Android app? I mean is it a WebView or Just a simple VideoView? I used VideoView to play videos from the URL associated with them but it doesn't look as nice as YouTube's VideoView (or whatever it is)
And is there any other option to play videos from a URL other than using the code below? Because it just plays video in the native video player. If the red-marked portion in the image below is a VideoView, how does it look better than the normal VideoView? Or is it a WebView? Which one is a better option (in terms of UI) to play video from a URL? I'm using GingerBread and want to play mp4 or .flv videos in a VideoView or WebView (whichever is the better option, preferably like Android's YouTube app)
Uri data = Uri.parse(movieurl);
intent.setDataAndType(data,"video/3gpp");
startActivity(intent);

Embedded video inside of Android media player

I have an application that I want to play a video in. I want to play the video from an embed code via html5 in an iframe. Is it possible to call the androids stock video player to play the video from the iframe embed code?
I fixed this by putting my embed code in an html file inside the assets folder. works greate.

.mov file will play in browser, but not in native MediaPlayer app

I am launching the MediaPlayer to play a .mov file that is being passed into the MediaPlayer as a Uri (which is standard). However, it is telling me that it cannot play the file. However, if I put this same link on the web, and the click the link to launch the movie (while in my Android browser) the video plays no problem. However, I can't get the WebView to play it with the Video tag despite all my efforts.
So here is my question, what magic is taking place that allows an android browser app to take a .html url which contains a link to play a video and play it? If I load the same url in a WebView, or try to pass the video url into the mediaplayer, it is a no go. The format of the video is .mov.
Thanks in advance to everyone.
The Android browser and WebView are very different, WebView is very barebones as it was designed expecting people to use it for very basic showing html webpages. WebView by default has no plugins enabled, no javascript enabled and so on and so on. Never expect that because something works in the browser that it will work in a WebView.
Now in regards to how the media is handled. The Browser has extra features set up to strip the video source from the page and launch it in the native player most of the time. This functionality is not built into WebView. And the native player is very picky about what needs to passed into it as a URI to be able to play it.
Hope that helps,
Stevy888

Categories

Resources