Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the way I usualy use to embed YouTube videos into Swing application. </p> <p>Instead of YouTube API a native browser component is embedded into JPanel using <a href="http://djproject.sourceforge.net/ns/" rel="noreferrer">DJ Native Swing</a>: </p> <pre><code>public class YouTubeViewer { public static void main(String[] args) { NativeInterface.open(); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame("YouTube Viewer"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(getBrowserPanel(), BorderLayout.CENTER); frame.setSize(800, 600); frame.setLocationByPlatform(true); frame.setVisible(true); } }); NativeInterface.runEventPump(); // don't forget to properly close native components Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { NativeInterface.close(); } })); } public static JPanel getBrowserPanel() { JPanel webBrowserPanel = new JPanel(new BorderLayout()); JWebBrowser webBrowser = new JWebBrowser(); webBrowserPanel.add(webBrowser, BorderLayout.CENTER); webBrowser.setBarsVisible(false); webBrowser.navigate("https://www.youtube.com/v/b-Cr0EWwaTk?fs=1"); return webBrowserPanel; } } </code></pre> <p>When running it looks like</p> <p><img src="https://i.stack.imgur.com/fadWP.png" alt="enter image description here"></p> <p>The following libraries are necessary to launch an example above:</p> <ul> <li>DJNativeSwing.jar</li> <li>DJNativeSwing-SWT.jar</li> <li>swt-4.3-win32-win32-x86.jar (This one is platform dependent)</li> </ul> <p>you can get all of them from a DJ Native Swing download package.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload