0

I have embedded a youtube video as shown here. I have several videos and when one finishes the next one starts automatically. I achieved this by looking up the video duration and starting a TimerTask.

Now there is one problem left: If the user pauses the youtube video, the timer continues and the next video starts after some time. I thought of this solution but could not make it happen: Implement a JButton, that stops the timer, changes the focus to the youtube video and presses the space button. That should stop the video. I played with the JWebBrowser.grabFocus() and alike but I was not succesful.

Any help would be appreciated.

Community
  • 1
  • 1
Selphiron
  • 897
  • 1
  • 12
  • 30
  • 1
    requestFocusInWindow? – MadProgrammer Jan 01 '16 at 00:38
  • @MadProgrammer yes I tried that too but it does not work. When I do webBrowser.requestFocusInWindows() and press space, nothing happens. But when I click on the youtube video and then press space the video stops. I also tried webBrowserPanel.requestFocusInWindows() – Selphiron Jan 02 '16 at 11:00
  • Requesting focus on the component may not give focus to the you tube video element, unless the `JWebBrowser` component provides you a means to focus a given element, I don't think you'll get much luck – MadProgrammer Jan 02 '16 at 11:35

0 Answers0