JavaFX 2 embed YouTube video - java

Is there a way to embed a YouTube video with JavaFX 2 without a WebView? And if using a WebView is the only viable option, how can I detect when a video started and ended?

Is there a way to embed a YouTube video with JavaFX 2 without a WebView?
Technically, probably yes, but legally no as that would require using a video player other than the YouTube video player, which would violate YouTube's current terms of service.
If instead, you embed a player in JavaFX using a WebView to display YouTube's HTML5 embedded player, then that is ok with the YouTube terms of service agreement.
how can I detect when a video started and ended?
Use the YouTube JavaScript API to monitor playback status.

Related

Play a video on Android full screen from website link

I have a website which lists the links to videos. Clicking on these links will play video on browser.
Now, I am planning to develop an Android app for my website. The way I am going to do is just framing this website inside Android app.
Now, when I click on these links inside the Android app, the video is getting played as like it plays on the browser. But I need it in a way such that when a user clicks on these links the video should play automatically on full screen landscape mode.
What modification should be done in the coding to play this video on full screen upon clicking on the video link?
Thanks

How to check if video is playing if we have video URL?

I am writing a java class where i have some video URLs . I want to check if the video is played or not . In other words i just need to validate the video URL
I have heard we can use Selenium for this but i have no idea.
Thanks in Advance
If your video is playing using html5 tag and are using selenium then you can check that as following:
driver.findElement(by.xpath("Video element")).getAttribute("currentTime");
if it is greater than 0 that means those many seconds of playback o/w:
driver.findElement(by.xpath("Video element")).getAttribute("ended");
will show if playback has ended.
Selenium is a web driver that works by inspecting the DOM and interacting with the browser so I am assuming your java class ends up generating a web page.
I've never tried to interact with a video player before but assuming you are using html5 for your player you should be able to play the video by getting the play button element from the page and actioning a click on it. To verify that it actually plays you could wait a few seconds then verify via the progress bar that the current point in the video is past the 0:00 moment.
The above said, if these videos are external URLs you should avoid testing them, your testing should refrain to what is within the scope of your application, IE check that a video player is on the page, and confirm that it points at the expected link, but not that external resources are available (IE that a random video is still available on YouTube).

Youtube videos in webView using Youtube API

My current problem: I am using a webView to show web content in my app. In one link (which I need to show in webView) there is nothing more but just 3 youtube videos from 1 channel.
Question: How to use youtube API that it would automatically detect these videos and play correctly when the mentioned link is being opened?
I tried to use only webView to show youtube content but I am facing many problems with it - youtube video sometimes doesn't play at all, there is problems with Android version compatibility, etc. And as I read in general in forums - webView itself is not recommended to be used as html5 youtube video player. Most people suggests to use "new Youtube API". So how exactly implement this youtube API in my case?
Any examples? Suggestions?
Google release Youtube Android player api so that you can import this library to use
it's a good video player for watch YouTube video and playlist
YouTube Android Player API

Integrating flash player in JavaFX web browser

I created a web browser using WebView and WebEngine classes of JavaFX. It is working fine but not able to play videos. It is opening youtube.com but is not playing videos of youtube. It is asking to install Adobe flash player. Even after installing, the problem is same. Do I have to integrate some plug-in of Adobe Flash Player in my Java code. If yes, how? Or there is some other solution. Kindly help.
WebView in JavaFX 2.2 does not support plugin based content such as Flash content.
As alternatives, for launching YouTube video content from JavaFX you can use:
HostServices.showDocument go launch flash content in the default system web browser OR
YouTube's iframe embedding API in WebView rather than it's flash interface.
The YouTube iframe embedding API embeds html5 video content, rather than flash video content and html5 video content works in WebView.
For more info, see http://www.youtube.com/html5

Any options to build your own java based youtube html5 video player for android?

I need to build a Video Player in android that can play
youtube HTML5 videos (www.youtube.com/html5) also be able
to embed the player within an android app I build.
The tablets I am building this app for cannot use flash at all
(this is why I need to build my own).
This would end up being a kids app, so I really only want to give
them 4 options on the player: play, reply, pause, exit
I am still a little confused as to would I be playing this embed
video in my custom app (with custom video player i make) using rtsp://
or a m.youtube.com H.264
Thanks in advance, all help appreciated
These projects from GIthub might get you started.
vivdub / AndroidMediaplayer
joelbinn / media-player
lxz2003 / mediaplayer

Categories