Hi There,
I wonder if anyone would be so kind as to help me with javascript code that i cannot seem to understand. I’m trying to write a media player that works cross browser and cross platform. I’m trying to embed windows media player and effectively creating my own skin.
[URL=”http://www.hydrate.org.uk/soundlab/”]http://www.hydrate.org.uk/soundlab/
Origionaly I was checking the browser and platform on the player.php which was invoked by the index.php – Now i’m trying to do the tests before player.php opens via Launch_Player.js
player_open(file_to_open) // This function invokes 2 functions which retrieve
the browser and platform (Get_Browser_Platform(vpass); + _Get_Info(vpass, file_to_open)?
The intended outcome is to retrieve the relevant code for the player then open a new window and print the HTML for player.php
the js file is embedded within the <head> tags as follows (4 js files are also present)
[QUOTE]
<script language=”JavaScript” src=”javascript/Launch_Player.js” ></script>
and the code that invokes the function is (echo’d by php)
[QUOTE]
echo “<a href=”index.php?addtrack=audio/” . $file . “” style=’cursor:pointer;’ onclick=”javascript:player_open(“audio/” . $file . “”); return false” onmouseover=’javascript : starttimer2(“$n”)’ onmouseout=’javascript : stoptimer2(“$n”)’><h5 id=’tune$n’ class=’tune’>$track_full_name</h5></a>”;
Please go easy on me as I’m new to javascript (newbie)
Thanks for any help in advance
—– Launch_Player.js ———
[CODE]
// JavaScript Document
function _Get_Info(x,track)
{
switch (x)
{
case 0:
break;
case 1:
break;
case 4:
break;
}
switch (_platform)
{
case 3:
// functions to place player html into Player and return to player_open
break;
}
return Player;
}
function Get_Browser_Platform(x)
{
if (-1 != navigator.userAgent.indexOf(‘MSIE’))
{
if (-1 != navigator.userAgent.indexOf(‘MSIE 8’))
{x = 0;}
else if (-1 != navigator.userAgent.indexOf(‘MSIE 7’))
{x = 7;}
else if (-1 != navigator.userAgent.indexOf(‘MSIE 6’))
{x = 8;}
else
{x = 9;}
}
else if (-1 != navigator.userAgent.indexOf(‘Firefox’))
{x = 1;}
else if (-1 != navigator.userAgent.indexOf(‘Chrome’))
{x = 2;}
else if (-1 != navigator.userAgent.indexOf(‘Opera’))
{x = 3;}
else if (-1 != navigator.userAgent.indexOf(‘Safari’))
{x = 4;}
else if (-1 != navigator.userAgent.indexOf(‘Konqueror’))
{x = 5;}
else if (-1 != navigator.userAgent.indexOf(‘Epiphany’))
{x = 6;}
return x;
}
function player_open(file_to_open)
{
var vpass;
Get_Browser_Platform(vpass) return true;
_Get_Info(vpass, file_to_open) return true;
PlayerWin = window.open(”,’_blank’,’width=202,height=302,top=0,left=0,screenX=0,screenY=0,resizable=1,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0′);
PlayerWin.document.writeln(‘<?php’);
PlayerWin.document.writeln(‘session_start();’);
PlayerWin.document.writeln(‘?>’);
PlayerWin.document.writeln(‘<html>’);
PlayerWin.document.writeln(‘<head>’);
PlayerWin.document.writeln(‘<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />’);
PlayerWin.document.writeln(‘<title>Sound Lab Media Player</title>’);
PlayerWin.document.writeln(‘<link href=”css/style.css” rel=”stylesheet” type=”text/css” />’);
PlayerWin.document.writeln(‘<link href=”css/slider.css” rel=”stylesheet” type=”text/css” />’);
PlayerWin.document.writeln(‘<script language=”JavaScript” src=”javascript/slider.js” ></script>’);
PlayerWin.document.writeln(‘<script language=”JavaScript” src=”javascript/player.js” ></script>’);
PlayerWin.document.writeln(‘<script language=”JavaScript” src=”javascript/user_detail.js” ></script>’);
PlayerWin.document.writeln(‘<script type=”text/javascript”>’);
PlayerWin.document.writeln(‘var Tunes = new Array();’);
PlayerWin.document.writeln(‘var platform = 0;’);
PlayerWin.document.writeln(‘var browser = 0;’);
PlayerWin.document.writeln(‘var _Playlist;’);
PlayerWin.document.writeln(‘var media;’);
PlayerWin.document.writeln(‘var x;’);
PlayerWin.document.writeln(‘var y;’);
PlayerWin.document.writeln(‘var start_track = “‘ + file_to_open + ‘”;’);
PlayerWin.document.writeln(‘<?php’);
PlayerWin.document.writeln(‘echo “var total = new Number(“. $_SESSION[‘track_count’] .”);nn”;’);
PlayerWin.document.writeln(‘?>’);
PlayerWin.document.writeln(‘function Load_Player(){‘);
PlayerWin.document.writeln(‘x = document.getElementById(‘Media_Player’));’);
PlayerWin.document.writeln(‘_pre_Load(x);’);
PlayerWin.document.writeln(‘var n = 0; ‘);
PlayerWin.document.writeln(‘while (n < total){‘);
PlayerWin.document.writeln(‘<?php’);
PlayerWin.document.writeln(‘$n = $_SESSION[‘track_count’];’);
PlayerWin.document.writeln(‘for($i=0;$i<$n;$i++){‘);
PlayerWin.document.writeln(‘echo “media = x.newMedia(‘” . $_SESSION[‘track’.$i] . “‘);n”;’);
PlayerWin.document.writeln(‘echo “Tunes[” . $i . “] = ‘” . $_SESSION[‘track’.$i] . “‘;n”;’);
PlayerWin.document.writeln(‘echo “x.currentPlaylist.appendItem(media);”;}’);
PlayerWin.document.writeln(‘?>’);
PlayerWin.document.writeln(‘n++;}’);
PlayerWin.document.writeln(‘y = x.currentPlaylist.count;’);
PlayerWin.document.writeln(‘document.getElementById(‘Track_len’).innerHTML = y;’);
PlayerWin.document.writeln(‘</script>’);
PlayerWin.document.writeln(‘</head>’);
PlayerWin.document.writeln(‘<body onLoad=”_Get_Browser(start_track); _Get_OS(); _Get_Info(); Load_Player();”>’);
PlayerWin.document.writeln(‘<div style=”position:absolute; width:200px; height:300px; left:0px; top:0px; border:solid thin #FFFFFF;”>’);
PlayerWin.document.writeln(‘<p id=”Display” style=”font-size:10px;”></p>’);
PlayerWin.document.writeln(‘<p id=”Slider_val” style=”font-size:10px;”></p>’);
PlayerWin.document.writeln(‘<p id=”Track_len” style=”font-size:10px;”></p>’);
PlayerWin.document.writeln(‘<p id=”On_Off” style=”font-size:10px;”></p> <br />’);
PlayerWin.document.writeln(‘<p id=”browser_P” style=”font-size:10px;”>Browser</p><br /> ‘);
PlayerWin.document.writeln(‘<p id=”platform_P” style=”font-size:10px;”>Platform</p>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”Initialize()” value=”Play”>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”stop_player()” value=”Stop”>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”VolumeUp()” value=”+”>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”VolumeDown()” value=”-“>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”Rewind()” value=”<<“>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”FastForward()” value=”>>”>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”javascript:PlayerObj.controls.next();” value=”Next”>’);
PlayerWin.document.writeln(‘<input class=”textbox” type=”button” onClick=”javascript:PlayerObj.controls.previous();” value=”Previous”>’);
PlayerWin.document.writeln(‘<div class=”horizontal_track” id=”horizontal_track_1″ >’);
PlayerWin.document.writeln(‘<div class=”horizontal_slit” id=”horizontal_slit_1″ > </div>’);
PlayerWin.document.writeln(‘<div class=”horizontal_slider” id=”horizontal_slider_1″ style=”left: 0px;”‘);
PlayerWin.document.writeln(‘onmousedown=”stop_adjust(); slide(event, ‘horizontal’, 100, 0, 100, 101, 0, ‘value_display_1’);” > </div></div> ‘);
PlayerWin.document.writeln(‘<div class=”display_holder” >’);
PlayerWin.document.writeln(‘<input id=”value_display_1″ class=”value_display” type=”text”
value=”0″ onFocus=”blur(this);” /></div>’);
PlayerWin.document.writeln(‘</div>’);
PlayerWin.document.writeln(‘<div id=”Player_Holder” style=”display:none”>’);
PlayerWin.document.writeln(vpass);
PlayerWin.document.writeln(‘</div></body></html>’);
PlayerWin.focus();
PlayerWin.document.close();
}