Important JMF question

Advertisement

hello.
i managed to get both the menu + JMF programs below compiling. when i choose a media file from a directory, the file chooser closes down and the window that the audio or video is supposed to be played on opens up. but the window is blank. how am i going to get this problem solved?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class UserMainMenu extends JFrame{
   JButton btnViewProductDetails = new JButton("View Product Details");
   JButton btnViewSpecialOffers = new JButton("View Special Offers");
   JButton btnViewLatestMovieClip = new JButton("View Latest Movie Clip");
   JButton btnEditMemberDetails = new JButton("Edit Member Details");
   JButton btnUnsubscribe = new JButton("Unsubscribe");
   JButton btnUserLogOff = new JButton("Log Off");
   Container contentpane;
   public UserMainMenu(){
      super("User Main Menu");
      contentpane = getContentPane();
      contentpane.setLayout(new GridLayout(3, 2));
      add(btnViewProductDetails);
      add(btnViewSpecialOffers);
      add(btnViewLatestMovieClip);
      add(btnEditMemberDetails);
      add(btnUnsubscribe);
      add(btnUserLogOff);
      setSize(650, 600);
      setLocationRelativeTo(null);
      setVisible(true);
      btnViewProductDetails.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
            setVisible(false);
            //ViewProductDetails vpd = new ViewProductDetails();
            //vpd.setVisible(true);    
       btnViewSpecialOffers.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
             setVisible(false);
             //ViewSpecialOffers vso = new ViewSpecialOffers();
             //vso.setVisible(true);    
       btnViewLatestMovieClip.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e){
             setVisible(false);
             Media m = new Media();
             m.setVisible(true);    
      btnEditMemberDetails.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
            setVisible(false);
            //MemberForm mf = new MemberForm();
            //mf.setVisible(true);    
      btnUnsubscribe.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
            setVisible(false);
            //UnsubscribeMenu um = new UnsubscribeMenu();
            //um.setVisible(true);     
      btnUserLogOff.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
            int result;
            result = JOptionPane.showConfirmDialog(null, "Are you sure you want to log off?", null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if(result == JOptionPane.YES_OPTION){
               setVisible(false);
   public static void main(String[] args){  
      new UserMainMenu(); 
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.media.*;
import javax.swing.*;
public class Media extends JPanel{
   public Media(){
      JFileChooser jfc = new JFileChooser();
      int f = jfc.showOpenDialog(null);
      if(f == JFileChooser.APPROVE_OPTION){
         URL u = null;
         try{ 
            u = jfc.getSelectedFile().toURL();
         catch(MalformedURLException mue){
            System.err.println("Could not create the URL for the file");
         if(u != null){
            JFrame jf = new JFrame("Latest Movie Clip");
            jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Media m = new Media(u);
            jf.add(m);
            jf.setSize(600, 600);
            jf.setLocationRelativeTo(null);
            jf.setVisible(true);
   public Media(URL u){
      setLayout(new BorderLayout());
      JPanel mediaPanel = new JPanel();
      JPanel buttonPanel = new JPanel();
      JButton returnToMainMenu = new JButton("Return to Main Menu");
      buttonPanel.add(returnToMainMenu, BorderLayout.NORTH);
      Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
      try{
         Player p = Manager.createRealizedPlayer(u);
         Component v = p.getVisualComponent();
         Component c = p.getControlPanelComponent();
         if(v != null && c != null){
            mediaPanel.add(v, BorderLayout.CENTER);
            mediaPanel.add(c, BorderLayout.SOUTH);
         p.start();
      catch(NoPlayerException npe){
         System.err.println("No media player was found");
      catch(CannotRealizeException cre){
         System.err.println("Could not realize the media player");
      catch(IOException ioe){
         System.err.println("Error reading from the source");
      returnToMainMenu.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
            setVisible(false);
            UserMainMenu umm = new UserMainMenu();
            umm.setVisible(true);
}

Advertisement

you are going to figure out what went wrong in your app by backtracking until you find the problem. you can use the debugger to look for things that should have been there but arent, and then finding the source of this problem. eventually you can find what is wrong.

November 30, -0001

Important JMF question

hello. i managed to get both the menu + JMF programs below compiling. when i choose a media file from a directory, the file chooser closes down and the window that the audio or video is supposed to be played on opens up. but the window is blank. how

No option to import GIFT question as pretest

I'm importing a gift file, and it appears to default to "Graded", with no option to change it to Pretest.  Not a huge problem with smaller courses but it would be nice to import pretest questions as well. Unless I'm just missing something?I thin

Simple Import Static Question

Hi, Just wondering is it possible in regards to "import static" to statically import a static class or does it only allow one to import static functions and variables within a class? Cheers.Hi, Thanks for your reply. I actually do understand tha

JSTL c:import tag question

HI I have a question about how the <c:param> tag interacts with <c:import> tag. <c:import> tag can be used to import from relative URL's like <c:import url="target.jsp" /> , from absolute urls like <c:import url="

Import Quality Question

Ok I don't know much about this but, How much audio quality do you lose when you import from a CD? Also, if the answer is lots, then does iTunes use that lossless audio encoder called apple lossless and if not where can I get and what do I need to us

EDL Exporting and Importing 101 - Questions

We are testing Premiere's EDL exporting and importing capabilities for the first time, and are having issues. We set up a very simple test project with only 13 clips and a timeline with only 10 edits. This is what it looks like: http://img819.imagesh

General JMF question

If I had three MP3/WAV files, could JMF allow me to combine all 3 into one single MP3/WAV file? Thanks.I think this question belongs in the Java Media Framework section, not the Java Sound section.Read other 3 answers

Playing imported HDV question

I use Final Cut Studio 2 at school, and import off our HDV camcorders using Final Cut. I've noticed the format used is Quicktime MOV with the HDV codec. Is there any way to play these files back on a pc running Windows Vista? I don't have Final Cut o

An ever-ubituous import library question ???

So here's my dillemma: My desktop computer is slooooooooo. My laptop is fast. My large (over 100 gig) library is on my desktop computer -- well, really it's on an external hard drive, but the itunes I use is on the desktop. If I import the library fr

Import media questions

Device is the Nokia E5-00 and Ovi suite version is 3.1.1.78 Whil;e importign media files, is it possible that:  a. only the files get imported, no folders b. after a successful import, the data is automatically deleted from the phoneYes, but I don't

Another JMF-question

Hi ! can you maybe please tell me, how to find out a media's total playing time? i would like to implement a Slider that shows the current mediaTime, and can be set to another mediaTime, therefor i need it. thx a lot!dear US101! I'm not sure if i get

Importing Format Questions

Ok when you import a cd as mp3 format, when I check the file it gives me the name of the song, artist and album. Now when I import using the AAC format it just says track # and song, also when u go into proterties it doesnt tell you any info about th

IMPORTANT charging question (proper charging method)

lately, my battery has been dying quickly... are you supposed to use the little white dock/stand that comes with the iphone to charge it, or can you charge it by just plugging the iphone into the usb-> to wall... i have been doing the usb to wall and

Imported graphic question

I made a graphic of a "tabbed folder" in a graphics program (Photoshop). Just imagine a manilla folder with a tab at the top. I saved it off as a PNG 24 graphic. When I imported it into Flash (using Flash Pro 8), the area to the right of the tab

Very quick JMF question

HI I have serached google and a lot of forums and can;t find a simple answer. Can the JMF play AVI's encoded in DIVX 5.xx with mp3 sound? If yes is there something i have to do to get the JMF player to play them cos it comes up with an error. thanks

Basic importing/exporting question

I have been creating web videos for some time for a few companies. I bring all of the clips in as dv files, mess with them in FCP, then export to mov. I then use CS4 encoder to convert them to mp4's. Works great. My question is I have a project where

Import Folder question

I have all of my photos organized on a hard drive in folders and subfolders. For example: Main Photos>2009>RAW136>20091112Grandmas Birthday. When I import into Aperture do I have to point to each individual subfolder or is there a way to point to

Import export questions

Hi. I want to import on portal 3.0.9.8.0 an export file from a component from portal 3.0.9.8.3A. Is that a problem? Does upgrading the portal to the latest 3.0.9. version infects the components already on it? Thanks!Anybody?Read other 2 answers

Importing duplicates question

When I connect my iPhone and Import photos, somethimes I am asked if I want to import duplicates as it seems some photos are already on my Mac probably via iCloud. But if I say Do not import duplicates, does that mean that when I reach 1,000 photos i

Importing/exporting question

I'll start by saying I'm new to video editing and adobe premiere pro.  Forgive me if what I ask has been asked repeatedly before but I can't find an answer to my question through keyword searchs of google and these forums. That said I have a canon vi