TrackManiaControl/libs/FML/Controls/Audio.php

118 lines
2.4 KiB
PHP
Raw Normal View History

<?php
namespace FML\Controls;
2014-01-12 00:51:46 +01:00
use FML\Types\Playable;
use FML\Types\Scriptable;
/**
2014-01-19 19:30:21 +01:00
* Audio Control
2014-01-12 00:51:46 +01:00
* (CMlMediaPlayer)
*
2014-05-16 22:44:22 +02:00
* @author steeffeen
2014-04-13 18:21:40 +02:00
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
2014-05-16 22:44:22 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Audio extends Control implements Playable, Scriptable {
2014-01-21 20:30:40 +01:00
/*
2014-06-21 03:18:21 +02:00
* Protected properties
2014-01-12 00:51:46 +01:00
*/
2014-06-21 03:18:21 +02:00
protected $tagName = 'audio';
protected $data = null;
protected $dataId = null;
protected $play = null;
protected $looping = true;
protected $music = null;
2014-01-12 00:51:46 +01:00
protected $volume = 1.;
2014-06-21 03:18:21 +02:00
protected $scriptEvents = null;
2014-01-19 19:30:21 +01:00
/**
2014-05-16 22:44:22 +02:00
* @see \FML\Controls\Control::getManiaScriptClass()
*/
2014-05-16 22:44:22 +02:00
public function getManiaScriptClass() {
return 'CMlMediaPlayer';
}
2014-01-12 00:51:46 +01:00
/**
* @see \FML\Types\Playable::setData()
*/
public function setData($data) {
2014-05-16 22:44:22 +02:00
$this->data = (string)$data;
2014-01-12 00:51:46 +01:00
return $this;
}
2014-01-19 19:30:21 +01:00
/**
* @see \FML\Types\Playable::setDataId()
*/
public function setDataId($dataId) {
2014-05-16 22:44:22 +02:00
$this->dataId = (string)$dataId;
2014-01-19 19:30:21 +01:00
return $this;
}
2014-01-12 00:51:46 +01:00
/**
* @see \FML\Types\Playable::setPlay()
*/
public function setPlay($play) {
$this->play = ($play ? 1 : 0);
return $this;
}
/**
* @see \FML\Types\Playable::setLooping()
*/
public function setLooping($looping) {
$this->looping = ($looping ? 1 : 0);
return $this;
}
/**
* @see \FML\Types\Playable::setMusic()
*/
public function setMusic($music) {
$this->music = ($music ? 1 : 0);
return $this;
}
/**
* @see \FML\Types\Playable::setVolume()
*/
public function setVolume($volume) {
2014-05-16 22:44:22 +02:00
$this->volume = (float)$volume;
2014-01-12 00:51:46 +01:00
return $this;
}
/**
* @see \FML\Types\Scriptable::setScriptEvents()
*/
public function setScriptEvents($scriptEvents) {
$this->scriptEvents = ($scriptEvents ? 1 : 0);
return $this;
}
/**
2014-06-21 03:18:21 +02:00
* @see \FML\Types\Renderable::render()
*/
public function render(\DOMDocument $domDocument) {
2014-01-12 00:51:46 +01:00
$xmlElement = parent::render($domDocument);
if ($this->data) {
$xmlElement->setAttribute('data', $this->data);
}
if ($this->play) {
$xmlElement->setAttribute('play', $this->play);
}
2014-01-19 19:30:21 +01:00
if (!$this->looping) {
2014-01-12 00:51:46 +01:00
$xmlElement->setAttribute('looping', $this->looping);
}
if ($this->music) {
$xmlElement->setAttribute('music', $this->music);
}
if ($this->volume != 1.) {
$xmlElement->setAttribute('volume', $this->volume);
}
if ($this->scriptEvents) {
$xmlElement->setAttribute('scriptevents', $this->scriptEvents);
}
return $xmlElement;
}
}