diff options
author | Anika Henke <anika@selfthinker.org> | 2013-08-02 23:13:41 +0100 |
---|---|---|
committer | Anika Henke <anika@selfthinker.org> | 2013-08-02 23:13:41 +0100 |
commit | 3d7a9e0a1cba0b173b6b03f5c88a8eb975286cc7 (patch) | |
tree | 9963a34099190a1c9241c0e3d8df8de8c13c8171 /inc/parser | |
parent | 2a2a2ba2f6092b0b68a7de0ccc798062682487f4 (diff) | |
download | rpg-3d7a9e0a1cba0b173b6b03f5c88a8eb975286cc7.tar.gz rpg-3d7a9e0a1cba0b173b6b03f5c88a8eb975286cc7.tar.bz2 |
Add several alternative formats to video for better browser compatibility
All .webm, .ogv and .mp4 files with the same filename are automatically
chosen as alternative sources when only one of them is mentioned in the
media syntax.
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/xhtml.php | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 747f0e8a0..bb5f6a4d2 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1095,9 +1095,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { }elseif(substr($mime,0,5) == 'video'){ + $origTitle = ''; // first get the $title if (!is_null($title)) { $title = $this->_xmlEntities($title); + $origTitle = $title; } if (!$title) { // just show the sourcename @@ -1113,7 +1115,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $att['class'] = "media$align"; //add video(s) - $ret .= $this->_video($src, $title, $mime, $width, $height, $att); + $ret .= $this->_video($src, $origTitle, $mime, $width, $height, $att); }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { @@ -1269,16 +1271,30 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if(!$atts['width']) $atts['width'] = 320; if(!$atts['height']) $atts['height'] = 240; - $url = ml($src,array('cache'=>$cache),true,'&'); + // prepare alternative formats + $extensions = array('webm', 'ogv', 'mp4'); + $types['webm'] = 'video/webm; codecs="vp8, vorbis"'; + $types['ogv'] = 'video/ogg; codecs="theora, vorbis"'; + // mp4 would be 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', but Android doesn't like it + $types['mp4'] = ''; + $alternatives = media_alternativefiles($src, $extensions); // @todo: add poster $this->doc .= '<video '.buildAttributes($atts).' controls="controls">'.NL; - // @todo: foreach all extensions - $this->doc .= '<source src="'.hsc($url).'" />'.NL; + foreach($alternatives as $ext => $file) { + $url = ml($file,array('cache'=>$cache),true,'&'); + $type = $types[$ext]; + if (!$title) { + $title = $this->_xmlEntities(utf8_basename(noNS($file))); + } - // alternative content - // @todo: foreach all extensions - $this->internalmedia($src, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly'); + $this->doc .= '<source src="'.hsc($url).'"'; + if (!empty($type)) $this->doc .= ' type=\''.$type.'\''; + $this->doc .= ' />'.NL; + + // alternative content + $this->internalmedia($file, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly'); + } // finish $this->doc .= '</video>'.NL; |