Greetings. I looking for a way to tie in dynamically generated (php) videos into a media player using javascript. I’ve got a start but need a little help cleaning it up. Can someone take a look?
[code]
<SCRIPT LANGUAGE = “JavaScript”>
var streams = new Array();
<?php
for($i = 0; $i <= $totalRows_VideoBites; $i++) {
do {
$title = $row_VideoBites[‘title’];
$link = $row_VideoBites[‘video’];
?>
streams[<?php echo $i++ ?>] = new makeStream(“http://proto.wvva.com/Video/<?php echo $link ?>”, “<?php echo $title ?>”);
<?php
} while ($row_VideoBites = mysql_fetch_assoc($VideoBites));
}
?>
function makeStream(url, name) {
this.url = url;
this.name = name;
}
function handleControlsOnOffClick() {
if (document.mediaPlayer.showControls == true) {
document.mediaPlayer.showControls = false;
document.playerCtrl.controls.value = ” Show Controls “;
}
else {
document.mediaPlayer.showControls = true;
document.playerCtrl.controls.value = ” Hide Controls ”
}
}
function handlePlayOrPauseClick(){
var state;
playerStatus = document.mediaPlayer.playState;
if (playerStatus == 6) {
document.mediaPlayer.play();
document.playerCtrl.playOrPause.value = ” Pause “;
}
else if (playerStatus == 1) {
document.mediaPlayer.play();
document.playerCtrl.playOrPause.value = ” Pause “;
}
else if (playerStatus == 2) {
document.mediaPlayer.pause();
document.playerCtrl.playOrPause.value = ” Play “;
}
}
function changeSize(newSize) {
document.mediaPlayer.displaySize = newSize;
}
function change() {
var list = document.playerCtrl.streams;
var streamURL = list.options[list.selectedIndex].value;
document.playerCtrl.playOrPause.value = ” Pause “;
document.mediaPlayer.fileName = streamURL;
}
</SCRIPT>
</HEAD>
<BODY LEFTMARGIN = “100”>
<h3>Doc JavaScript’s Streaming Media JukeBox</h3><P><P><HR><P>
<OBJECT
ID=”mediaPlayer”
CLASSID=”CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95″
CODEBASE=”http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701″
STANDBY=”Loading Microsoft Windows Media Player components…”
TYPE=”application/x-oleobject”>
<PARAM NAME=”fileName” VALUE=”http://msdn.microsoft.com/downloads/samples/Internet/imedia/netshow/smedia/NS3/JavaScript/Buttons/control.asx”>
<PARAM NAME=”animationatStart” VALUE=”true”>
<PARAM NAME=”transparentatStart” VALUE=”true”>
<PARAM NAME=”autoStart” VALUE=”true”>
<PARAM NAME=”showControls” VALUE=”true”>
</OBJECT><P>
<FORM NAME=”playerCtrl”>
<INPUT TYPE=”button” VALUE=” Pause ” NAME=”playOrPause” onClick=”handlePlayOrPauseClick()” STYLE = “font-family:courier”>
<INPUT TYPE=”button” VALUE=” Hide Controls ” NAME=”controls” onClick=”handleControlsOnOffClick()” STYLE = “font-family:courier”><BR>
<INPUT TYPE=”button” VALUE=” Small ” NAME=”small” onclick=”changeSize(1)” STYLE=”font-family:courier”>
<INPUT TYPE=”button” VALUE=” Normal ” NAME=”normal” onclick=”changeSize(0)” STYLE=”font-family:courier”>
<INPUT TYPE=”button” VALUE=” Large ” NAME=”large” onclick=”changeSize(2)” STYLE=”font-family:courier”><BR><BR>
<SCRIPT LANGUAGE=”JavaScript”>
with (document) {
writeln(‘<SELECT NAME=”streams” onChange=”change()”>’);
for (var i = 0; i < streams.length; i++) {
writeln(‘<OPTION VALUE=”‘, streams[i].url, ‘”>’, streams[i].name);
}
writeln(‘</SELECT>’);
}
</SCRIPT>