package tmaestroplayer;

import java.awt.Component;
import java.beans.PropertyVetoException;

import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.plaf.basic.BasicInternalFrameUI;

public class DelayedTime extends Thread {

    long time;
    public Component component;
    boolean delayed;
    boolean focusable;
    boolean norep=false;
    public String name;
    VentanaSeleccionUnidad vsup;
    final JInternalFrame jif = new JInternalFrame();

    public DelayedTime() {
    }

    public void inicia(String str, long time, Component component,
            boolean delayed, boolean focusable, String name, VentanaSeleccionUnidad vsup) {
        this.time = time;
        this.component = component;
        this.delayed = delayed;
        this.focusable = focusable;
        this.name = name;
        this.vsup = vsup;
    }

    public void run() {
     
            //System.out.println(time);
    
        if (delayed) {
            try {
                sleep(time);

            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

      
                //System.out.println("anado " + name);
          
            component.setVisible(true);
            if (component instanceof MediaPanel) {
                MediaPanel mediaPanel = (MediaPanel) component;
                String aux = mediaPanel.mediaURL.getPath();
                String extension = aux.substring(aux.lastIndexOf("."), aux.length());
                component.setVisible(false);
                //System.out.println("aqui el problem");
               if (!norep) mediaPanel.start();
            }

        } else {

            try {
                sleep(time);

            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

                //System.out.println("borro " + name);
    
            component.setVisible(false);
            //SSSSSSS 22102009
            if (component instanceof MediaPanel) {
                ((MediaPanel) component).stop();
            }

        }

    }
}
