1: <?php
2:
3: /**
4: * This file contains the cHTMLAudio class.
5: *
6: * @package Core
7: * @subpackage GUI_HTML
8: *
9: * @author Simon Sprankel
10: * @copyright four for business AG <www.4fb.de>
11: * @license http://www.contenido.org/license/LIZENZ.txt
12: * @link http://www.4fb.de
13: * @link http://www.contenido.org
14: */
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: /**
19: * cHTMLAudio class specifies sound content.
20: *
21: * @package Core
22: * @subpackage GUI_HTML
23: */
24: class cHTMLAudio extends cHTMLContentElement {
25:
26: /**
27: * Constructor to create an instance of this class.
28: *
29: * @param mixed $content [optional]
30: * String or object with the contents
31: * @param string $class [optional]
32: * the class of this element
33: * @param string $id [optional]
34: * the ID of this element
35: * @param string $src [optional]
36: */
37: public function __construct($content = '', $class = '', $id = '', $src = '') {
38: parent::__construct($content, $class, $id);
39: $this->_tag = 'audio';
40: $this->setSrc($src);
41: }
42:
43: /**
44: * Sets the src attribute of this element.
45: *
46: * @param string $src
47: */
48: public function setSrc($src) {
49: $this->setAttribute('src', $src);
50: }
51:
52: /**
53: * Sets the autoplay attribute which specifies if the sound should be played
54: * automatically.
55: *
56: * @param bool $autoplay
57: */
58: public function setAutoplay($autoplay) {
59: if ($autoplay) {
60: $this->setAttribute('autoplay', 'autoplay');
61: } else {
62: $this->removeAttribute('autoplay');
63: }
64: }
65:
66: /**
67: * Sets the controls attribute which specifies if controls should be shown
68: * in the player.
69: *
70: * @param bool $controls
71: */
72: public function setControls($controls) {
73: if ($controls) {
74: $this->setAttribute('controls', 'controls');
75: } else {
76: $this->removeAttribute('controls');
77: }
78: }
79:
80: }
81: