import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.control.Button;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.media.MediaView;
import java.io.IOException;
import java.io.*;
import javafx.application.Application;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.util.Timer;
import javafx.scene.control.Label;
import javafx.animation.Timeline;
import javafx.stage.Stage;

public class Boton extends Button implements BotonList {
	public Boton(String str, String str2,String str3){
		//metodo constructor
		setText(str);
		Image img = new Image(str3);
		ImageView view = new ImageView(img);
		setGraphic(view);
		Image image = new Image(str3);
		//getChildren().add(label);
		//setMinSize(2,2);
		media_url=Boton.class.getResource(str2).toExternalForm();
		Media media = new Media(media_url);
		player = new MediaPlayer(media);
		//player.setCycleCount(MediaPlayer.INDEFINITE);
		equis=1;
		cronometro=new Cronometro(this);
		setOnAction(e->crono());
	}
	public void play_pause(){
		if(equis==1){
			player.play();
			//cronometro.asignarTiempo();
			equis=0;
		}
		else{
			player.pause();
			//cronometro.asignarTiempo();
			equis=1;
		}
	}
	public void crono(){
		if(equis==1){
				cronometro.display();
				equis=0;
			}
		else{
			play_pause();
			
		}
	}
	public void pause(){
		player.pause();
	}
	
   
	
	private String media_url;
	private int equis;
	public MediaPlayer player;
	private Cronometro cronometro;
}
