// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:47:52
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   LabelDelVideo.java

package project;

import java.awt.*;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.util.Properties;
import javax.media.*;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import traduccion.Traducir;

// Referenced classes of package project:
//            JLabel, EZIPImageLoader, MensajeDeError, ControlDeLasPreguntasTipoV, 
//            LabelDeFondoDelFrame2, AccederADatos, Video

public class LabelDelVideo extends JLabel
    implements ControllerListener
{

    public LabelDelVideo(Video fr2)
    {
        eZIPImageLoader = new EZIPImageLoader();
        player = null;
        fr = fr2;
        setLayout(new BorderLayout());
        setLocation(-1000, -1000);
    }

    public void start()
    {
        try
        {
            player.start();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.err.println("Got exception " + e);
        }
    }

    public void stop()
    {
        try
        {
            player.stop();
            player.deallocate();
            fr.setLocation(-1000, -1000);
            vid.visible = 0;
            vid.vid.setEnabled(true);
            vid.labelDeFondoDelFrame.vid = true;
            fr.setVisible(false);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void destroy()
    {
    }

    public synchronized void controllerUpdate(ControllerEvent event)
    {
        if(event instanceof EndOfMediaEvent)
        {
            player.deallocate();
            fr.setLocation(-1000, -1000);
            vid.visible = 0;
            vid.vid.setEnabled(true);
            vid.labelDeFondoDelFrame.vid = true;
            fr.setVisible(false);
        }
        if(event instanceof RealizeCompleteEvent)
        {
            if((comp = player.getVisualComponent()) != null)
            {
                add("Center", comp);
                tamaF1oVideo = player.getVisualComponent().getPreferredSize();
                colocar();
            }
            if((comp = player.getControlPanelComponent()) == null);
            validate();
        }
    }

    public void cargarYComenzar(String mediaFile2, ControlDeLasPreguntasTipoV vid2)
    {
        String mediaFile;
        vid = vid2;
        mediaFile = null;
        try
        {
            if(mediaFile2.startsWith("Videos"))
                mediaFile = "file:" + System.getProperties().getProperty("user.dir") + "/java/" + mediaFile2;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            MensajeDeError mensaje = new MensajeDeError();
            mensaje.mensaje(true, Traducir.getTraduccion(AccederADatos.leer("h.proyecto"), "project.LabelDelVideo", "200411301748", AccederADatos.idioma) + mediaFile2);
            mensaje = null;
        }
        try
        {
            URL mediaURL = new URL(mediaFile);
            player = Manager.createPlayer(mediaURL);
            player.addControllerListener(this);
            start();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.err.println("Got exception " + e);
        }
        break MISSING_BLOCK_LABEL_190;
        Exception exception;
        exception;
        throw exception;
    }

    public void colocar()
    {
        try
        {
            setPreferredSize(tamaF1oVideo);
            fr.setSize(tamaF1oVideo);
            Dimension videoSize = tamaF1oVideo;
            screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            fr.setLocation((screenSize.width - videoSize.width) / 2, (screenSize.height - videoSize.height) / 2);
            setVisible(true);
            fr.setVisible(true);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    EZIPImageLoader eZIPImageLoader;
    Player player;
    Dimension screenSize;
    Component comp;
    Dimension tamaF1oVideo;
    Video fr;
    ControlDeLasPreguntasTipoV vid;
    InputStream stream;
}