/    Sign up×
Community /Pin to ProfileBookmark

javascript media player

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>
[/code]

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 14.2006 — Considering that your post was viewed 1,076 times (but noone answered it), next time, if you really want "help" (instead of just wanting someone to do it for you), then perhaps you need to be more precise as to just what is the problem -- people don't like to play 20 questions in an attempt to find out more. You see, everybody that answers questions here are just visitors to this site -- as you were. Thus, you may "scare away" some people by coming across as expecting them to spend a lot of time researching your issue.

At any rate... Not to just constructively criticize, but to also offer help -- even though this perhaps comes months too late... The big unanswered question is, though, and which people really shouldn't have to ask, just what is the problem? You never said.

OK? Cheers.
Copy linkTweet thisAlerts:
@cwilkeyauthorApr 14.2006 — phpnovice,

Thanks for your "constructive criticizm". I post questions to this site in hopes that the issue that I'm having has either already been addressed or someone with more advanced knowledge can help. I apologize if I wasn't specific enough for you. Perhaps, you should disregard future posts that lack the specifics in which you require. Also bare in mind that many times when folks post to these boards they, myself included, don't have specifics. They just know what the end result should produce.

Ok? Cheers.
Copy linkTweet thisAlerts:
@Rmstn1580Apr 14.2006 — I'm having problems with Media Players too. Maybe something in my code could help you? The code doesn't work though, but maybe it could steer you in the right direction.

[url=http://www.webdeveloper.com/forum/showthread.php?t=103111]http://www.webdeveloper.com/forum/showthread.php?t=103111[/url]
Copy linkTweet thisAlerts:
@cwilkeyauthorApr 14.2006 — At first glance, you are missing a closing bracket so your script should look like this:
<i>
</i>&lt;script language="Javascript" type="text/javascript"&gt;
&lt;!--
var bolIsPlaying;
var intVolumeBarState=4;

function songPlay() {
objMediaPlayer.Play();
bolIsPlaying = true;
}

function songStop() {
objMediaPlayer.stop();
bolIsPlaying = false;
}

function videoPause() {
if(bolIsPlaying) {
objMediaPlayer.Pause();
}

function setVolume(intVolume) {
intVolume = ((intVolume-8)*1250);
objMediaPlayer.Volume=intVolume;
}

function volumeChange(strChangeDir) {
var strDiv="divVolumeBar";
var strEval;

if ((strChangeDir=="increase") &amp;&amp; (intVolumeBarState &lt; 8)) {
intVolumeBarState++;
}

if ((strChangeDir=="decrease") &amp;&amp; (intVolumeBarState &gt; 0)) {
intVolumeBarState--;
}
setVolume(intVolumeBarState);
}
}
//--&gt;
&lt;/script&gt;
Copy linkTweet thisAlerts:
@Rmstn1580Apr 14.2006 — How stupid could I be!?! BTW I think phpnovice is a bot if you haven't thought so already. I tend to know how to write the code, but I always make stupid mistakes.
Copy linkTweet thisAlerts:
@phpnoviceApr 14.2006 — I think phpnovice is a bot ...[/QUOTE]
Hah! Nope, not a robot -- just stiring up old unanswered posts to stimulate new concersations. Works real good, I see. ?
Copy linkTweet thisAlerts:
@Rmstn1580Apr 14.2006 — You seem to be annoying many people. Please stop.
Copy linkTweet thisAlerts:
@phpnoviceApr 14.2006 — Nope, there is no reason to stop. What I'm doing is within the rules of this site. Since all I am doing is telling the truth, and nicely at that, the only people that get annoyed must be those that don't like being told the truth.
Copy linkTweet thisAlerts:
@Rmstn1580Apr 14.2006 — Uh you're digging up discarded theads from 2005 and bringing them back. Sounds like you're trying to gain posts to me.
Copy linkTweet thisAlerts:
@phpnoviceApr 14.2006 — If they were discarded, I wouldn't be able to find them. Everything I say in my answers to these old posts you can find in the sticky threads at the top of this forum. I'm not saying anything new and I'm not just speaking my own opinion. The purpose for answering such old posts is so that people will get some idea of why their posts were not answered (since most people ignore the sticky threads anyway). Most also appreciate getting any answer at all -- even after many months. So, what is your problem?
Copy linkTweet thisAlerts:
@swtransApr 14.2006 — A month ago I was in the middle of a project and php gave me a hand ... easy on him
Copy linkTweet thisAlerts:
@stephen1davisApr 15.2006 — i don't see what's wrong with trying to gain posts by answering questions... isn't that what we're all doing?
×

Success!

Help @cwilkey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...