Menu

Streaming za NAT

28.3.2014 - Web

Potřebuji, aby jsem se mohl dívat na živý stream, který běží za routerem s dynamickou ip.

 

index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 </head>
 <body>

 <H3>Přehrávač</H3>

<?php
$File = "player-player1.txt";
$fh = fopen($File, 'r');
$Stream = fread($fh, filesize($File));
fclose($fh);
?>
 <div name="mediaspace" id="mediaspace"></div>
 <script type='text/javascript' src="silverlight.js"></script>
 <script type='text/javascript' src="wmvplayer.js"></script>
 <script type="text/javascript">
 var cnt = document.getElementById("mediaspace");
 var src = 'wmvplayer.xaml';
 var cfg = {
 file:'<?php echo $Stream; ?>',
 image:'preview.jpg',
 height:'240',
 width:'440'
 };
 var ply = new jeroenwijering.Player(cnt,src,cfg);
 </script>
</body>
</html>

 

nactienc.php
<?PHP

if ( isset($_SERVER["REMOTE_ADDR"]) )    { 
$ip=$_SERVER["REMOTE_ADDR"]; 
} else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) )    { 
$ip=$_SERVER["HTTP_X_FORWARDED_FOR"]; 
} else if ( isset($_SERVER["HTTP_CLIENT_IP"]) )    { 
$ip=$_SERVER["HTTP_CLIENT_IP"]; 
} 

$datum = StrFTime("%d.%m.%Y %H:%M:%S", Time());

$log="log.txt"; # log soubor - Must CHMOD to 666
$ID = $_GET['ID'];#$ip; #$_POST['theformfieldname']; # Form must use POST. if it uses GET, use the line below:
#$text = $_GET['theformfieldname']; #POST is the preferred method
#
$fp = fopen ($log, "a"); # w = write to the file only, create file if it does not exist, discard existing contents
if ($fp) {
fwrite ($fp, $ID." ".$ip." ".$datum."\n");
fclose ($fp);
echo ("log Ok\n");
}
else {
echo ("log Problem\n");
}

$fp = fopen ("player-".$ID.".txt", "w"); # w = write to the file only, create file if it does not exist, discard existing contents
if ($fp) {
fwrite ($fp, "mms://".$ip.":8888"); #zapise adresu na prehravac mms:// :8888
fclose ($fp);
echo ("playlist ".$ID." zapsan\n");
}
else {
echo ("playlist ".$ID." problem\n");
}

 ?>