-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhtml5video.php
63 lines (52 loc) · 1.9 KB
/
html5video.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*
* kirbytag html5video
* html5 video player embedding for lazy people
*
* copyright: Jannik Beyerstedt | http://jannikbeyerstedt.de | code@jannikbeyerstedt.de
* license: http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License
*
* version 2.2 (31.05.2015)
* changelog:
* - v2.0: kirby 2 support
* - v2.1: fix broken default values
* - v2.2: autodetection for poster file
*/
kirbytext::$tags['html5video'] = array(
'attr' => array(
'hls',
'h264',
'webm'
),
'html' => function($tag) {
$source = $tag->attr('html5video');
$baseurl = url('/video/');
$posterurl = $baseurl . urlencode($source) . '-poster.png';
if ($tag->attr('hls') === null || strtolower($tag->attr('hls')) === 'true' ) {
$hlsurl = $baseurl . urlencode($source) . '-hls/' . urlencode($source) . '-index.m3u8';
$hlssource = '<source src="' . $hlsurl . '" type="application/x-mpegurl">';}
else {
$hlssource = "";}
if ($tag->attr('h264') === null || strtolower($tag->attr('h264')) === 'true' ) {
$mp4url = $baseurl . urlencode($source) . '-h264.mp4';
$mp4source = '<source src="' . $mp4url . '" type="video/mp4">';}
else {
$mp4source = "";}
if ($tag->attr('webm') === null || strtolower($tag->attr('webm')) === 'true' ) {
$webmurl = $baseurl . urlencode($source) . '-webm.webm';
$webmsource = '<source src="' . $webmurl . '" type="video/webm">';}
else {
$webmsource = "";}
if (file_exists($source . '-poster.png')) {
$postersource = 'poster="' . $posterurl . '"';
}else {
$postersource = '';
}
return '<video class=html5player controls="controls" ' . $postersource . ' preload="none">' .
$hlssource .
$mp4source .
$webmsource .
'Dein Browser kann HTML5-Video nicht. Nimm eine aktuelle Version. Your browser does not support the video tag, choose an other browser.' .
'</video>';
}
);