-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.php
97 lines (83 loc) · 3.29 KB
/
player.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
//page init
require_once "loader.php";
//array to store the markers...
$markers = array();
//grab the full filepath...
$name = addslashes(ltrim(urldecode(str_replace("..", "", $_GET['name'])),"/"));
$type = $_GET['type'];
$title = urldecode($_GET['name']);
preg_match('/\.[0-9A-Za-z]{3}$/',basename($name),$matched);
$video_title = explode($matched[0],basename($name))[0];
//for multiuser support we use client ip and chosen file
$params['uid'] = md5($_SERVER['REMOTE_ADDR'].$_GET['file']);
//commandline testing if we got our rtmp stream running or not
$cmd = buildCmd($params,$commands['ps_get']);
$name_cmd = exec($cmd);
$filename = preg_replace("/[^a-z0-9\_\-\.]/","",strtolower($video_title));
//reading out the duration of a clip to have a scrollbar...
$data = file_get_contents($meta_dir.$filename.".txt");
if($m != ""){
$m->set('data',$data);
$data = $m->get('data');
}
preg_match("#Duration: (.+), start#",$data,$duration);
$parsed = date_parse(trim($duration[1]));
$seconds = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
//check if we are streaming or not streaming...
if($name_cmd == ""){
$name_cmd = $name;
} else {
$name_cmd = $params['uid'];
}
/* global vars possible to set... */
$style = "";
$headscript = "";
$tag = "<div id=\"css-poster\" class=\"player minimalist is-splash\" data-rtmp=\"rtmp://".
$crtmpserver.":".
$crtmp_out_port."/flvplayback\" data-engine=\"flash\"><video id=\"container1\" class=\"player projekktor\" poster=\"".
$thumbs_dir.$filename."_thumb.png\" data-engine=\"html5\" width=\"".$width."\" height=\"".
$height."\" title=\"".$title."\" controls>";
/* global definitions for all other players but flowplayer */
if($name_cmd == $params['uid']){
$long_src = "rtmp://".$crtmpserver.":".$crtmp_out_port."/flvplayback/".$name_cmd;
$short_src = $name_cmd;
$default_src = "rtmp://".$crtmpserver.":".$crtmp_out_port."/flvplayback/".$name_cmd;
$tag .= "<source type=\"".$type."\" src=\"".$long_src."\"/>";
/* load the desired player */
if($player == "clappr" || !isset($player)){
include_once $webroot."/players/clappr/player.php";
$clappr_tag = '<div id="container1"></div>';
} else {
include_once $webroot."/players/".$player."/player.php";
}
} else {
$contentscript = "";
$long_src = "http://".$storageserver.":".$storageport."/".$name_cmd;
$short_src = $long_src;
$default_src = $long_src;
$tag .= "<source type='".$type.";codecs=\"".$codecs[$type]."\"' src=\"".$long_src."\" autobuffer controls preload=\"auto\"/>";
}
$tag .= "</video></div>";
//special case for clappr player, cause he hates the video tag
//in this version...
if(($player == "clappr" || !isset($player)) && $name_cmd == $params['uid'])
{
$tag = $clappr_tag;
}
//combining all the above...
$markers['players_content_script'] = $contentscript;
$markers['players_scripts'] = $headscript;
$markers['players_content_tag'] = $tag;
$markers['title'] = $title;
$markers['video_title'] = $video_title;
$markers['js_dir'] = $js_dir;
$markers['main_style'] = $style_main;
$markers['players_styles'] = $style;
//choose a template file...
$tpl_file = "templates/player.html";
/* writing our template */
header('X-Content-Duration: '.$seconds);
echo templating($tpl_file,$markers);
$out = ob_get_contents();
ob_end_flush();