I have embedded a youtube video as shown here. Now I want something to happen, when the video finishes.
I guess the hard way would be to download the video as an object etc.
Is there an easier way?
Any help would be appreciated.
I have embedded a youtube video as shown here. Now I want something to happen, when the video finishes.
I guess the hard way would be to download the video as an object etc.
Is there an easier way?
Any help would be appreciated.
Copyright © 2021 Jogjafile Inc.
The
JWebBrowser
component from The DJ project as used in the very nice example by Jk1 supports a listener that you can add to it to receive browser events. You could use these events to search for specific events that indicate the video is finished. This depends on how YouTube works, which could be platform/browser dependent and will change over time. So no hard science here, but perhaps this approach is good enough for your situation.Here is the modified code of the above mentioned example, which adds a listener for the browser events (implementing only two of the ten available
WebBrowserListener
methods) and some logging. I used DJNativeSwing-SWT-1-0-2 and swt-4.5-win32-win32-x86_64:And here the output for a short test:
On my machine, the
statusChanged
event where the status text of thewebBrowser
field is "Downloading picture res://ieframe.dll/background_gradient.jpg..." seems to indicate that the video is finished.