summaryrefslogtreecommitdiff
path: root/pages/vlc.ecpp
blob: 6245c90c7161b6b73c255d0982edba30f52df60f (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<%pre>
#include <vdr/channels.h>
#include <vdr/i18n.h>
#include <vdr/keys.h>
#include "setup.h"
#include "tools.h"

using namespace std;
using namespace vdrlive;

</%pre>
<%args>
	tChannelID channel;
	string async;
</%args>
<%session scope="global">
	bool logged_in(false);
</%session>
<%request scope="page">
	cChannel* Channel;
</%request>
<%include>page_init.eh</%include>
<%cpp>
	if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");

	pageTitle = tr("VLC: live video stream");

	bool asyncReq = !async.empty() && (lexical_cast<int>(async) != 0);

	ReadLock channelsLock(Channels);

	if (!channelsLock) {
		throw HtmlError(tr("Couldn't aquire access to channels, please try again later."));
	}
	Channel = Channels.GetByChannelID(channel);
	if (Channel == 0) {
		throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") );
	}
</%cpp>
<& pageelems.doc_type &>
<html>
	<head>
		<title>VDR-Live - <$ pageTitle $></title>
		<& pageelems.stylesheets &>
<%cpp>
	if (!asyncReq) {
</%cpp>
		<& pageelems.ajax_js &>
<%cpp>
	}
	else {
</%cpp>
		<script type="text/javascript" src="js/mootools/mootools.v1.11.js"></script>
<%cpp>
	}
</%cpp>
		<script type="text/javascript" src="js/live/vlc.js"></script>
		<script type="text/javascript"><!--
			var vlcControl = new VLC("video1", {
					<? !asyncReq ? "autoresize: false" ?>
				});
			vlcControl.addEvent('toggle', function(id, state){
					var text = null;
					switch (id) {
					case "TogglePlay":
						text = state ? "<$ tr("Stop") $>" : "<$ tr("Play") $>";
						break;
					case "ToggleMute":
						text = state ? "<$ tr("Sound on") $>" : "<$ tr("Sound off") $>";
						break;
					}
					if (text)
						$(id).setHTML(text);
				});
		--></script>
	</head>
	<body>
<%cpp>
	if (!asyncReq) {
</%cpp>
		<& pageelems.logo &>
		<& menu active="vlc" &>
		<div class="inhalt">
<%cpp>
	}
</%cpp>
<%cpp>
	if ( Channel != 0 ) {
		int streamdevPort = LiveSetup().GetStreamdevPort();
#ifdef TNTVERS7
		string server = request.getHost();
		server = server.substr(0, server.rfind(':'));
#else
		string server = request.getServerIp();
#endif
		string videourl = string("http://") + server + ":" + lexical_cast<string,int>(streamdevPort) + "/" + LiveSetup().GetStreamdevType() + "/" + *Channel->GetChannelID().ToString();
</%cpp>
			<embed type="application/x-vlc-plugin" id="video1" name="video1" autoplay="yes" loop="no" width="720" height="576" target="<$ videourl $>" />
	   		<& vlc.controls videourl=(videourl) asyncReq=(asyncReq) &>
<%cpp>
	}
	if (!asyncReq) {
</%cpp>
		</div>
<%cpp>
	}
</%cpp>
	</body>
</html>
<%include>page_exit.eh</%include>

<%def controls>
<%args>
	string videourl;
	bool asyncReq;
</%args>
<div id="vlcControls">
	<button id="TogglePlay" type="button" class="green"><$ tr("Stop") $></button>
	<button id="ToggleMute" type="button" class="red"><$ tr("Sound off") $></button>
	<button id="FullScreen" type="button" class="blue"><$ tr("Fullscreen") $></button>
<%cpp>
	if (asyncReq) {
</%cpp>
	<button id="Close" type="button" class="yellow"><$ tr("Close") $></button>
<%cpp>
	}
</%cpp>
<!-- --><p><$ tr("VLC media URL") $>: <$ videourl $></p><!-- -->
</div>
</%def>