2013-11-25 00:02:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Controls;
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
use FML\Types\Playable;
|
|
|
|
use FML\Types\Scriptable;
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2014-01-19 19:30:21 +01:00
|
|
|
* Video Control
|
2014-01-12 00:51:46 +01:00
|
|
|
* (CMlMediaPlayer)
|
2013-11-25 00:02:07 +01:00
|
|
|
*
|
|
|
|
* @author steeffeen
|
|
|
|
*/
|
|
|
|
class Video extends Control implements Playable, Scriptable {
|
2014-01-12 00:51:46 +01:00
|
|
|
/**
|
|
|
|
* Protected Properties
|
|
|
|
*/
|
|
|
|
protected $data = '';
|
2014-01-19 19:30:21 +01:00
|
|
|
protected $dataId = '';
|
2014-01-12 00:51:46 +01:00
|
|
|
protected $play = 0;
|
|
|
|
protected $looping = 0;
|
|
|
|
protected $music = 0;
|
|
|
|
protected $volume = 1.;
|
|
|
|
protected $scriptEvents = 0;
|
2013-11-25 00:02:07 +01:00
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
* Create a new Video Control
|
|
|
|
*
|
|
|
|
* @param string $id (optional) Control Id
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public static function create($id = null) {
|
|
|
|
$video = new Video($id);
|
|
|
|
return $video;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
2013-12-31 02:55:19 +01:00
|
|
|
* Construct a new Video Control
|
|
|
|
*
|
2014-01-12 00:51:46 +01:00
|
|
|
* @param string $id (optional) Control Id
|
2013-11-25 00:02:07 +01:00
|
|
|
*/
|
|
|
|
public function __construct($id = null) {
|
|
|
|
parent::__construct($id);
|
|
|
|
$this->tagName = 'video';
|
|
|
|
}
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Playable::setData()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setData($data) {
|
|
|
|
$this->data = (string) $data;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-19 19:30:21 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Playable::setDataId()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setDataId($dataId) {
|
|
|
|
$this->dataId = (string) $dataId;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-12 00:51:46 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Playable::setPlay()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setPlay($play) {
|
|
|
|
$this->play = ($play ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Playable::setLooping()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setLooping($looping) {
|
|
|
|
$this->looping = ($looping ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Playable::setMusic()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setMusic($music) {
|
|
|
|
$this->music = ($music ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Playable::setVolume()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setVolume($volume) {
|
|
|
|
$this->volume = (float) $volume;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Types\Scriptable::setScriptEvents()
|
|
|
|
* @return \FML\Controls\Video
|
|
|
|
*/
|
|
|
|
public function setScriptEvents($scriptEvents) {
|
|
|
|
$this->scriptEvents = ($scriptEvents ? 1 : 0);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-11-25 00:02:07 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @see \FML\Control::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;
|
2013-11-25 00:02:07 +01:00
|
|
|
}
|
|
|
|
}
|