Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA**********Write a Java program that plays a video clip of a concert or opera

ID: 3835958 • Letter: J

Question

JAVA**********Write a Java program that plays a video clip of a concert or opera performance.

Requirements:

Upon running the program a theater curtain is displayed

When the user clicks on the curtain, the curtain opens and a video clip of the concert/opera performance (complete with sound) begins.

It is acceptable to have a working console with a start, pause and stop button displayed at the bottom of the video clip, after the curtain opens.

You may need the following to complete the answer to this question:

https://www.youtube.com/watch?v=Vf42IP__ipw

Explanation / Answer

Hi ,

To run this you need following jar's

DJNativeSwing.jar
DJNativeSwing-SWT.jar
swt-4.3-win32-win32-x86.jar (This one is platform dependent)

You can fid this jars fromdj native swing download package.

The code is using swing jpanel to run the video.

package mediaplayer;

import java.awt.BorderLayout;
import java.awt.Component;
import java.net.MalformedURLException;
import java.net.URL;

import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import chrriis.dj.nativeswing.swtimpl.NativeInterface;
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;

public class MediaPlayer {

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/watch?v=Vf42IP__ipw");
return webBrowserPanel;
}
}