I have created a youtube video player with a JavaFX application and I want to launch this application with a play button on my main frame. I have created a play button an created its actionlistener to launch the application. The app launches without any problem but when I try to close it, the window closes but the video keeps on playing in the background. How can completely shut down the launched application( video player ) , so it does not continue playing the video. The code for my app is here
public class YoutubeVideoPlayer extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception{
WebView webView = new WebView();
webView.getEngine().load("https://www.youtube.com/embed/6uL3SHfllh8");
webView.setPrefSize( 300 , 300);
primaryStage.setScene( new Scene( webView ) );
primaryStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){
@Override
public void handle(WindowEvent we) {
Platform.setImplicitExit(true);
primaryStage.close();
Platform.exit();
}
});
}
}
Again, I want the YoutubeVideoPlayer to completely shut down ( stop the video from playing ) without closing the main application. I do not have much knowledge of JavaFX so I would really appreciate if you could explain your answer. Thanks...