Search in sources :

Example 1 with Audio

use of com.teamdev.jxbrowser.media.Audio in project JxBrowser-Examples by TeamDev-IP.

the class MuteAudio method main.

public static void main(String[] args) {
    Engine engine = Engine.newInstance(HARDWARE_ACCELERATED);
    Browser browser = engine.newBrowser();
    SwingUtilities.invokeLater(() -> {
        BrowserView view = BrowserView.newInstance(browser);
        JButton muteAudioButton = new JButton("Mute Audio");
        muteAudioButton.addActionListener(e -> {
            Audio audio = browser.audio();
            if (audio.isMuted()) {
                audio.unmute();
            } else {
                audio.mute();
            }
            updateButtonText(muteAudioButton, browser);
        });
        JFrame frame = new JFrame("Mute Audio");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(muteAudioButton, BorderLayout.NORTH);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    });
    browser.navigation().loadUrl("https://www.youtube.com/");
}
Also used : JFrame(javax.swing.JFrame) JButton(javax.swing.JButton) BrowserView(com.teamdev.jxbrowser.view.swing.BrowserView) Audio(com.teamdev.jxbrowser.media.Audio) Engine(com.teamdev.jxbrowser.engine.Engine) Browser(com.teamdev.jxbrowser.browser.Browser)

Aggregations

Browser (com.teamdev.jxbrowser.browser.Browser)1 Engine (com.teamdev.jxbrowser.engine.Engine)1 Audio (com.teamdev.jxbrowser.media.Audio)1 BrowserView (com.teamdev.jxbrowser.view.swing.BrowserView)1 JButton (javax.swing.JButton)1 JFrame (javax.swing.JFrame)1