public synchronized void controllerUpdate(ControllerEvent event) {

		if (Debug.audio) System.out.println("CONTROLLER EVENT");

		// If the player has just been realized, then create the control panel.
		if (event instanceof RealizeCompleteEvent){

			//  Now that the player is realized, get the gain controls to allow volume control.
			gainControl = player.getGainControl();

			if (Debug.audio) System.out.println("AudioPlayer -> Realize complete");

			// Check whether a control panel was requested, then create one if needed.
			if ((controls) && (controlComponent = player.getControlPanelComponent()) != null) {

				if (Debug.audio) System.out.println("AudioPlayer -> Creating control panel");

				// Fix the size of the control panel
                Dimension controlDim = controlComponent.getPreferredSize();
                controlDim.height = 25;
                controlDim.width = scaledXDim;
                controlComponent.setPreferredSize(controlDim);
                mediaPanel.add(controlComponent);
                controlComponent.setBounds(0, 0, scaledXDim, 25);
            }
			mediaPanel.validate();
			realizeComplete = true;
			// Sets it to active
			super.setIsActive(true);

		}

		// At the end of the media, loop round if loop is set
		else if (event instanceof EndOfMediaEvent){
			if (loop){
				stopMedia();
				playMedia();
			}
			else {
				stopMedia();
			}
		}
	}