ZinXanCraft
ZinXanCraft

Reputation: 145

JavaFX MediaPlayer with youtube?

I was wondering if it was possible to make a video player in JavaFX that can play a video the user find on youtube legally.

If it is legal and possible how do I so find the link to the video xx.

Upvotes: 2

Views: 709

Answers (1)

sazzy4o
sazzy4o

Reputation: 3343

As far as I know you can legal link the video as long as it is set as embed-able. In javafx you can load YouTube videos with a webview like this:

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
          webEngine.load("https://www.youtube.com/embed/-ppPl182K30");  

You can replace //www.youtube.com/embed/-ppPl182K30 with the embed url of the video you want to play. If you dont know where to find it this is a picture of where it is on the YouTube video page http://goreserva.com/images/youtube-embed-url.jpg

Keep in mind dont remove the https: or else the video wont load and It may take a few seconds for the video to load.
I hope this helped!

Upvotes: 1

Related Questions