Forum Moderators: open

Message Too Old, No Replies

Firefox and windows media player - video from an onclick

         

webmannw

9:34 am on Jan 18, 2005 (gmt 0)

10+ Year Member



Hi all,

I have embedded windows media player (10) in a web page and while it works fine in IE and Netscape 7.2, the video player doesn't appear at all in Opera, Mozilla or Firefox. The code I am using to embed is:

<object width="250" height="230" id="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" >
<param name="URL" value=" " />
<param name="captioningID" value="cc" />
<param name="AutoStart" value="true" />
<param name="AutoRewind" value="true" />
</object>

The video to be played is actually pased to the medi aplayer by a javascript function but I have checked and its working ok.

I have also checked that the relevant plug-ins are installed but still to no avail.

Can anyone help?

Thanks

webmannw

2:48 pm on Jan 18, 2005 (gmt 0)

10+ Year Member



Hi again,

After some digging around i realised that i needed the EBMED tag as well as the OBJECT tag. So now I can see WMP in Firefox, Opera and Mozilla using the following:

<object width="250" height="230" id="Player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" >
<param name="URL" value=" " />
<param name="captioningID" value="cc" />
<param name="AutoStart" value="true" />
<param name="AutoRewind" value="true" />
<embed type="application/x-mplayer2"
pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"
id="Player"
name="URL"
value=" "
width="250"
height="240"
autostart="false">
</embed>
</object>

BUT!....

I am playing the video files via a javascript function :

function Play( videoFile )
{
document.getElementById("Player").URL = videoFile;
}

which is triggered by an onclick:

onclick="Play('introduction.wvx');">

The trouble is that 'OBJECT' uses '<param name="URL" value=" " />' and 'EMBED' uses 'src=" "'

Any idea how I can populate the src=" " with the same value as the <param name="URL" value=" " />?

Hope this is clear to someone!

Thanks

BlobFisk

4:54 pm on Jan 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about giving the <object> and <embed> 2 different id's and use the same function to set both:


function Play( videoFile )
{
document.getElementById("objectID").URL = videoFile;
document.getElementById("embedID").SRC = videoFile;
}

I'm not sure if this will work at all though as the only embedded object that I've accessed using JavaScript are Java applets....

webmannw

9:11 am on Jan 19, 2005 (gmt 0)

10+ Year Member



Thanks for the tip!

Tried it but unfortunatley didn't seem to do the trick and it throws up a runtime error in IE :-(

The issue seems to be the difference between these two lines:

<param name="URL" value=" " /> in the <object> section.

src=" " in the <embed> section

I guess I need to pass the value from 'document.getElementById("Player").URL = videoFile' in the Play() function to both the <object> and <embed>.

Any thoughts whould be appreciated.

Thnaks again.

BlobFisk

9:17 am on Jan 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm clutching at straws here but how about:

document.getElementById("Player").URL.value = videoFile

webmannw

1:25 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



I really appreciate the help but that didn't work either. It's driving me mad :-)

I must be missing something......

webmannw

12:52 pm on Feb 1, 2005 (gmt 0)

10+ Year Member



Hi,

Still having problems with this..can anyone help?

Thanks

amznVibe

1:14 pm on Feb 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ditch the activex (object) and only use the embed which is supported by all browsers that do windows media. The embed will also help people who have active-x blocked since the video will still play. I have no idea why there are still examples around that mix the activex in there, it's a legacy style.

(also put a note on your video page for firefox/mozilla/opera/netscape visitors that if the video won't play they need to copy npdsplay.dll from their Program Files\Windows Media Player folder to the browser/plugins folder)

webmannw

1:51 pm on Feb 1, 2005 (gmt 0)

10+ Year Member



Thanks for the advice.

But I still cant get the src=" " //in the <embed> section to dynamicaly recieve the same .wmv file as the
<param name="URL" value=" " /> //in the <object> section.

>:-(

amznVibe

3:52 pm on Feb 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay you're not following me. Rip out any line with OBJECT or PARAM.
Leave only the embed statements. Example (untested)

<embed name="player" id="player" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/" type="application/x-mplayer2" src="" width="320" height="240" ShowControls=1 ShowDisplay=0 ShowStatusBar=0 autostart=1 autorewind=0 ShowPositionControls=1 ShowTracker=0>
</embed>

then in javascript this should work:

document.player.src="videofile.wmv";

if not, try this way:
document.getElementById("player").src="videofile.wmv";

last but not least if all this fails, feed the filename to the player dynamically via PHP or other through the URL

videos.php?filename=videofile.php

and make
src="<? echo $filename;?>"

then you can have <a href="?filename=blahvideo.wmv">
The php way is superiour because then you can see in your logs what people are watching (or not).

webmannw

9:47 am on Feb 2, 2005 (gmt 0)

10+ Year Member



Thanks amznVibe I reallt appreciate your help.

It's driving me mad! tried both suggestions but the value passes drom the Play() function just isn't reaching the src= " ".

Unfortunatly PHP isnt an option as the client has specified no serverside :-(

Looks like I'm going to have to have a rethink!

Thanks again

amznVibe

10:07 am on Feb 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Believe it or not, someone went through the same issue trying to change a flash movie inside an embed in another thread on WebmasterWorld:
[webmasterworld.com...]

They had little success as well. But you could try using the innerhtml idea which is supported now by ie5+/firefox1+/opera7+/netscape7+

Just stuff the embed into a div and change the innerhtml of the div with a new embed when you want to change the filename. In theory should work.