1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00
octonet/octoserve/var/www/browsertv.html

455 lines
13 KiB
HTML
Raw Normal View History

2015-08-05 22:22:06 +02:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OctopusNet</title>
<link rel="stylesheet" type="text/css" href="/style.css">
<script type="text/javascript" src="/menu.js"></script>
<!-- Add included scripts here -->
<script type="text/javascript" src="/systeminfo.lua"></script>
<script type="text/javascript">Octoserve = false;</script>
<script type="text/javascript" src="/octoserve/serverinfo.js"></script>
<!-- Add page scripts here -->
<script type="text/javascript">
var VLCPluginValid = false;
var VLCPlugin;
var RTSPLink = false;
var UseAudioPids = true;
2015-08-05 22:22:06 +02:00
if( browserType == "Netscape" )
{
if( browserPlatform == "ipad" )
{
RTSPLink = true;
}
else
{
for(var i = 0; i < navigator.plugins.length; i++ )
{
var t = navigator.plugins[i].name + " " + navigator.plugins[i].version;
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
if( navigator.plugins[i].name == "VLC Web Plugin" )
{
VLCPlugin = navigator.plugins[i];
if( browserPlatform == "win" )
{
if( navigator.plugins[i].version >= "2.0.6.0" ) VLCPluginValid = true;
if( navigator.plugins[i].version >= "2.2.0.0" ) UseAudioPids = false;
2015-08-05 22:22:06 +02:00
}
else if( browserPlatform == "linux" )
{
VLCPluginValid = true;
}
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
break;
}
}
}
}
var CurTracks = new Array();
var SelectedSource = 0;
var SelectedChannel = 0;
var SourceList = new Array();
function PlayEvent()
{
// var vlc = document.getElementById("vlcplayer");
// var vlc = getVLC("vlcplayer");
var vlc = vlcplayer;
var options = new Array();
var t = "rtsp://"+host+"/"+this.PlayRequest;
vlc.playlist.clear();
var id = vlc.playlist.add(t, this.PlayName, options);
vlc.playlist.playItem(id);
CurTracks = this.PlayTracks;
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
document.getElementById("nowplaying").firstChild.nodeValue = this.PlayName;
document.getElementById("ac0").disabled = CurTracks.length < 1;
document.getElementById("ac1").disabled = CurTracks.length < 2;
document.getElementById("ac2").disabled = CurTracks.length < 3;
document.getElementById("ac3").disabled = CurTracks.length < 4;
}
function SetAudioChannel(ac)
{
var vlc = vlcplayer;
if( ac < CurTracks.length ) vlc.audio.track = UseAudioPids ? CurTracks[ac] : ac + 1;
2015-08-05 22:22:06 +02:00
}
function MuteAudio()
{
var vlc = vlcplayer;
vlc.audio.mute = !vlc.audio.mute;
}
function AddRow(table,name,request,tracks)
{
var row = document.createElement("tr");
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
var col = document.createElement("td");
var txt = document.createTextNode(name);
col.appendChild(txt);
row.appendChild(col);
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
col = document.createElement("td");
if( RTSPLink )
{
var t = "rtsp://"+host+"/"+request;
var a = document.createElement("a");
a.setAttribute("href",t);
2016-01-11 19:17:48 +01:00
a.appendChild(document.createTextNode("Play"));
2015-08-05 22:22:06 +02:00
col.appendChild(a);
}
else
{
var form = document.createElement("form");
form.setAttribute("action", "");
var field = document.createElement("input");
field.setAttribute("type", "button");
field.setAttribute("value", "Play");
//field.setAttribute("onclick", "Play("+name+","+request+")");
//field.onclick = "Play("+name+","+request+")";
field.PlayName = name;
field.PlayRequest = request;
field.PlayTracks = tracks;
field.addEventListener("click",PlayEvent);
2016-01-11 19:17:48 +01:00
form.appendChild(field);
2015-08-05 22:22:06 +02:00
col.appendChild(form);
}
row.appendChild(col);
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
table.appendChild(row);
}
// function TitleCompare(a,b)
// {
// if( a.Title.toUpperCase() < b.Title.toUpperCase() ) return -1;
// if( a.Title.toUpperCase() > b.Title.toUpperCase() ) return 1;
// return 0;
// }
2015-08-05 22:22:06 +02:00
2016-01-11 19:17:48 +01:00
var xmlhttp = new XMLHttpRequest();
var url = "/channellist.lua?select=json";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState == 4 )
{
if( xmlhttp.status == 200 )
myFunction(xmlhttp.responseText);
}
}
var hasCable = false;
var hasSat = false;
var hasTer = false;
var LastSourceName = "";
var LastChannelName = "";
function myFunction(response) {
var ChannelList = JSON.parse(response);
var LastSource = 0;
var Index = 0;
if(typeof(Storage) !== "undefined")
{
try
{
LastSourceName = localStorage.getItem("LastSourceName");
LastChannelName = localStorage.getItem("LastChannelName");
if( !LastSourceName ) LastSourceName = "";
if( !LastChannelName ) LastChannelName = "";
}
catch(e)
{
}
}
document.Source.Select.length = 0;
for(var i = 0; i < ChannelList.GroupList.length; i++)
{
var newChannelList = new Array();
for(var j = 0; j < ChannelList.GroupList[i].ChannelList.length; j++ )
{
if( ( hasSat && ChannelList.GroupList[i].ChannelList[j].Request.indexOf("dvbs") > 0 ) ||
( hasCable && ChannelList.GroupList[i].ChannelList[j].Request.indexOf("dvbc") > 0 ) ||
( hasTer && ChannelList.GroupList[i].ChannelList[j].Request.indexOf("dvbt") > 0 ) )
{
newChannelList.push(ChannelList.GroupList[i].ChannelList[j]);
}
}
if( newChannelList.length > 0 )
{
SourceList[Index] = new Object();
SourceList[Index].ChannelList = newChannelList;
SourceList[Index].Title = ChannelList.GroupList[i].Title;
document.Source.Select.options[Index] = new Option(SourceList[Index].Title,Index, false, true);
if( LastSourceName.length > 0 )
{
if( LastSourceName == SourceList[Index].Title ) LastSource = Index;
}
Index = Index + 1;
}
}
// for(var i = 0; i < SourceList.length; i++ )
// {
// SourceList[i].ChannelList.sort(TitleCompare);
// }
2016-01-11 19:17:48 +01:00
document.Source.Select.selectedIndex = LastSource;
SetSource(LastSource);
}
2015-08-05 22:22:06 +02:00
function OnLoad()
{
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
if( !RTSPLink )
{
document.getElementById("Play").style.display = "none";
}
if( VLCPluginValid || RTSPLink )
{
for(var i = 0; i < Octoserve.TunerList.length; i++ )
{
if( Octoserve.TunerList[i] )
{
if( Octoserve.TunerList[i].Desc.indexOf("C/T") >= 0 ) hasCable = true;
if( Octoserve.TunerList[i].Desc.indexOf("C/C2") >= 0 ) hasCable = true;
if( Octoserve.TunerList[i].Desc.indexOf("S/S2") >= 0 ) hasSat = true;
}
}
2016-01-11 19:17:48 +01:00
// TODO: differentiate between dvbc and dvbt
hasTer = hasCable;
xmlhttp.open("GET", url, true);
xmlhttp.send();
2015-08-05 22:22:06 +02:00
}
else
{
document.getElementById("channeltable").style.display = "none";
}
}
function CreatePlugin()
{
document.getElementById("ControlPlugin").style.display = "none";
if( browserType == "Netscape" )
{
if( RTSPLink )
{
document.write('NOTE: Requires VLC App or similar with RTSP support');
return;
}
else if( VLCPlugin && !VLCPluginValid )
{
document.write("Invalid VLC Plugin found: "+ VLCPlugin.version + "<br/>" + browserPlatform + "<br/>");
document.write('Check for new Version on <a href="http://www.videolan.org">VLC Mediaplayer</a>');
return;
}
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
if( VLCPluginValid )
{
document.getElementById("ControlPlugin").style.display = "block";
document.write('<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" width="640" height="480" id="vlcplayer">');
document.write('</embed>');
}
else
{
if ( browserPlatform == "win" || browserPlatform == "linux" )
{
document.write('Install <a href="http://www.videolan.org">VLC Mediaplayer</a> for in Browser TV');
}
}
}
else if (browserType == "MSIE" )
{
document.write('Install <a href="http://www.mozilla.org">Firefox</a> and <a href="http://www.videolan.org">VLC Mediaplayer</a> for in Browser TV:&nbsp');
return;
}
}
function SetSource(SourceIndex)
{
SelectedSource = SourceIndex;
2016-01-11 19:17:48 +01:00
if( SourceList[SourceIndex].Title != LastSourceName )
{
LastSourceName = SourceList[SourceIndex].Title;
LastChannelName = "";
if(typeof(Storage) !== "undefined")
{
try
{
localStorage.setItem("LastSourceName",LastSourceName);
}
catch(e)
{
}
}
}
2015-08-05 22:22:06 +02:00
document.Channel.Select.length = 0;
var i = -1;
for( j = 0; j < SourceList[SourceIndex].ChannelList.length; j++ )
{
2016-01-11 19:17:48 +01:00
document.Channel.Select.options[j] = new Option(SourceList[SourceIndex].ChannelList[j].Title,j, false, true);
if( i < 0 )
{
if( LastChannelName.length > 0 )
{
if( SourceList[SourceIndex].ChannelList[j].Title == LastChannelName ) i = j;
}
else
{
if( SourceList[SourceIndex].ChannelList[j].Title.toUpperCase() >= "DAS ERSTE" ) i = j;
}
}
}
2015-08-05 22:22:06 +02:00
if( i < 0 ) i = 0;
document.Channel.Select.selectedIndex = i;
SetChannel(i);
}
function SetChannel(ChannelIndex)
{
SelectedChannel = ChannelIndex;
2016-01-11 19:17:48 +01:00
if( SourceList[SelectedSource].ChannelList[ChannelIndex].Title != LastChannelName )
{
LastChannelName = SourceList[SelectedSource].ChannelList[ChannelIndex].Title;
if(typeof(Storage) !== "undefined")
{
try
{
localStorage.setItem("LastChannelName",LastChannelName);
}
catch(e)
{
}
}
}
2015-08-05 22:22:06 +02:00
var a = document.getElementById("Play");
if( RTSPLink )
{
2016-01-11 19:17:48 +01:00
var t = "rtsp://"+host+"/"+SourceList[SelectedSource].ChannelList[ChannelIndex].Request;
a.href = t;
2015-08-05 22:22:06 +02:00
}
else
{
2016-01-11 19:17:48 +01:00
var t = "rtsp://"+host+"/"+SourceList[SelectedSource].ChannelList[ChannelIndex].Request;
2015-08-05 22:22:06 +02:00
var vlc = vlcplayer;
var options = new Array();
vlc.playlist.clear();
2016-01-11 19:17:48 +01:00
var id = vlc.playlist.add(t, SourceList[SelectedSource].ChannelList[ChannelIndex].Title, options);
2015-08-05 22:22:06 +02:00
vlc.playlist.playItem(id);
2016-01-11 19:17:48 +01:00
CurTracks = SourceList[SelectedSource].ChannelList[ChannelIndex].Tracks;
document.getElementById("nowplaying").firstChild.nodeValue = SourceList[SelectedSource].ChannelList[ChannelIndex].Title;
2015-08-05 22:22:06 +02:00
document.getElementById("ac0").disabled = CurTracks.length < 1;
document.getElementById("ac1").disabled = CurTracks.length < 2;
document.getElementById("ac2").disabled = CurTracks.length < 3;
document.getElementById("ac3").disabled = CurTracks.length < 4;
}
}
</script>
</head>
<body onload="OnLoad()">
<table class="maintable" align="center">
<colgroup>
<col width="182px"/>
<col width="728px"/>
</colgroup>
<tr><td class="maintd" colspan="2">
<a href="http://www.digitaldevices.de"><img src="/BannerDD.jpg" alt="DD" width="910" height="130" /></a>
</td></tr>
<tr><td class="maintd" colspan="2">&nbsp;</td></tr>
<tr>
<td class="maintd"><script type="text/javascript">CreateMenu();</script></td>
<td class="content">
<div>
<!-- Begin Content -->
<table cellpadding="2px" align="center">
<tr><td>
2016-01-11 19:17:48 +01:00
<div id="ControlPlugin">
2015-08-05 22:22:06 +02:00
<table width="100%">
<tr>
<td><div align="left" id="nowplaying">&nbsp;</div></td>
<td><div align="right">
<form action="">
Audio:&nbsp;
<input id="ac0" type="Button" Value="1" onclick="SetAudioChannel(0)"/>
<input id="ac1" type="Button" Value="2" onclick="SetAudioChannel(1)"/>
<input id="ac2" type="Button" Value="3" onclick="SetAudioChannel(2)"/>
<input id="ac3" type="Button" Value="4" onclick="SetAudioChannel(3)"/>
<input type="Button" Value="Mute" onclick="MuteAudio()"/>
</form>
</div></td>
</tr>
</table>
</div>
</td></tr>
<tr><td>
2016-01-11 19:17:48 +01:00
<script type="text/javascript">CreatePlugin();</script></td>
2015-08-05 22:22:06 +02:00
</td></tr>
<tr><td>
2016-01-11 19:17:48 +01:00
<div id="channeltable">
2015-08-05 22:22:06 +02:00
<table cellpadding="2px" align="center">
<tr>
<td>Source</td>
<td>
<form name="Source" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetSource(document.Source.Select.selectedIndex)" >
</select>
</form>
</td>
</tr>
<tr>
<td>Channel</td>
<td>
<form name="Channel" action="">
<select name="Select" size="1" style="width: 300px" onchange="SetChannel(document.Channel.Select.selectedIndex)">
</select>
</form>
</td>
</tr>
</table>
</div>
</td></tr>
<tr><td>
2016-01-11 19:17:48 +01:00
<div id="playlink" align="center" >
2015-08-05 22:22:06 +02:00
<a id="Play" href="">Play</a>
</div>
</td></tr>
</table>
2016-01-11 19:17:48 +01:00
2015-08-05 22:22:06 +02:00
<!-- End Content -->
</div>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
</table>
</body>
</html>