From 7c9bda7978bab8f4972d32b6db65af2a16a2a34c Mon Sep 17 00:00:00 2001 From: "jtByt.Pictures" Date: Tue, 4 Nov 2014 10:04:36 +0100 Subject: [PATCH] updated for kirby 2 --- README.md | 59 ++++++++++++++++------------------- html5video.php | 55 +++++++++++++++++++++++++++++++++ kirbytext.extend.php | 73 -------------------------------------------- 3 files changed, 82 insertions(+), 105 deletions(-) create mode 100644 html5video.php delete mode 100644 kirbytext.extend.php diff --git a/README.md b/README.md index ab149ab..67395cf 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,28 @@ -## README: kirby-kirbytag-html5video +# kirbytag html5video +by jtByt.Pictures, Jannik Beyerstedt from Hamburg, Germany +[jannik.beyerstedt.de](http://jannik.beyerstedt.de) | [Github](https://github.com/jtByt-Pictures) -## html5 video markdown -This is an extension of kirbytext for the [kirby cms](getkirby.com), which adds the possibiliy to add html5-video very simple in your text file like any link you add. It´s done by extending the default kirbytags in the file kirbytag.extend.php. -This extension/ funciton will generate the HTML5-video-tag element with the correct source files. It can handle links to mp4 (h.264), webm and HTTP-live-streaming sources (you can disable some) as well as a poster. A special feature of this kirbytag-extension is, that the videos can be stored in a seperate folder so they can be at an other location than the content-folder. +## responsive html5 video player for lazy people + +#### update: +This is the version for kirby 2! html5youtube has moved to [it´s own repository](https://github.com/jtByt-Pictures/kirby-kirbytag-html5youtube) + +## Introduction + +This is an extension of kirbytext for the [kirby cms](getkirby.com), which adds an easy way to embed your self-hosted html5-video sources in a responsive layout. This means, you can use it responsive, or it´ll adapt to your layout anyway. + +I know that there are some other solutions out there, but I´m lazy, so this is the version for the lazy people. + +This extension can handle mp4 (h.264), webm and HTTP-live-streaming sources as well as a poster. You can select, which versions you have. +Another special feature is, that the videos are stored in a special folder to keen bug data in one place. #### how to use +store this file in + + site/tags/ + * store your video files in a folder named "video" in your html-root * or change the $baseurl in the php * have a name for your video-files, e.g. "NAME" @@ -28,12 +44,6 @@ example (in your video folder): | cool-video-poster.png | /cool-video-hls/cool- * (html5video: cool-video webm: FALSE hls: FALSE) -#### why not store the video files in the content-folder? -I choosed to store all the videos in a seperate folder, because all my html-root is synced to my dropbox (I´m very lazy to sync my local HTML-editor and my webserver). But the video-files are quite big, so I excluded the video-folder from the sync. -** exclude this folder from dropbox-sync before you add any content to that folder! Or move the content temprary to another folde! Otherwise alle the content in the excluded folder will be removed from the local directory (but not the server)** - -So I add video-files via (S)FTP an edit all my other files via dropbox sync to my computers dorectory. - #### CSS @@ -43,30 +53,15 @@ Add this little rule to make the player fill the full width of the parent-contai .html5player {width: 100%; height: auto;} -#### to do: -perhaps someone can add a auto-detection, if the source file exists, so you needn´t add the options manually. - - - -## responsive youtube player embedding - -#### how to use - -simply add your video ID in your markdown in the following way: - - (html5youtube: {video-ID}) - -you will only need the youtube-video-ID, not the whole link. Of course you can add more options (the ones that are in the embedding URL. See [google embedding options reference](https://developers.google.com/youtube/player_parameters?hl=en#Parameters). ) - -Now your markdown tag can look like this: +#### why not store the video files in the content-folder? +I choosed to store all the videos in a seperate folder, because all my html-root is synced to my dropbox (I´m very lazy to sync my local HTML-editor and my webserver). But the video-files are quite big, so I excluded the video-folder from the sync. +** exclude this folder from dropbox-sync before you add any content to that folder! Or move the content temprary to another folde! Otherwise alle the content in the excluded folder will be removed from the local directory (but not the server)** - (html5youtube: {video-ID} options: &modestbranding=1) +So I add video-files via (S)FTP an edit all my other files via dropbox sync to my computers dorectory. + +#### to do: +- auto-detection if the source files exist. -#### CSS -simply add this two lines of code to your CSS file to make the youtube-player responsive/ switch from fixed size to the width of the container it is placed in. - div.video-container {width: 100%; padding-bottom: 56%; padding-top: 30px; height: 0; overflow: hidden; max-width: 100%; height: auto; position: relative;} - - .video-container iframe {position: absolute; top: 0; left: 0; width: 100%; height: 100%;} diff --git a/html5video.php b/html5video.php new file mode 100644 index 0000000..adc3fe9 --- /dev/null +++ b/html5video.php @@ -0,0 +1,55 @@ + array( + 'hls', + 'h264', + 'webm' + ), + 'html' => function($tag) { + $source = $tag->attr('html5video'); + + $baseurl = url('/video/'); + $posterurl = $baseurl . urlencode($source) . '-poster.png'; + + + + if ($tag->attr('hls') == true) { + $hlsurl = $baseurl . urlencode($source) . '-hls/' . urlencode($source) . '-index.m3u8'; + $hlssource = '';} + else { + $hlssource = "";} + + if ($tag->attr('h264') == true) { + $mp4url = $baseurl . urlencode($source) . '-h264.mp4'; + $mp4source = '';} + else { + $mp4source = "";} + + if ($tag->attr('webm') == true) { + $webmurl = $baseurl . urlencode($source) . '-webm.webm'; + $webmsource = '';} + else { + $webmsource = "";} + + return ''; + + } + +); \ No newline at end of file diff --git a/kirbytext.extend.php b/kirbytext.extend.php deleted file mode 100644 index 1d1c936..0000000 --- a/kirbytext.extend.php +++ /dev/null @@ -1,73 +0,0 @@ -addTags('html5video'); - $this->addAttributes('hls'); - $this->addAttributes('h264'); - $this->addAttributes('webm'); - - $this->addtags('html5youtube'); - $this->addAttributes('options'); - - } - - function html5video($params) { - $source = $params['html5video']; - - $defaults = array( - 'hls' => true, - 'h264' => true, - 'webm' => true - ); - $options = array_merge($defaults, $params); - - $baseurl = url('/video/'); - $posterurl = $baseurl . urlencode($source) . '-poster.png'; - - if ($options['hls'] == true) { - $hlsurl = $baseurl . urlencode($source) . '-hls/' . urlencode($source) . '-index.m3u8'; - $hlssource = '';} - else { - $hlssource = "";} - - if ($options['h264'] == true) { - $mp4url = $baseurl . urlencode($source) . '-h264.mp4'; - $mp4source = '';} - else { - $mp4source = "";} - - if ($options['webm'] == true) { - $webmurl = $baseurl . urlencode($source) . '-webm.webm'; - $webmsource = '';} - else { - $webmsource = "";} - - return ''; - } - - - function html5youtube($params) { - $videoID = $params['html5youtube']; - - $options = $params['options']; - - $base = 'https://www.youtube-nocookie.com/embed/'; - $end = '?rel=0&html5=1'; - - return '
'; - } - -} - -?> \ No newline at end of file