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*

 
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;*
 
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;
 
}

3. class:
*TIMER*

 
/*
 * 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);
    }
}

4. class:
*ACTION*

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);
                }
            }
        };
 
}
}

I think when *Background.oknoPrehravace.setVisible(Background.v iditelnostOkna);* will be *FALSE* it STOP *mediaPlayer* -> *if (Background.viditelnostOkna == false){mediaPlayer.stop();}*

Thx for help