Results 1 to 3 of 3
Thread: JMF mediaPlayer.close
- 02-09-2011, 02:11 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 9
- Rep Power
- 0
JMF mediaPlayer.close
Hi,
I have problem, when I click to any JButton -> It start plays MPEG video (for example: 10s) -> (I use Timer to check duration of video), video plays in JWINDOW /setVisible(true)/ and start Timer set on 10s, after 10s Timer setVisible(false) *JWINDOW* -> It works! But when I want second time click on the same JButton, I have
last picture from first video.
I post you 4 classes of my program, check it pls (I have problem with mediaPlayer.close).
first class ->
*PLAYER*
--------------Java Code:package kiosk; import java.awt.Component; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.media.CannotRealizeException; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.swing.JWindow; public class Prehravac extends JWindow { public Prehravac(URL mediaURL) throws MalformedURLException, IOException, NoPlayerException, CannotRealizeException { Player mediaPlayer = Manager.createRealizedPlayer(mediaURL); Component video = mediaPlayer.getVisualComponent(); // Component stop = mediaPlayer.getControlPanelComponent(); mediaPlayer.start(); if (Background.viditelnostOkna == false) { mediaPlayer.stop(); } if (mediaURL != null) { // Background.oknoPrehravace.add(stop); Background.viditelnostOkna = true; Background.oknoPrehravace.add(video); Background.oknoPrehravace.setVisible(Background.viditelnostOkna); } } }
2. class: (only part of class)
*public static JWindow oknoPrehravace = new JWindow();public static boolean viditelnostOkna = true;*
3. class:Java Code:package kiosk; import kiosk.Akce.ZpetAZobrazeni; import java.awt.Font; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.JWindow; import kiosk.Akce.CtvrtePatro; import kiosk.Akce.DruhePatro; import kiosk.Akce.PrvniPatro; import kiosk.Akce.TretiPatro; import kiosk.Akce.Vedeni; import kiosk.Tlacitka.MenuTlacitko; import kiosk.Tlacitka.MistnostTlacitko; import kiosk.Tlacitka.ZpetTlacitko; public class Background extends JWindow { public static JWindow oknoPrehravace = new JWindow(); public static boolean viditelnostOkna = true; }
*TIMER*
4. class:Java Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package kiosk; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** * * @author Gog */ public class Casovac implements ActionListener { javax.swing.Timer t = null; public Casovac(int delay) { t = new javax.swing.Timer(delay, this); t.start(); } public void actionPerformed(ActionEvent e) { Background.viditelnostOkna = false; Background.oknoPrehravace.setVisible(Background.viditelnostOkna); } }
*ACTION*
I think when *Background.oknoPrehravace.setVisible(Background.v iditelnostOkna);* will be *FALSE* it STOP *mediaPlayer* -> *if (Background.viditelnostOkna == false){mediaPlayer.stop();}*Java Code:package kiosk.Akce; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.logging.Level; import java.util.logging.Logger; import javax.media.CannotRealizeException; import javax.media.NoPlayerException; import kiosk.Background; import kiosk.Casovac; import kiosk.Prehravac; public class Vedeni { public Vedeni() { ActionListener sborovnaAction = new ActionListener() { public void actionPerformed(ActionEvent e) { try { Prehravac p = new Prehravac(new File("d:/bailey.mpg").toURL()); Casovac c = new Casovac(26000); } catch (MalformedURLException ex) { Logger.getLogger(Background.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Background.class.getName()).log(Level.SEVERE, null, ex); } catch (NoPlayerException ex) { Logger.getLogger(Background.class.getName()).log(Level.SEVERE, null, ex); } catch (CannotRealizeException ex) { Logger.getLogger(Background.class.getName()).log(Level.SEVERE, null, ex); } } }; } }
Thx for help
- 02-09-2011, 03:58 PM #2
You have the last picture from the first video because all you did was hide the view and then make it visible again. You may need to destroy some of the resources and recreate them for each new file - unless JMF has some handy methods to do that automatically. I did this years ago, and just can't remember anymore!
- 02-09-2011, 06:22 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 9
- Rep Power
- 0
yeah, I know what you mean but I write IF -> if(backgroud.viditelnostOkna == false)mediaPlayer.stop(); -> It doesn't works :-( When I play VIDEO, It will be visible (It plays mediaPlayer -> method -> mediaPlayer.start(); -> after video END I set JWINDOW to invisible -> so mediaPlayer restarted ?! Please help me more :-(
Similar Threads
-
don´t close a jFrame
By flaquitqm in forum AWT / SwingReplies: 4Last Post: 04-25-2010, 02:57 AM -
Will the connection.close() and statement.close() ever be called???
By Stephen Douglas in forum New To JavaReplies: 13Last Post: 04-09-2010, 11:15 AM -
close to zero
By nokicky in forum New To JavaReplies: 6Last Post: 10-26-2009, 04:30 PM -
Video MediaPlayer Errors
By Menre in forum Advanced JavaReplies: 6Last Post: 09-21-2009, 09:49 AM -
[SOLVED] Close Exe
By smartsubroto in forum New To JavaReplies: 11Last Post: 10-14-2008, 08:04 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks