mirror of
https://github.com/mirror/jdownloader.git
synced 2025-02-20 12:31:56 +00:00
Removed Embeded VLC Code
git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@17839 ebf7c1c2-ba36-0410-9fe8-c592906822b4
This commit is contained in:
parent
ba1e83f181
commit
e067ffe2d9
@ -93,7 +93,5 @@
|
||||
<classpathentry kind="lib" path="ressourcen/libs/bcprov-jdk15on-147.jar"/>
|
||||
<classpathentry kind="lib" path="ressourcen/libs/sevenzipjbindingLinux.jar"/>
|
||||
<classpathentry kind="lib" path="ressourcen/libs/sevenzipjbindingMac.jar"/>
|
||||
<classpathentry kind="lib" path="ressourcen/libs/platform.jar"/>
|
||||
<classpathentry kind="lib" path="ressourcen/libs/vlcj.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
jna platform
|
||||
version 3.4.0
|
||||
lgpl
|
||||
https://github.com/twall/jna
|
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
Version 2.1.0
|
||||
http://code.google.com/p/vlcj/
|
||||
GPL v3
|
@ -12,9 +12,12 @@ import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import jd.Launcher;
|
||||
import jd.nutils.Executer;
|
||||
import jd.parser.Regex;
|
||||
import jd.plugins.DownloadLink;
|
||||
|
||||
import org.appwork.utils.Application;
|
||||
import org.appwork.utils.StringUtils;
|
||||
import org.appwork.utils.ImageProvider.ImageProvider;
|
||||
import org.appwork.utils.os.CrossSystem;
|
||||
@ -88,12 +91,12 @@ public class VLCStreamingExtension extends AbstractExtension<VLCStreamingConfig,
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "VLC Streaming";
|
||||
return "Audio & Video Streaming";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageIcon getIcon(int size) {
|
||||
return NewTheme.I().getIcon("vlc-ico", size);
|
||||
return NewTheme.I().getIcon("video", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,15 +156,13 @@ public class VLCStreamingExtension extends AbstractExtension<VLCStreamingConfig,
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// Executer exec = new Executer(getVLCBinary());
|
||||
// exec.setLogger(LogController.CL());
|
||||
// exec.addParameters(new String[] { "http://127.0.0.1:" + RemoteAPIController.getInstance().getApiPort() +
|
||||
// "/vlcstreaming/play?id=" + link.getUniqueID() });
|
||||
// exec.setRunin(Application.getRoot(Launcher.class));
|
||||
// exec.setWaitTimeout(0);
|
||||
// exec.start();
|
||||
Executer exec = new Executer(getVLCBinary());
|
||||
exec.setLogger(LogController.CL());
|
||||
exec.addParameters(new String[] { "http://127.0.0.1:" + RemoteAPIController.getInstance().getApiPort() + "/vlcstreaming/play?id=" + link.getUniqueID() });
|
||||
exec.setRunin(Application.getRoot(Launcher.class));
|
||||
exec.setWaitTimeout(0);
|
||||
exec.start();
|
||||
|
||||
tab.playMedia("http://127.0.0.1:" + RemoteAPIController.getInstance().getApiPort() + "/vlcstreaming/play?id=" + link.getUniqueID());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,42 +1,19 @@
|
||||
package org.jdownloader.extensions.vlcstreaming.gui;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import jd.gui.swing.jdgui.JDGui;
|
||||
import jd.gui.swing.jdgui.interfaces.SwitchPanel;
|
||||
import jd.plugins.AddonPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.appwork.swing.components.ExtButton;
|
||||
import org.appwork.utils.logging.Log;
|
||||
import org.appwork.utils.logging2.LogSource;
|
||||
import org.appwork.utils.os.CrossSystem;
|
||||
import org.jdownloader.actions.AppAction;
|
||||
import org.jdownloader.extensions.vlcstreaming.VLCStreamingExtension;
|
||||
import org.jdownloader.logging.LogController;
|
||||
|
||||
import uk.co.caprica.vlcj.binding.LibVlc;
|
||||
import uk.co.caprica.vlcj.binding.LibVlcFactory;
|
||||
import uk.co.caprica.vlcj.player.AudioOutput;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
|
||||
import uk.co.caprica.vlcj.player.embedded.DefaultFullScreenStrategy;
|
||||
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
|
||||
import uk.co.caprica.vlcj.player.embedded.FullScreenStrategy;
|
||||
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
|
||||
import uk.co.caprica.vlcj.runtime.windows.WindowsCanvas;
|
||||
import uk.co.caprica.vlcj.runtime.windows.WindowsRuntimeUtil;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLibrary;
|
||||
|
||||
public class VLCGui extends AddonPanel<VLCStreamingExtension> implements MouseListener {
|
||||
|
||||
private static final String ID = "VLCGUI";
|
||||
@ -65,92 +42,8 @@ public class VLCGui extends AddonPanel<VLCStreamingExtension> implements MouseLi
|
||||
|
||||
}
|
||||
|
||||
private Canvas videoSurface;
|
||||
private MediaPlayerFactory mediaPlayerFactory;
|
||||
private EmbeddedMediaPlayer mediaPlayer;
|
||||
|
||||
private void layoutPanel() {
|
||||
|
||||
try {
|
||||
System.out.println(RuntimeUtil.getLibVlcLibraryName());
|
||||
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Users\\Thomas\\Downloads\\vlc-2.0.2-win64\\vlc-2.0.2");
|
||||
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LibVlc libVlc = LibVlcFactory.factory().create();
|
||||
//
|
||||
logger.info(" version: " + libVlc.libvlc_get_version());
|
||||
logger.info(" compiler: " + libVlc.libvlc_get_compiler());
|
||||
logger.info("changeset: " + libVlc.libvlc_get_changeset());
|
||||
|
||||
if (CrossSystem.isWindows()) {
|
||||
videoSurface = new WindowsCanvas();
|
||||
} else {
|
||||
videoSurface = new Canvas();
|
||||
}
|
||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||
|
||||
videoSurface.addMouseListener(this);
|
||||
List<String> vlcArgs = new ArrayList<String>();
|
||||
|
||||
// vlcArgs.add("--ffmpeg-hw"); // <--- if your system supports it, this might be useful
|
||||
vlcArgs.add("--no-plugins-cache");
|
||||
vlcArgs.add("--no-video-title-show");
|
||||
vlcArgs.add("--no-snapshot-preview");
|
||||
vlcArgs.add("--quiet");
|
||||
vlcArgs.add("--quiet-synchro");
|
||||
vlcArgs.add("--intf");
|
||||
vlcArgs.add("dummy");
|
||||
|
||||
System.out.println(WindowsRuntimeUtil.getVlcInstallDir());
|
||||
// Special case to help out users on Windows (supposedly this is not actually needed)...
|
||||
// if(RuntimeUtil.isWindows()) {
|
||||
// vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins");
|
||||
// }
|
||||
// else {
|
||||
// vlcArgs.add("--plugin-path=/home/linux/vlc/lib");
|
||||
// }
|
||||
|
||||
// vlcArgs.add("--plugin-path=" + System.getProperty("user.home") + "/.vlcj");
|
||||
|
||||
logger.info("vlcArgs=" + vlcArgs);
|
||||
|
||||
FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(JDGui.getInstance().getMainFrame());
|
||||
|
||||
mediaPlayerFactory = new MediaPlayerFactory(vlcArgs.toArray(new String[vlcArgs.size()]));
|
||||
mediaPlayerFactory.setUserAgent("vlcj test player");
|
||||
List<AudioOutput> audioOutputs = mediaPlayerFactory.getAudioOutputs();
|
||||
logger.info("audioOutputs=" + audioOutputs);
|
||||
|
||||
mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy);
|
||||
mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(videoSurface));
|
||||
mediaPlayer.setPlaySubItems(true);
|
||||
|
||||
// mediaPlayer.setEnableKeyInputHandling(false);
|
||||
// mediaPlayer.setEnableMouseInputHandling(false);
|
||||
|
||||
// controlsPanel = new PlayerControlsPanel(mediaPlayer);
|
||||
// videoAdjustPanel = new PlayerVideoAdjustPanel(mediaPlayer);
|
||||
//
|
||||
|
||||
panel.add(videoSurface);
|
||||
// mainFrame.add(controlsPanel, BorderLayout.SOUTH);
|
||||
// mainFrame.add(videoAdjustPanel, BorderLayout.EAST)
|
||||
|
||||
panel.add(new ExtButton(new AppAction() {
|
||||
{
|
||||
setName("Play");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
mediaPlayer.toggleFullScreen();
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,10 +120,4 @@ public class VLCGui extends AddonPanel<VLCStreamingExtension> implements MouseLi
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void playMedia(String string) {
|
||||
mediaPlayer.playMedia(string);
|
||||
|
||||
JDGui.getInstance().getMainTabbedPane().setSelectedComponent(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,105 +0,0 @@
|
||||
package org.jdownloader.extensions.vlcstreaming.test;
|
||||
|
||||
/*
|
||||
* This file is part of VLCJ.
|
||||
*
|
||||
* VLCJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* VLCJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright 2009, 2010, 2011, 2012 Caprica Software Limited.
|
||||
*/
|
||||
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UIManager.LookAndFeelInfo;
|
||||
|
||||
import uk.co.caprica.vlcj.logger.Logger;
|
||||
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
|
||||
import uk.co.caprica.vlcj.runtime.x.LibXUtil;
|
||||
|
||||
import com.sun.jna.NativeLibrary;
|
||||
|
||||
/**
|
||||
* Base class for tests.
|
||||
* <p>
|
||||
* This makes it a lot easier to switch vlc versions or vlc install directories without having to change system properties on a lot of IDE
|
||||
* application run-configurations.
|
||||
* <p>
|
||||
* Explicitly setting a search path forces JNA to search that path <em>first</em>.
|
||||
* <p>
|
||||
* The search path should be the directory that contains libvlc.so and libvlccore.so.
|
||||
* <p>
|
||||
* If you do not explicitly set the search path, the system search path will be used.
|
||||
* <p>
|
||||
* You can also set the log level here.
|
||||
*/
|
||||
public abstract class VlcjTest {
|
||||
|
||||
/**
|
||||
* Log level, used only if the -Dvlcj.log= system property has not already been set.
|
||||
*/
|
||||
private static final String VLCJ_LOG_LEVEL = "INFO";
|
||||
|
||||
/**
|
||||
* Change this to point to your own vlc installation, or comment out the code if you want to use your system default installation.
|
||||
* <p>
|
||||
* This is a bit more explicit than using the -Djna.library.path= system property.
|
||||
*/
|
||||
private static final String NATIVE_LIBRARY_SEARCH_PATH = null;
|
||||
|
||||
/**
|
||||
* Set to true to dump out native JNA memory structures.
|
||||
*/
|
||||
private static final String DUMP_NATIVE_MEMORY = "false";
|
||||
|
||||
/**
|
||||
* Static initialisation.
|
||||
*/
|
||||
static {
|
||||
if (null == System.getProperty("vlcj.log")) {
|
||||
System.setProperty("vlcj.log", VLCJ_LOG_LEVEL);
|
||||
}
|
||||
|
||||
// Safely try to initialise LibX11 to reduce the opportunity for native
|
||||
// crashes - this will silently throw an Error on Windows (and maybe MacOS)
|
||||
// that can safely be ignored
|
||||
LibXUtil.initialise();
|
||||
|
||||
if (null != NATIVE_LIBRARY_SEARCH_PATH) {
|
||||
Logger.info("Explicitly adding JNA native library search path: '{}'", NATIVE_LIBRARY_SEARCH_PATH);
|
||||
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), NATIVE_LIBRARY_SEARCH_PATH);
|
||||
}
|
||||
|
||||
System.setProperty("jna.dump_memory", DUMP_NATIVE_MEMORY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the standard look and feel.
|
||||
*/
|
||||
protected static final void setLookAndFeel() {
|
||||
String lookAndFeelClassName = null;
|
||||
LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
|
||||
for (LookAndFeelInfo lookAndFeel : lookAndFeelInfos) {
|
||||
if ("Nimbus".equals(lookAndFeel.getName())) {
|
||||
lookAndFeelClassName = lookAndFeel.getClassName();
|
||||
}
|
||||
}
|
||||
if (lookAndFeelClassName == null) {
|
||||
lookAndFeelClassName = UIManager.getSystemLookAndFeelClassName();
|
||||
}
|
||||
try {
|
||||
UIManager.setLookAndFeel(lookAndFeelClassName);
|
||||
} catch (Exception e) {
|
||||
// Silently fail, it doesn't matter
|
||||
}
|
||||
}
|
||||
}
|
@ -1,479 +0,0 @@
|
||||
package org.jdownloader.extensions.vlcstreaming.test.basic;
|
||||
|
||||
/*
|
||||
* This file is part of VLCJ.
|
||||
*
|
||||
* VLCJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* VLCJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright 2009, 2010, 2011, 2012 Caprica Software Limited.
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import uk.co.caprica.vlcj.binding.LibVlcConst;
|
||||
import uk.co.caprica.vlcj.filter.swing.SwingFileFilterFactory;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter;
|
||||
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
|
||||
|
||||
public class PlayerControlsPanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final int SKIP_TIME_MS = 10 * 1000;
|
||||
|
||||
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
private final EmbeddedMediaPlayer mediaPlayer;
|
||||
|
||||
private JLabel timeLabel;
|
||||
// private JProgressBar positionProgressBar;
|
||||
private JSlider positionSlider;
|
||||
private JLabel chapterLabel;
|
||||
|
||||
private JButton previousChapterButton;
|
||||
private JButton rewindButton;
|
||||
private JButton stopButton;
|
||||
private JButton pauseButton;
|
||||
private JButton playButton;
|
||||
private JButton fastForwardButton;
|
||||
private JButton nextChapterButton;
|
||||
|
||||
private JButton toggleMuteButton;
|
||||
private JSlider volumeSlider;
|
||||
|
||||
private JButton captureButton;
|
||||
|
||||
private JButton ejectButton;
|
||||
private JButton connectButton;
|
||||
|
||||
private JButton fullScreenButton;
|
||||
|
||||
private JButton subTitlesButton;
|
||||
|
||||
private JFileChooser fileChooser;
|
||||
|
||||
private boolean mousePressedPlaying = false;
|
||||
|
||||
public PlayerControlsPanel(EmbeddedMediaPlayer mediaPlayer) {
|
||||
this.mediaPlayer = mediaPlayer;
|
||||
|
||||
createUI();
|
||||
|
||||
executorService.scheduleAtFixedRate(new UpdateRunnable(mediaPlayer), 0L, 1L, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void createUI() {
|
||||
createControls();
|
||||
layoutControls();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void createControls() {
|
||||
timeLabel = new JLabel("hh:mm:ss");
|
||||
|
||||
// positionProgressBar = new JProgressBar();
|
||||
// positionProgressBar.setMinimum(0);
|
||||
// positionProgressBar.setMaximum(1000);
|
||||
// positionProgressBar.setValue(0);
|
||||
// positionProgressBar.setText("Time");
|
||||
|
||||
positionSlider = new JSlider();
|
||||
positionSlider.setMinimum(0);
|
||||
positionSlider.setMaximum(1000);
|
||||
positionSlider.setValue(0);
|
||||
positionSlider.setToolTipText("Position");
|
||||
|
||||
chapterLabel = new JLabel("00/00");
|
||||
|
||||
previousChapterButton = new JButton();
|
||||
// previousChapterButton.setIcon(NewTheme.I().getIcon("control_start_blue", 24));
|
||||
previousChapterButton.setText("Go to previous chapter");
|
||||
|
||||
rewindButton = new JButton();
|
||||
// rewindButton.setIcon(NewTheme.I().getIcon("control_rewind_blue", 24));
|
||||
rewindButton.setText("Skip back");
|
||||
|
||||
stopButton = new JButton();
|
||||
// stopButton.setIcon(NewTheme.I().getIcon("control_stop_blue", 24));
|
||||
stopButton.setText("Stop");
|
||||
|
||||
pauseButton = new JButton();
|
||||
// pauseButton.setIcon(NewTheme.I().getIcon("control_pause_blue", 24));
|
||||
pauseButton.setText("Play/pause");
|
||||
|
||||
playButton = new JButton();
|
||||
// playButton.setIcon(NewTheme.I().getIcon("control_play_blue", 24));
|
||||
playButton.setText("Play");
|
||||
|
||||
fastForwardButton = new JButton();
|
||||
// fastForwardButton.setIcon(NewTheme.I().getIcon("control_fastforward_blue", 24));
|
||||
fastForwardButton.setText("Skip forward");
|
||||
|
||||
nextChapterButton = new JButton();
|
||||
// nextChapterButton.setIcon(NewTheme.I().getIcon("control_end_blue", 24));
|
||||
nextChapterButton.setText("Go to next chapter");
|
||||
|
||||
toggleMuteButton = new JButton();
|
||||
// toggleMuteButton.setIcon(NewTheme.I().getIcon("sound_mute", 24));
|
||||
toggleMuteButton.setText("Toggle Mute");
|
||||
|
||||
volumeSlider = new JSlider();
|
||||
volumeSlider.setOrientation(JSlider.HORIZONTAL);
|
||||
volumeSlider.setMinimum(LibVlcConst.MIN_VOLUME);
|
||||
volumeSlider.setMaximum(LibVlcConst.MAX_VOLUME);
|
||||
volumeSlider.setPreferredSize(new Dimension(100, 40));
|
||||
volumeSlider.setToolTipText("Change volume");
|
||||
|
||||
captureButton = new JButton();
|
||||
// captureButton.setIcon(NewTheme.I().getIcon("camera", 24));
|
||||
captureButton.setText("Take picture");
|
||||
|
||||
ejectButton = new JButton();
|
||||
// ejectButton.setIcon(NewTheme.I().getIcon("control_eject_blue", 24));
|
||||
ejectButton.setText("Load/eject media");
|
||||
|
||||
connectButton = new JButton("connect");
|
||||
// connectButton.setIcon(NewTheme.I().getIcon("connect", 24));
|
||||
connectButton.setText("Connect to media");
|
||||
|
||||
fileChooser = new JFileChooser();
|
||||
fileChooser.setApproveButtonText("Play");
|
||||
fileChooser.addChoosableFileFilter(SwingFileFilterFactory.newVideoFileFilter());
|
||||
fileChooser.addChoosableFileFilter(SwingFileFilterFactory.newAudioFileFilter());
|
||||
fileChooser.addChoosableFileFilter(SwingFileFilterFactory.newPlayListFileFilter());
|
||||
FileFilter defaultFilter = SwingFileFilterFactory.newMediaFileFilter();
|
||||
fileChooser.addChoosableFileFilter(defaultFilter);
|
||||
fileChooser.setFileFilter(defaultFilter);
|
||||
|
||||
fullScreenButton = new JButton();
|
||||
// fullScreenButton.setIcon(NewTheme.I().getIcon("image", 24));
|
||||
fullScreenButton.setText("Toggle full-screen");
|
||||
|
||||
subTitlesButton = new JButton();
|
||||
// subTitlesButton.setIcon(NewTheme.I().getIcon("comment", 24));
|
||||
subTitlesButton.setText("Cycle sub-titles");
|
||||
}
|
||||
|
||||
private void layoutControls() {
|
||||
setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
JPanel positionPanel = new JPanel();
|
||||
positionPanel.setLayout(new GridLayout(1, 1));
|
||||
// positionPanel.add(positionProgressBar);
|
||||
positionPanel.add(positionSlider);
|
||||
|
||||
JPanel topPanel = new JPanel();
|
||||
topPanel.setLayout(new BorderLayout(8, 0));
|
||||
|
||||
topPanel.add(timeLabel, BorderLayout.WEST);
|
||||
topPanel.add(positionPanel, BorderLayout.CENTER);
|
||||
topPanel.add(chapterLabel, BorderLayout.EAST);
|
||||
|
||||
add(topPanel, BorderLayout.NORTH);
|
||||
|
||||
JPanel bottomPanel = new JPanel();
|
||||
|
||||
bottomPanel.setLayout(new FlowLayout());
|
||||
|
||||
bottomPanel.add(previousChapterButton);
|
||||
bottomPanel.add(rewindButton);
|
||||
bottomPanel.add(stopButton);
|
||||
bottomPanel.add(pauseButton);
|
||||
bottomPanel.add(playButton);
|
||||
bottomPanel.add(fastForwardButton);
|
||||
bottomPanel.add(nextChapterButton);
|
||||
|
||||
bottomPanel.add(volumeSlider);
|
||||
bottomPanel.add(toggleMuteButton);
|
||||
|
||||
bottomPanel.add(captureButton);
|
||||
|
||||
bottomPanel.add(ejectButton);
|
||||
bottomPanel.add(connectButton);
|
||||
|
||||
bottomPanel.add(fullScreenButton);
|
||||
|
||||
bottomPanel.add(subTitlesButton);
|
||||
|
||||
add(bottomPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broken out position setting, handles updating mediaPlayer
|
||||
*/
|
||||
private void setSliderBasedPosition() {
|
||||
if (!mediaPlayer.isSeekable()) { return; }
|
||||
float positionValue = (float) positionSlider.getValue() / 1000.0f;
|
||||
// Avoid end of file freeze-up
|
||||
if (positionValue > 0.99f) {
|
||||
positionValue = 0.99f;
|
||||
}
|
||||
mediaPlayer.setPosition(positionValue);
|
||||
}
|
||||
|
||||
private void updateUIState() {
|
||||
if (!mediaPlayer.isPlaying()) {
|
||||
// Resume play or play a few frames then pause to show current position in video
|
||||
mediaPlayer.play();
|
||||
if (!mousePressedPlaying) {
|
||||
try {
|
||||
// Half a second probably gets an iframe
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
// Don't care if unblocked early
|
||||
}
|
||||
mediaPlayer.pause();
|
||||
}
|
||||
}
|
||||
long time = mediaPlayer.getTime();
|
||||
int position = (int) (mediaPlayer.getPosition() * 1000.0f);
|
||||
int chapter = mediaPlayer.getChapter();
|
||||
int chapterCount = mediaPlayer.getChapterCount();
|
||||
updateTime(time);
|
||||
updatePosition(position);
|
||||
updateChapter(chapter, chapterCount);
|
||||
}
|
||||
|
||||
private void skip(int skipTime) {
|
||||
// Only skip time if can handle time setting
|
||||
if (mediaPlayer.getLength() > 0) {
|
||||
mediaPlayer.skip(skipTime);
|
||||
updateUIState();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
|
||||
@Override
|
||||
public void playing(MediaPlayer mediaPlayer) {
|
||||
updateVolume(mediaPlayer.getVolume());
|
||||
}
|
||||
});
|
||||
|
||||
positionSlider.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (mediaPlayer.isPlaying()) {
|
||||
mousePressedPlaying = true;
|
||||
mediaPlayer.pause();
|
||||
} else {
|
||||
mousePressedPlaying = false;
|
||||
}
|
||||
setSliderBasedPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
setSliderBasedPosition();
|
||||
updateUIState();
|
||||
}
|
||||
});
|
||||
|
||||
previousChapterButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.previousChapter();
|
||||
}
|
||||
});
|
||||
|
||||
rewindButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
skip(-SKIP_TIME_MS);
|
||||
}
|
||||
});
|
||||
|
||||
stopButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.stop();
|
||||
}
|
||||
});
|
||||
|
||||
pauseButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.pause();
|
||||
}
|
||||
});
|
||||
|
||||
playButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.play();
|
||||
}
|
||||
});
|
||||
|
||||
fastForwardButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
skip(SKIP_TIME_MS);
|
||||
}
|
||||
});
|
||||
|
||||
nextChapterButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.nextChapter();
|
||||
}
|
||||
});
|
||||
|
||||
toggleMuteButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.mute();
|
||||
}
|
||||
});
|
||||
|
||||
volumeSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
// if(!source.getValueIsAdjusting()) {
|
||||
mediaPlayer.setVolume(source.getValue());
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
captureButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.saveSnapshot();
|
||||
}
|
||||
});
|
||||
|
||||
ejectButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.enableOverlay(false);
|
||||
if (JFileChooser.APPROVE_OPTION == fileChooser.showOpenDialog(PlayerControlsPanel.this)) {
|
||||
mediaPlayer.playMedia(fileChooser.getSelectedFile().getAbsolutePath());
|
||||
}
|
||||
mediaPlayer.enableOverlay(true);
|
||||
}
|
||||
});
|
||||
|
||||
connectButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.enableOverlay(false);
|
||||
String mediaUrl = (String) JOptionPane.showInputDialog(PlayerControlsPanel.this, "Enter a media URL", "Connect to media", JOptionPane.QUESTION_MESSAGE);
|
||||
if (mediaUrl != null && mediaUrl.length() > 0) {
|
||||
mediaPlayer.playMedia(mediaUrl);
|
||||
}
|
||||
mediaPlayer.enableOverlay(true);
|
||||
}
|
||||
});
|
||||
|
||||
fullScreenButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.toggleFullScreen();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
subTitlesButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int spu = mediaPlayer.getSpu();
|
||||
if (spu > -1) {
|
||||
spu++;
|
||||
if (spu > mediaPlayer.getSpuCount()) {
|
||||
spu = -1;
|
||||
}
|
||||
} else {
|
||||
spu = 0;
|
||||
}
|
||||
mediaPlayer.setSpu(spu);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private final class UpdateRunnable implements Runnable {
|
||||
|
||||
private final MediaPlayer mediaPlayer;
|
||||
|
||||
private UpdateRunnable(MediaPlayer mediaPlayer) {
|
||||
this.mediaPlayer = mediaPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final long time = mediaPlayer.getTime();
|
||||
final int position = (int) (mediaPlayer.getPosition() * 1000.0f);
|
||||
final int chapter = mediaPlayer.getChapter();
|
||||
final int chapterCount = mediaPlayer.getChapterCount();
|
||||
|
||||
// Updates to user interface components must be executed on the Event
|
||||
// Dispatch Thread
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mediaPlayer.isPlaying()) {
|
||||
updateTime(time);
|
||||
updatePosition(position);
|
||||
updateChapter(chapter, chapterCount);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTime(long millis) {
|
||||
String s = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis), TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
|
||||
timeLabel.setText(s);
|
||||
}
|
||||
|
||||
private void updatePosition(int value) {
|
||||
// positionProgressBar.setValue(value);
|
||||
positionSlider.setValue(value);
|
||||
}
|
||||
|
||||
private void updateChapter(int chapter, int chapterCount) {
|
||||
String s = chapterCount != -1 ? (chapter + 1) + "/" + chapterCount : "-";
|
||||
chapterLabel.setText(s);
|
||||
chapterLabel.invalidate();
|
||||
validate();
|
||||
}
|
||||
|
||||
private void updateVolume(int value) {
|
||||
volumeSlider.setValue(value);
|
||||
}
|
||||
}
|
@ -1,217 +0,0 @@
|
||||
package org.jdownloader.extensions.vlcstreaming.test.basic;
|
||||
|
||||
/*
|
||||
* This file is part of VLCJ.
|
||||
*
|
||||
* VLCJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* VLCJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright 2009, 2010, 2011, 2012 Caprica Software Limited.
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import uk.co.caprica.vlcj.binding.LibVlcConst;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
|
||||
public class PlayerVideoAdjustPanel extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final MediaPlayer mediaPlayer;
|
||||
|
||||
private JCheckBox enableVideoAdjustCheckBox;
|
||||
|
||||
private JLabel contrastLabel;
|
||||
private JSlider contrastSlider;
|
||||
|
||||
private JLabel brightnessLabel;
|
||||
private JSlider brightnessSlider;
|
||||
|
||||
private JLabel hueLabel;
|
||||
private JSlider hueSlider;
|
||||
|
||||
private JLabel saturationLabel;
|
||||
private JSlider saturationSlider;
|
||||
|
||||
private JLabel gammaLabel;
|
||||
private JSlider gammaSlider;
|
||||
|
||||
public PlayerVideoAdjustPanel(MediaPlayer mediaPlayer) {
|
||||
this.mediaPlayer = mediaPlayer;
|
||||
|
||||
createUI();
|
||||
}
|
||||
|
||||
private void createUI() {
|
||||
createControls();
|
||||
layoutControls();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void createControls() {
|
||||
enableVideoAdjustCheckBox = new JCheckBox("Video Adjust");
|
||||
|
||||
contrastLabel = new JLabel("Contrast");
|
||||
contrastSlider = new JSlider();
|
||||
contrastSlider.setOrientation(JSlider.HORIZONTAL);
|
||||
contrastSlider.setMinimum(Math.round(LibVlcConst.MIN_CONTRAST * 100.0f));
|
||||
contrastSlider.setMaximum(Math.round(LibVlcConst.MAX_CONTRAST * 100.0f));
|
||||
contrastSlider.setPreferredSize(new Dimension(100, 40));
|
||||
contrastSlider.setToolTipText("Change Contrast");
|
||||
contrastSlider.setEnabled(false);
|
||||
contrastSlider.setPaintLabels(true);
|
||||
contrastSlider.setPaintTicks(true);
|
||||
|
||||
brightnessLabel = new JLabel("Brightness");
|
||||
brightnessSlider = new JSlider();
|
||||
brightnessSlider.setOrientation(JSlider.HORIZONTAL);
|
||||
brightnessSlider.setMinimum(Math.round(LibVlcConst.MIN_BRIGHTNESS * 100.0f));
|
||||
brightnessSlider.setMaximum(Math.round(LibVlcConst.MAX_BRIGHTNESS * 100.0f));
|
||||
brightnessSlider.setPreferredSize(new Dimension(100, 40));
|
||||
brightnessSlider.setToolTipText("Change Brightness");
|
||||
brightnessSlider.setEnabled(false);
|
||||
|
||||
hueLabel = new JLabel("Hue");
|
||||
hueSlider = new JSlider();
|
||||
hueSlider.setOrientation(JSlider.HORIZONTAL);
|
||||
hueSlider.setMinimum(LibVlcConst.MIN_HUE);
|
||||
hueSlider.setMaximum(LibVlcConst.MAX_HUE);
|
||||
hueSlider.setPreferredSize(new Dimension(100, 40));
|
||||
hueSlider.setToolTipText("Change ");
|
||||
hueSlider.setEnabled(false);
|
||||
|
||||
saturationLabel = new JLabel("Saturation");
|
||||
saturationSlider = new JSlider();
|
||||
saturationSlider.setOrientation(JSlider.HORIZONTAL);
|
||||
saturationSlider.setMinimum(Math.round(LibVlcConst.MIN_SATURATION * 100.0f));
|
||||
saturationSlider.setMaximum(Math.round(LibVlcConst.MAX_SATURATION * 100.0f));
|
||||
saturationSlider.setPreferredSize(new Dimension(100, 40));
|
||||
saturationSlider.setToolTipText("Change ");
|
||||
saturationSlider.setEnabled(false);
|
||||
|
||||
gammaLabel = new JLabel("Gamma");
|
||||
gammaSlider = new JSlider();
|
||||
gammaSlider.setOrientation(JSlider.HORIZONTAL);
|
||||
gammaSlider.setMinimum(Math.round(LibVlcConst.MIN_GAMMA * 100.0f));
|
||||
gammaSlider.setMaximum(Math.round(LibVlcConst.MAX_GAMMA * 100.0f));
|
||||
gammaSlider.setPreferredSize(new Dimension(100, 40));
|
||||
gammaSlider.setToolTipText("Change ");
|
||||
gammaSlider.setEnabled(false);
|
||||
|
||||
contrastSlider.setValue(Math.round(mediaPlayer.getBrightness() * 100.0f));
|
||||
brightnessSlider.setValue(Math.round(mediaPlayer.getContrast() * 100.0f));
|
||||
hueSlider.setValue(mediaPlayer.getHue());
|
||||
saturationSlider.setValue(Math.round(mediaPlayer.getSaturation() * 100.0f));
|
||||
gammaSlider.setValue(Math.round(mediaPlayer.getGamma() * 100.0f));
|
||||
}
|
||||
|
||||
private void layoutControls() {
|
||||
setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
JPanel slidersPanel = new JPanel();
|
||||
slidersPanel.setLayout(new BoxLayout(slidersPanel, BoxLayout.Y_AXIS));
|
||||
slidersPanel.add(enableVideoAdjustCheckBox);
|
||||
slidersPanel.add(contrastLabel);
|
||||
slidersPanel.add(contrastSlider);
|
||||
slidersPanel.add(brightnessLabel);
|
||||
slidersPanel.add(brightnessSlider);
|
||||
slidersPanel.add(hueLabel);
|
||||
slidersPanel.add(hueSlider);
|
||||
slidersPanel.add(saturationLabel);
|
||||
slidersPanel.add(saturationSlider);
|
||||
slidersPanel.add(gammaLabel);
|
||||
slidersPanel.add(gammaSlider);
|
||||
|
||||
add(slidersPanel, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
enableVideoAdjustCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean enabled = enableVideoAdjustCheckBox.isSelected();
|
||||
contrastSlider.setEnabled(enabled);
|
||||
brightnessSlider.setEnabled(enabled);
|
||||
hueSlider.setEnabled(enabled);
|
||||
saturationSlider.setEnabled(enabled);
|
||||
gammaSlider.setEnabled(enabled);
|
||||
mediaPlayer.setAdjustVideo(enabled);
|
||||
}
|
||||
});
|
||||
|
||||
contrastSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
// if(!source.getValueIsAdjusting()) {
|
||||
mediaPlayer.setContrast(source.getValue() / 100.0f);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
brightnessSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
// if(!source.getValueIsAdjusting()) {
|
||||
mediaPlayer.setBrightness(source.getValue() / 100.0f);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
hueSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
// if(!source.getValueIsAdjusting()) {
|
||||
mediaPlayer.setHue(source.getValue());
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
saturationSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
// if(!source.getValueIsAdjusting()) {
|
||||
mediaPlayer.setSaturation(source.getValue() / 100.0f);
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
gammaSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JSlider source = (JSlider) e.getSource();
|
||||
// if(!source.getValueIsAdjusting()) {
|
||||
mediaPlayer.setGamma(source.getValue() / 100.0f);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,606 +0,0 @@
|
||||
package org.jdownloader.extensions.vlcstreaming.test.basic;
|
||||
|
||||
/*
|
||||
* This file is part of VLCJ.
|
||||
*
|
||||
* VLCJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* VLCJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with VLCJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright 2009, 2010, 2011, 2012 Caprica Software Limited.
|
||||
*/
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import jd.gui.swing.laf.LookAndFeelController;
|
||||
|
||||
import org.jdownloader.extensions.vlcstreaming.test.VlcjTest;
|
||||
|
||||
import uk.co.caprica.vlcj.binding.LibVlc;
|
||||
import uk.co.caprica.vlcj.binding.LibVlcFactory;
|
||||
import uk.co.caprica.vlcj.binding.internal.libvlc_media_t;
|
||||
import uk.co.caprica.vlcj.logger.Logger;
|
||||
import uk.co.caprica.vlcj.player.AudioOutput;
|
||||
import uk.co.caprica.vlcj.player.MediaDetails;
|
||||
import uk.co.caprica.vlcj.player.MediaMeta;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
|
||||
import uk.co.caprica.vlcj.player.embedded.DefaultFullScreenStrategy;
|
||||
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
|
||||
import uk.co.caprica.vlcj.player.embedded.FullScreenStrategy;
|
||||
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
|
||||
import uk.co.caprica.vlcj.runtime.windows.WindowsCanvas;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLibrary;
|
||||
|
||||
/**
|
||||
* Simple test harness creates an AWT Window and plays a video.
|
||||
* <p>
|
||||
* This is <strong>very</strong> basic but should give you an idea of how to build a media player.
|
||||
* <p>
|
||||
* In case you didn't realise, you can press F12 to toggle the visibility of the player controls.
|
||||
* <p>
|
||||
* Java7 provides -Dsun.java2d.xrender=True or -Dsun.java2d.xrender=true, might give some general performance improvements in graphics
|
||||
* rendering.
|
||||
*/
|
||||
public class TestPlayer extends VlcjTest {
|
||||
|
||||
private JFrame mainFrame;
|
||||
private Canvas videoSurface;
|
||||
private JPanel controlsPanel;
|
||||
private JPanel videoAdjustPanel;
|
||||
|
||||
private MediaPlayerFactory mediaPlayerFactory;
|
||||
|
||||
private EmbeddedMediaPlayer mediaPlayer;
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
|
||||
try {
|
||||
System.out.println(RuntimeUtil.getLibVlcLibraryName());
|
||||
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Users\\Thomas\\Downloads\\vlc-2.0.2-win64\\vlc-2.0.2");
|
||||
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LibVlc libVlc = LibVlcFactory.factory().create();
|
||||
|
||||
Logger.info(" version: {}", libVlc.libvlc_get_version());
|
||||
Logger.info(" compiler: {}", libVlc.libvlc_get_compiler());
|
||||
Logger.info("changeset: {}", libVlc.libvlc_get_changeset());
|
||||
|
||||
setLookAndFeel();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LookAndFeelController.getInstance().setUIManager();
|
||||
new TestPlayer(args);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public TestPlayer(String[] args) {
|
||||
if (RuntimeUtil.isWindows() && false) {
|
||||
// If running on Windows and you want the mouse/keyboard event hack...
|
||||
videoSurface = new WindowsCanvas();
|
||||
} else {
|
||||
videoSurface = new Canvas();
|
||||
}
|
||||
|
||||
Logger.debug("videoSurface={}", videoSurface);
|
||||
|
||||
videoSurface.setBackground(Color.black);
|
||||
videoSurface.setSize(800, 600); // Only for initial layout
|
||||
|
||||
// Since we're mixing lightweight Swing components and heavyweight AWT
|
||||
// components this is probably a good idea
|
||||
// JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||
|
||||
TestPlayerMouseListener mouseListener = new TestPlayerMouseListener();
|
||||
videoSurface.addMouseListener(mouseListener);
|
||||
videoSurface.addMouseMotionListener(mouseListener);
|
||||
videoSurface.addMouseWheelListener(mouseListener);
|
||||
videoSurface.addKeyListener(new TestPlayerKeyListener());
|
||||
|
||||
List<String> vlcArgs = new ArrayList<String>();
|
||||
|
||||
// vlcArgs.add("--ffmpeg-hw"); // <--- if your system supports it, this might be useful
|
||||
vlcArgs.add("--no-plugins-cache");
|
||||
vlcArgs.add("--no-video-title-show");
|
||||
vlcArgs.add("--no-snapshot-preview");
|
||||
vlcArgs.add("--quiet");
|
||||
vlcArgs.add("--quiet-synchro");
|
||||
vlcArgs.add("--intf");
|
||||
vlcArgs.add("dummy");
|
||||
|
||||
// Special case to help out users on Windows (supposedly this is not actually needed)...
|
||||
// if(RuntimeUtil.isWindows()) {
|
||||
// vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins");
|
||||
// }
|
||||
// else {
|
||||
// vlcArgs.add("--plugin-path=/home/linux/vlc/lib");
|
||||
// }
|
||||
|
||||
// vlcArgs.add("--plugin-path=" + System.getProperty("user.home") + "/.vlcj");
|
||||
|
||||
Logger.debug("vlcArgs={}", vlcArgs);
|
||||
|
||||
mainFrame = new JFrame("VLCJ Test Player");
|
||||
// mainFrame.setIconImage(new ImageIcon(getClass().getResource("/icons/vlcj-logo.png")).getImage());
|
||||
|
||||
FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame);
|
||||
fullScreenStrategy = new FullScreenStrategy() {
|
||||
|
||||
@Override
|
||||
public void enterFullScreenMode() {
|
||||
mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
// mediaPlayer.setFullScreen(true);
|
||||
mainFrame.setUndecorated(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitFullScreenMode() {
|
||||
mainFrame.setExtendedState(JFrame.NORMAL);
|
||||
// mediaPlayer.setFullScreen(true);
|
||||
mainFrame.setUndecorated(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullScreenMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
mediaPlayerFactory = new MediaPlayerFactory(vlcArgs.toArray(new String[vlcArgs.size()]));
|
||||
mediaPlayerFactory.setUserAgent("vlcj test player");
|
||||
|
||||
List<AudioOutput> audioOutputs = mediaPlayerFactory.getAudioOutputs();
|
||||
Logger.debug("audioOutputs={}", audioOutputs);
|
||||
|
||||
mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy);
|
||||
mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(videoSurface));
|
||||
mediaPlayer.setPlaySubItems(true);
|
||||
|
||||
// mediaPlayer.setEnableKeyInputHandling(false);
|
||||
// mediaPlayer.setEnableMouseInputHandling(false);
|
||||
|
||||
controlsPanel = new PlayerControlsPanel(mediaPlayer);
|
||||
videoAdjustPanel = new PlayerVideoAdjustPanel(mediaPlayer);
|
||||
|
||||
mainFrame.setLayout(new BorderLayout());
|
||||
mainFrame.setBackground(Color.black);
|
||||
mainFrame.add(videoSurface, BorderLayout.CENTER);
|
||||
mainFrame.add(controlsPanel, BorderLayout.SOUTH);
|
||||
mainFrame.add(videoAdjustPanel, BorderLayout.EAST);
|
||||
mainFrame.setJMenuBar(buildMenuBar());
|
||||
mainFrame.pack();
|
||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
mainFrame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent evt) {
|
||||
Logger.debug("windowClosing(evt={})", evt);
|
||||
|
||||
if (videoSurface instanceof WindowsCanvas) {
|
||||
((WindowsCanvas) videoSurface).release();
|
||||
}
|
||||
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.release();
|
||||
mediaPlayer = null;
|
||||
}
|
||||
|
||||
if (mediaPlayerFactory != null) {
|
||||
mediaPlayerFactory.release();
|
||||
mediaPlayerFactory = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Global AWT key handler, you're better off using Swing's InputMap and
|
||||
// ActionMap with a JFrame - that would solve all sorts of focus issues too
|
||||
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
|
||||
@Override
|
||||
public void eventDispatched(AWTEvent event) {
|
||||
if (event instanceof KeyEvent) {
|
||||
KeyEvent keyEvent = (KeyEvent) event;
|
||||
if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
|
||||
if (keyEvent.getKeyCode() == KeyEvent.VK_F12) {
|
||||
controlsPanel.setVisible(!controlsPanel.isVisible());
|
||||
videoAdjustPanel.setVisible(!videoAdjustPanel.isVisible());
|
||||
mainFrame.getJMenuBar().setVisible(!mainFrame.getJMenuBar().isVisible());
|
||||
mainFrame.invalidate();
|
||||
mainFrame.validate();
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_A) {
|
||||
mediaPlayer.setAudioDelay(mediaPlayer.getAudioDelay() - 50000);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_S) {
|
||||
mediaPlayer.setAudioDelay(mediaPlayer.getAudioDelay() + 50000);
|
||||
}
|
||||
// else if(keyEvent.getKeyCode() == KeyEvent.VK_N) {
|
||||
// mediaPlayer.nextFrame();
|
||||
// }
|
||||
else if (keyEvent.getKeyCode() == KeyEvent.VK_1) {
|
||||
mediaPlayer.setTime(60000 * 1);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_2) {
|
||||
mediaPlayer.setTime(60000 * 2);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_3) {
|
||||
mediaPlayer.setTime(60000 * 3);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_4) {
|
||||
mediaPlayer.setTime(60000 * 4);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_5) {
|
||||
mediaPlayer.setTime(60000 * 5);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_6) {
|
||||
mediaPlayer.setTime(60000 * 6);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_7) {
|
||||
mediaPlayer.setTime(60000 * 7);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_8) {
|
||||
mediaPlayer.setTime(60000 * 8);
|
||||
} else if (keyEvent.getKeyCode() == KeyEvent.VK_9) {
|
||||
mediaPlayer.setTime(60000 * 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, AWTEvent.KEY_EVENT_MASK);
|
||||
|
||||
mainFrame.setVisible(true);
|
||||
|
||||
mediaPlayer.addMediaPlayerEventListener(new TestPlayerMediaPlayerEventListener());
|
||||
|
||||
// Won't work with OpenJDK or JDK1.7, requires a Sun/Oracle JVM (currently)
|
||||
// boolean transparentWindowsSupport = true;
|
||||
// try {
|
||||
// Class.forName("com.sun.awt.AWTUtilities");
|
||||
// } catch (Exception e) {
|
||||
// transparentWindowsSupport = false;
|
||||
// }
|
||||
//
|
||||
// Logger.debug("transparentWindowsSupport={}", transparentWindowsSupport);
|
||||
//
|
||||
// if (transparentWindowsSupport) {
|
||||
// final Window test = new Window(null, WindowUtils.getAlphaCompatibleGraphicsConfiguration()) {
|
||||
// private static final long serialVersionUID = 1L;
|
||||
//
|
||||
// public void paint(Graphics g) {
|
||||
// Graphics2D g2 = (Graphics2D) g;
|
||||
//
|
||||
// g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
// g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
|
||||
//
|
||||
// g.setColor(Color.white);
|
||||
// g.fillRoundRect(100, 150, 100, 100, 32, 32);
|
||||
//
|
||||
// g.setFont(new Font("Sans", Font.BOLD, 32));
|
||||
// g.drawString("Heavyweight overlay test", 100, 300);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// AWTUtilities.setWindowOpaque(test, false); // Doesn't work in full-screen exclusive
|
||||
// // mode, you would have to use 'simulated'
|
||||
// // full-screen - requires Sun/Oracle JDK
|
||||
// test.setBackground(new Color(0, 0, 0, 0)); // This is what you do in JDK7
|
||||
//
|
||||
// // mediaPlayer.setOverlay(test);
|
||||
// // mediaPlayer.enableOverlay(true);
|
||||
// }
|
||||
|
||||
// This might be useful
|
||||
// enableMousePointer(false);
|
||||
}
|
||||
|
||||
private JMenuBar buildMenuBar() {
|
||||
// Menus are just added as an example of overlapping the video - they are
|
||||
// non-functional in this demo player
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
|
||||
JMenu mediaMenu = new JMenu("Media");
|
||||
mediaMenu.setMnemonic('m');
|
||||
|
||||
JMenuItem mediaPlayFileMenuItem = new JMenuItem("Play File...");
|
||||
mediaPlayFileMenuItem.setMnemonic('f');
|
||||
mediaMenu.add(mediaPlayFileMenuItem);
|
||||
mediaPlayFileMenuItem.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mediaPlayer.playMedia("http://www.youtube.com/watch?v=8s9MDe8JvSo");
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem mediaPlayStreamMenuItem = new JMenuItem("Play Stream...");
|
||||
mediaPlayFileMenuItem.setMnemonic('s');
|
||||
mediaMenu.add(mediaPlayStreamMenuItem);
|
||||
|
||||
mediaMenu.add(new JSeparator());
|
||||
|
||||
JMenuItem mediaExitMenuItem = new JMenuItem("Exit");
|
||||
mediaExitMenuItem.setMnemonic('x');
|
||||
mediaMenu.add(mediaExitMenuItem);
|
||||
|
||||
menuBar.add(mediaMenu);
|
||||
|
||||
JMenu playbackMenu = new JMenu("Playback");
|
||||
playbackMenu.setMnemonic('p');
|
||||
|
||||
JMenu playbackChapterMenu = new JMenu("Chapter");
|
||||
playbackChapterMenu.setMnemonic('c');
|
||||
for (int i = 1; i <= 25; i++) {
|
||||
JMenuItem chapterMenuItem = new JMenuItem("Chapter " + i);
|
||||
playbackChapterMenu.add(chapterMenuItem);
|
||||
}
|
||||
playbackMenu.add(playbackChapterMenu);
|
||||
|
||||
JMenu subtitlesMenu = new JMenu("Subtitles");
|
||||
playbackChapterMenu.setMnemonic('s');
|
||||
String[] subs = { "01 English (en)", "02 English Commentary (en)", "03 French (fr)", "04 Spanish (es)", "05 German (de)", "06 Italian (it)" };
|
||||
for (int i = 0; i < subs.length; i++) {
|
||||
JMenuItem subtitlesMenuItem = new JMenuItem(subs[i]);
|
||||
subtitlesMenu.add(subtitlesMenuItem);
|
||||
}
|
||||
playbackMenu.add(subtitlesMenu);
|
||||
|
||||
menuBar.add(playbackMenu);
|
||||
|
||||
JMenu toolsMenu = new JMenu("Tools");
|
||||
toolsMenu.setMnemonic('t');
|
||||
|
||||
JMenuItem toolsPreferencesMenuItem = new JMenuItem("Preferences...");
|
||||
toolsPreferencesMenuItem.setMnemonic('p');
|
||||
toolsMenu.add(toolsPreferencesMenuItem);
|
||||
|
||||
menuBar.add(toolsMenu);
|
||||
|
||||
JMenu helpMenu = new JMenu("Help");
|
||||
helpMenu.setMnemonic('h');
|
||||
|
||||
JMenuItem helpAboutMenuItem = new JMenuItem("About...");
|
||||
helpAboutMenuItem.setMnemonic('a');
|
||||
helpMenu.add(helpAboutMenuItem);
|
||||
|
||||
menuBar.add(helpMenu);
|
||||
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
private final class TestPlayerMediaPlayerEventListener extends MediaPlayerEventAdapter {
|
||||
@Override
|
||||
public void mediaChanged(MediaPlayer mediaPlayer, libvlc_media_t media, String mrl) {
|
||||
Logger.debug("mediaChanged(mediaPlayer={},media={},mrl={})", mediaPlayer, media, mrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finished(MediaPlayer mediaPlayer) {
|
||||
Logger.debug("finished(mediaPlayer={})", mediaPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paused(MediaPlayer mediaPlayer) {
|
||||
Logger.debug("paused(mediaPlayer={})", mediaPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playing(MediaPlayer mediaPlayer) {
|
||||
Logger.debug("playing(mediaPlayer={})", mediaPlayer);
|
||||
MediaDetails mediaDetails = mediaPlayer.getMediaDetails();
|
||||
Logger.info("mediaDetails={}", mediaDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopped(MediaPlayer mediaPlayer) {
|
||||
Logger.debug("stopped(mediaPlayer={})", mediaPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void videoOutput(MediaPlayer mediaPlayer, int newCount) {
|
||||
Logger.debug("videoOutput(mediaPlayer={},newCount={})", mediaPlayer, newCount);
|
||||
if (newCount == 0) { return; }
|
||||
|
||||
MediaDetails mediaDetails = mediaPlayer.getMediaDetails();
|
||||
Logger.info("mediaDetails={}", mediaDetails);
|
||||
|
||||
MediaMeta mediaMeta = mediaPlayer.getMediaMeta();
|
||||
Logger.info("mediaMeta={}", mediaMeta);
|
||||
|
||||
final Dimension dimension = mediaPlayer.getVideoDimension();
|
||||
Logger.debug("dimension={}", dimension);
|
||||
if (dimension != null) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
videoSurface.setSize(dimension);
|
||||
mainFrame.pack();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// You can set a logo like this if you like...
|
||||
File logoFile = new File("./etc/vlcj-logo.png");
|
||||
if (logoFile.exists()) {
|
||||
mediaPlayer.setLogoFile(logoFile.getAbsolutePath());
|
||||
mediaPlayer.setLogoOpacity(0.5f);
|
||||
mediaPlayer.setLogoLocation(10, 10);
|
||||
mediaPlayer.enableLogo(true);
|
||||
}
|
||||
|
||||
// Demo the marquee
|
||||
mediaPlayer.setMarqueeText("vlcj java bindings for vlc");
|
||||
mediaPlayer.setMarqueeSize(40);
|
||||
mediaPlayer.setMarqueeOpacity(95);
|
||||
mediaPlayer.setMarqueeColour(Color.white);
|
||||
mediaPlayer.setMarqueeTimeout(5000);
|
||||
mediaPlayer.setMarqueeLocation(50, 120);
|
||||
mediaPlayer.enableMarquee(true);
|
||||
|
||||
// Not quite sure how crop geometry is supposed to work...
|
||||
//
|
||||
// Assertions in libvlc code:
|
||||
//
|
||||
// top + height must be less than visible height
|
||||
// left + width must be less than visible width
|
||||
//
|
||||
// With DVD source material:
|
||||
//
|
||||
// Reported size is 1024x576 - this is what libvlc reports when you call
|
||||
// get video size
|
||||
//
|
||||
// mpeg size is 720x576 - this is what is reported in the native log
|
||||
//
|
||||
// The crop geometry relates to the mpeg size, not the size reported
|
||||
// through the API
|
||||
//
|
||||
// For 720x576, attempting to set geometry to anything bigger than
|
||||
// 719x575 results in the assertion failures above (seems like it should
|
||||
// allow 720x576) to me
|
||||
|
||||
// mediaPlayer.setCropGeometry("4:3");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(MediaPlayer mediaPlayer) {
|
||||
Logger.debug("error(mediaPlayer={})", mediaPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaSubItemAdded(MediaPlayer mediaPlayer, libvlc_media_t subItem) {
|
||||
Logger.debug("mediaSubItemAdded(mediaPlayer={},subItem={})", mediaPlayer, subItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaDurationChanged(MediaPlayer mediaPlayer, long newDuration) {
|
||||
Logger.debug("mediaDurationChanged(mediaPlayer={},newDuration={})", mediaPlayer, newDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaParsedChanged(MediaPlayer mediaPlayer, int newStatus) {
|
||||
Logger.debug("mediaParsedChanged(mediaPlayer={},newStatus={})", mediaPlayer, newStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaFreed(MediaPlayer mediaPlayer) {
|
||||
Logger.debug("mediaFreed(mediaPlayer={})", mediaPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaStateChanged(MediaPlayer mediaPlayer, int newState) {
|
||||
Logger.debug("mediaStateChanged(mediaPlayer={},newState={})", mediaPlayer, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mediaMetaChanged(MediaPlayer mediaPlayer, int metaType) {
|
||||
Logger.debug("mediaMetaChanged(mediaPlayer={},metaType={})", mediaPlayer, metaType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param enable
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void enableMousePointer(boolean enable) {
|
||||
Logger.debug("enableMousePointer(enable={})", enable);
|
||||
if (enable) {
|
||||
videoSurface.setCursor(null);
|
||||
} else {
|
||||
Image blankImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
videoSurface.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(blankImage, new Point(0, 0), ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final class TestPlayerMouseListener extends MouseAdapter {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Logger.trace("mouseMoved(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Logger.debug("mousePressed(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
Logger.debug("mouseReleased(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
Logger.debug("mouseWheelMoved(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
Logger.debug("mouseEntered(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
Logger.debug("mouseExited(e={})", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final class TestPlayerKeyListener extends KeyAdapter {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
Logger.debug("keyPressed(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
Logger.debug("keyReleased(e={})", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
Logger.debug("keyTyped(e={})", e);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Loading…
x
Reference in New Issue
Block a user