diff options
author | Anika Henke <anika@selfthinker.org> | 2013-08-03 16:56:16 +0100 |
---|---|---|
committer | Anika Henke <anika@selfthinker.org> | 2013-08-03 16:56:16 +0100 |
commit | b44a5dce182bb65063dd1868e92954520e8fab88 (patch) | |
tree | 532540e8250d9d1aa501da52555c051a30216094 | |
parent | 79e53fe5a44293a82486c7228deb6d435768bc04 (diff) | |
download | rpg-b44a5dce182bb65063dd1868e92954520e8fab88.tar.gz rpg-b44a5dce182bb65063dd1868e92954520e8fab88.tar.bz2 |
added support for html5 audio
Similar to videos, all .ogg, .mp3 and .wav files with the same filename are automatically chosen as alternative sources when only one of them is mentioned in the media syntax.
-rw-r--r-- | inc/parser/xhtml.php | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index b1bfaae5d..c6e5a8e22 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1114,6 +1114,27 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //add video(s) $ret .= $this->_video($src, $width, $height, $att); + }elseif($mime == 'audio/ogg' || $mime == 'audio/mpeg' || $mime == 'audio/wav' ){ + // first get the $title + if (!is_null($title)) { + $title = $this->_xmlEntities($title); + } + if (!$title) { + // just show the sourcename + $title = $this->_xmlEntities(utf8_basename(noNS($src))); + } + if (!$render) { + // if the video is not supposed to be rendered + // return the title of the video + return $title; + } + + $att = array(); + $att['class'] = "media$align"; + + //add audio + $ret .= $this->_audio($src, $att); + }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { // if the flash is not supposed to be rendered @@ -1253,8 +1274,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @author Anika Henke <anika@selfthinker.org> * * @param string $src - ID of video to embed - * @param string $title - title of the video - * @param string $mime - mimetype of the video * @param int $width - width of the video in pixels * @param int $height - height of the video in pixels * @param array $atts - additional attributes for the <video> tag @@ -1296,6 +1315,37 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= '</video>'.NL; } + /** + * Embed audio in HTML + * + * @author Anika Henke <anika@selfthinker.org> + * + * @param string $src - ID of audio to embed + * @param array $atts - additional attributes for the <video> tag + */ + function _audio($src,$atts=null){ + + // prepare alternative formats + $extensions = array('ogg', 'mp3', 'wav'); + $alternatives = media_alternativefiles($src, $extensions); + + // open audio tag + $this->doc .= '<audio '.buildAttributes($atts).' controls="controls">'.NL; + + // output source for each alternative audio format + foreach($alternatives as $mime => $file) { + $url = ml($file,array('cache'=>$cache),true,'&'); + $title = $this->_xmlEntities(utf8_basename(noNS($file))); + + $this->doc .= '<source src="'.hsc($url).'" type="'.$mime.'" />'.NL; + // alternative content (just a link to the file) + $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly'); + } + + // finish + $this->doc .= '</audio>'.NL; + } + } //Setup VIM: ex: et ts=4 : |