Is there is any way to play Youtube videos on JavaFX Application? I was trying this-
public class YoutubeVideoPlayer extends Application
{
@Override
public void start(Stage stage) throws Exception
{
WebView webview = new WebView();
webview.getEngine().load("http://www.youtube.com/embed/_3op5hukpIE?autoplay=1");
webview.setPrefSize(640, 390);
stage.setScene(new Scene(webview));
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}
I don't know how, but once it worked fine. But every time it is showing me an error message:
An error occured. Please try again later.
Can anyone explain how did it work and how can I make it work again?