diff options
author | Anika Henke <anika@selfthinker.org> | 2013-08-02 21:35:13 +0100 |
---|---|---|
committer | Anika Henke <anika@selfthinker.org> | 2013-08-02 21:35:13 +0100 |
commit | 2a2a2ba2f6092b0b68a7de0ccc798062682487f4 (patch) | |
tree | 0692416f6e0c81c62b3325fdf5c7b53280ca8266 | |
parent | de4c3948e85025e1244a5aadca017f83c6362c64 (diff) | |
download | rpg-2a2a2ba2f6092b0b68a7de0ccc798062682487f4.tar.gz rpg-2a2a2ba2f6092b0b68a7de0ccc798062682487f4.tar.bz2 |
added basic suport for embedding (html5) videos
-rw-r--r-- | conf/mime.conf | 3 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 66 | ||||
-rw-r--r-- | lib/images/fileicons/mp4.png | bin | 0 -> 740 bytes | |||
-rw-r--r-- | lib/images/fileicons/ogv.png | bin | 0 -> 740 bytes | |||
-rw-r--r-- | lib/images/fileicons/webm.png | bin | 0 -> 740 bytes |
5 files changed, 65 insertions, 4 deletions
diff --git a/conf/mime.conf b/conf/mime.conf index 381b93f86..2a50fab10 100644 --- a/conf/mime.conf +++ b/conf/mime.conf @@ -13,6 +13,9 @@ swf application/x-shockwave-flash mp3 audio/mpeg ogg audio/ogg wav audio/wav +webm video/webm +ogv video/ogg +mp4 video/mp4 tgz !application/octet-stream tar !application/x-gtar diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 84a999e56..747f0e8a0 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -795,8 +795,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { list($ext,$mime,$dl) = mimetype($src,false); if(substr($mime,0,5) == 'image' && $render){ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct')); - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -831,8 +831,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if(substr($mime,0,5) == 'image' && $render){ // link only jpeg images // if ($ext != 'jpg' && $ext != 'jpeg') $noLink = true; - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -1093,6 +1093,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= ' />'; + }elseif(substr($mime,0,5) == 'video'){ + + // 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 video(s) + $ret .= $this->_video($src, $title, $mime, $width, $height, $att); + }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { // if the flash is not supposed to be rendered @@ -1226,6 +1248,42 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } + /** + * Embed video(s) in HTML + * + * @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 + */ + function _video($src,$title,$mime,$width,$height,$atts=null){ + + // prepare width and height + if(is_null($atts)) $atts = array(); + $atts['width'] = (int) $width; + $atts['height'] = (int) $height; + if(!$atts['width']) $atts['width'] = 320; + if(!$atts['height']) $atts['height'] = 240; + + $url = ml($src,array('cache'=>$cache),true,'&'); + + // @todo: add poster + $this->doc .= '<video '.buildAttributes($atts).' controls="controls">'.NL; + // @todo: foreach all extensions + $this->doc .= '<source src="'.hsc($url).'" />'.NL; + + // alternative content + // @todo: foreach all extensions + $this->internalmedia($src, $title, NULL, NULL, NULL, $cache=NULL, $linking='linkonly'); + + // finish + $this->doc .= '</video>'.NL; + } + } //Setup VIM: ex: et ts=4 : diff --git a/lib/images/fileicons/mp4.png b/lib/images/fileicons/mp4.png Binary files differnew file mode 100644 index 000000000..b89fc5299 --- /dev/null +++ b/lib/images/fileicons/mp4.png diff --git a/lib/images/fileicons/ogv.png b/lib/images/fileicons/ogv.png Binary files differnew file mode 100644 index 000000000..b89fc5299 --- /dev/null +++ b/lib/images/fileicons/ogv.png diff --git a/lib/images/fileicons/webm.png b/lib/images/fileicons/webm.png Binary files differnew file mode 100644 index 000000000..b89fc5299 --- /dev/null +++ b/lib/images/fileicons/webm.png |