package zizouz.crime.demo;

import java.io.File;

import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ComponentEvent;

import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaPlayer.Status;
import javafx.scene.media.MediaView;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Paint;
import javafx.scene.Scene;

import javax.swing.JFrame;

public class VideoPlayer extends javafx.embed.swing.JFXPanel implements KeyListener, ComponentListener 
{
	private static final long serialVersionUID = 11521199786L;
	public static final String path = new File("./Resources/intro.mp4").toURI().toString();
	
	public VideoPlayer() 
	{
		super();
		
		this.file = new Media(VideoPlayer.path);
		this.player = new MediaPlayer(this.file);
		this.view = new MediaView(this.player);
		
		this.pane = new BorderPane();
		this.fxScene = new Scene(this.pane);
		
		this.pane.setCenter(this.view);
		
		this.fxScene.setFill(Paint.valueOf("black"));
		
		this.addComponentListener(this);
		this.addKeyListener(this);
		
		this.setScene(this.fxScene);
	}
	
	protected final Media file;
	protected final MediaPlayer player;
	protected final MediaView view;
	protected final BorderPane pane;
	protected final Scene fxScene;
	
	@Override
	public void keyPressed(KeyEvent event) 
	{
		
	}
	@Override
	public void keyReleased(KeyEvent event) 
	{
		switch (event.getKeyCode())
		{
			case KeyEvent.VK_SPACE:
				boolean playing = this.player.getStatus().equals(Status.PLAYING);
				if (playing) 
					this.player.pause();
				else
					this.player.play();
				return;
			case KeyEvent.VK_ENTER:
				boolean playing = this.player.getStatus().equals(Status.PLAYING);
				this.player.stop();
				if (playing)
					this.player.play();
				return;
		}
	}
	@Override
	public void keyTyped(KeyEvent event) 
	{
		
	}
	
	
	
}

@@ -1334,16 +1334,52 @@
 cene;%0A%09%0A
+%09protected volatile boolean auto;%0A%09%0A
 %09@Overri
@@ -1889,75 +1889,691 @@
 ;%0A%09%09
-%7D%0A%09%7D%0A%09@Override%0A%09public void keyTyped(KeyEvent event) %0A%09%7B%0A%09%09%0A%09%7D%0A%09%0A%09
+%09case KeyEvent.VK_A:%0A%09%09%09%09if (this.auto)%0A%09%09%09%09%09this.auto = false;%0A%09%09%09%09else%0A%09%09%09%09%09this.auto = true;%0A%09%09%09%09%0A%09%09%09%09this.player.setAutoPlay(this.auto);%0A%09%09%7D%0A%09%7D%0A%09@Override%0A%09public void keyTyped(KeyEvent event) %0A%09%7B%0A%09%09%0A%09%7D%0A%09@Override%0A%09public void componentResized(ComponentEvent event) %0A%09%7B%0A%09%09this.view.setPreserveRatio(true);%0A%09%09this.view.setFitWidth(this.getWidth());%0A%09%09this.view.setFitHeight(this.getHeight());%0A%09%7D%0A%09@Override%0A%09public void componentMoved(ComponentEvent event) %0A%09%7B%0A%09%09%0A%09%7D%0A%09@Override%0A%09public void componentMoved(ComponentEvent event) %0A%09%7B%0A%09%09%0A%09%7D%0A%09@Override%0A%09public void componentShown(ComponentEvent event) %0A%09%7B%0A%09%09%0A%09%7D%0A%09@Override%0A%09public void componentHidden(ComponentEvent event) %0A%09%7B%0A%09%09%0A%09%7D
 %0A%09%0A%7D

Update VideoPlayer.java