Link to home
Start Free TrialLog in
Avatar of ken_adams
ken_adams

asked on

IE javaScript or vbscript solution to QuickTime playback

I need to start playback of a QuickTime 4 movie from IE4.x and up using an external link to a function or in-line code.  I'm putting up 200 points in hopes of a swift cross browser solution.

I've got it working in Netscape 4.7 at the following url: http://davidrathod.com/rnd/

code is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
               "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>

<SCRIPT LANGUAGE="Javascript">
<!--

        /* takes a QT movie and calls its "Play" method */
        function PlayIt(anObj)
        {
                anObj.Play();
        }



//-->
</SCRIPT>
<HEAD>
     <TITLE>test QT play</TITLE>
</HEAD>
<BODY>
<center>
<embed src="../qt/0804sun_tango.mov" name="movie1" width="320" height="256" autoplay="false" enablejavascript="true" pluginspage="http://www.apple.com/quicktime/download/" bgcolor="black"></embed>

<br><br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript:PlayIt(document.movie1);">click to play the movie</a>
<br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript:document.embeds['movie1'].Play();">click to play in IE?</a>

</center>


</BODY>
</HTML>

Thanks,

-ken

Avatar of a.marsh
a.marsh

First of all vbscript is no good as it is only any good in IE.

Could you give us a link to the page above so that we can actually load the movie in order to work with this for you?

:o)

Ant
Avatar of ken_adams

ASKER

the url is at the top of the question but i modified the directory.  here is is:  
http://davidrathod.com/rnd/single_movie.htm

thanks,

-ken
Well if you use this you'll see that you can "get to" the object:

<a href="javascript:alert(document.all.movie1);">click to play in IE?</a>

because it returns "[object]".

Just can't seem to get it to play!

I'll see what I can find....

:oP

Ant
Sorry, I'm being "thick"... document.embeds gets you to the object aswell!

Ant
By adding this piece of clever javascript you can get a list of all attributes and methods of the embed object:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
               "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>

<SCRIPT LANGUAGE="Javascript">
<!--

        /* takes a QT movie and calls its "Play" method */
        function PlayIt(anObj)
        {
                anObj.Play();
        }



//-->
</SCRIPT>
<HEAD>
<base href="http://davidrathod.com/rnd/">
     <TITLE>test QT play</TITLE>
</HEAD>
<BODY>
<center>
<embed src="../qt/0804sun_tango.mov" name="movie1" width="320" height="256" autoplay="false" enablejavascript="true" pluginspage="http://www.apple.com/quicktime/download/" bgcolor="black"></embed>

<br><br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript:PlayIt(document.movie1);">click to play the movie</a>
<br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript: void(0); " onclick="alert(document.embeds['movie1'].behaviorUrns);">click to play in IE?</a>

</center>

<SCRIPT LANGUAGE="JavaScript">
<!--
    var output = '';
    for (var i in document.embeds[0])
        output += i+ '<br>';
    document.write(output);
//-->
</SCRIPT>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
               "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>

<SCRIPT LANGUAGE="Javascript">
<!--

        /* takes a QT movie and calls its "Play" method */
        function PlayIt(anObj)
        {
                anObj.Play();
        }



//-->
</SCRIPT>
<HEAD>
<base href="http://davidrathod.com/rnd/">
     <TITLE>test QT play</TITLE>
</HEAD>
<BODY>
<center>
<embed src="../qt/0804sun_tango.mov" name="movie1" width="320" height="256" autoplay="false" enablejavascript="true" pluginspage="http://www.apple.com/quicktime/download/" bgcolor="black"></embed>

<br><br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript:PlayIt(document.movie1);">click to play the movie</a>
<br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript:alert(document.embeds['movie1']);">click to play in IE?</a>

</center>

<SCRIPT LANGUAGE="JavaScript">
<!--
    var output = '';
    for (var i in document.embeds[0])
        output += i+ '<br>';
    document.write(output);
//-->
</SCRIPT>
</BODY>
</HTML>


Ant
As you can see there is no kind of play, run or start method in the list that gets generated....and things are getting worse still, I came across this:

http://developer.apple.com/techpubs/quicktime/qtdevdocs/REF/QT41_HTML/QT41WhatsNew-72.html

which is saying that only Netscape and Javascript work with QuickTime at present....I'm using IE5.5 and Quicktime 4.1.1

Did you get your code from here by any chance?

http://developer.apple.com/techpubs/quicktime/qtdevdocs/REF/QT41_HTML/QT41WhatsNew-72.html

Ant
Whoops, I just noticed that I must have pressed the paste button twice on my earlier comment!

The code is simply:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
              "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>

<SCRIPT LANGUAGE="Javascript">
<!--

       /* takes a QT movie and calls its "Play" method */
       function PlayIt(anObj)
       {
               anObj.Play();
       }



//-->
</SCRIPT>
<HEAD>
<base href="http://davidrathod.com/rnd/">
    <TITLE>test QT play</TITLE>
</HEAD>
<BODY>
<center>
<embed src="../qt/0804sun_tango.mov" name="movie1" width="320" height="256" autoplay="false" enablejavascript="true"
pluginspage="http://www.apple.com/quicktime/download/" bgcolor="black"></embed>

<br><br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript:PlayIt(document.movie1);">click to play the movie</a>
<br>
<!-- THIS LINK WORKS IN NETSCAPE ONLY -->
<a href="javascript: void(0); " onclick="alert(document.embeds['movie1'].behaviorUrns);">click to play
in IE?</a>

</center>

<SCRIPT LANGUAGE="JavaScript">
<!--
   var output = '';
   for (var i in document.embeds[0])
       output += i+ '<br>';
   document.write(output);
//-->
</SCRIPT>
</BODY>
</HTML>


:o)

Ant
i see what you mean.  it's up at:
http://davidrathod.com/rnd/single_movie.htm

however, i don't see how i can set the movie to play from any of those attributes or methods in IE.  

any suggestions?

-ken
i see what you mean.  it's up at:
http://davidrathod.com/rnd/single_movie.htm

however, i don't see how i can set the movie to play from any of those attributes or methods in IE.  

any suggestions?

-ken
sorry our comments crossed.  i only used the first half of your code and got the results.

i don't know if i got the code from that particular technote but i did read that it was problematic, but was hoping there was a work around since i can never find the "ultimate definitive" answer to this cross browser stuff.

hmmmm....
This seems like one of those rare cases where Netscape has better support for something than IE!!

Ant
seems so.  i'll leave this open for a while in case anyone else has some ideas, then if not, accept the answer.  thanks for putting in the time.  looks like no one else has approached this question so far but you.

-ken
I don't think you that IE understands the play(0 and stop(0 methods. I had the same trouble with sound. the way I solved this was to change the src of the bgsound tag, like so.

<html>
<body>
<BGSOUND id="BGSOUND_ID" LOOP=1 SRC="">
<EMBED NAME="WLS" SRC="sounds/Sound.wav" LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>

<script language="JavaScript">
<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3  && navigator.appName!="Netscape")?1:0
ns4=(ver>3  && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playSound(s) {

 soundStr = s;
 
 if (ie4) self.document.all['BGSOUND_ID'].src=soundStr;
 if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-midi'] && self.document.myform.soundFile.IsReady() )
 {

  soundStr = soundStr.substring(0 , soundStr.indexOf('.'));
  self.document.myform.soundFile.play()
 }
}

function stopSound() {
 if (ie4) self.document.all['BGSOUND_ID'].src='';
 if ((ns4||ns3) && navigator.javaEnabled() && navigator.mimeTypes['audio/x-midi'] )
 {
  self.document.myform.soundFile.stop()
 }
}

var clickCount;

clickCount = 0;

function engageSound(val, t) {
     clickCount++;

     if ((clickCount%2)==1) {
          playSound('sounds/Sound.wav');
          t.checked=true;
     }
     else {
          stopSound();
          t.checked=false;
     }
}

//-->
</script>

<form name=myform>

<a href="javascript:engageSound('sounds\sound.wav', this);"><input type=radio name="sOn" onclick="engageSound('sounds\sound.wav', this); return true;">Play</a>

</form>
</body>
</html>

I'd be interested to see if anyone does solve this.

nzjonboy
Glad to have helped Ken - sorry it wasn't a more positive result. :o(


Ant
Maybe Internet Explorer 6 will have better support.... I might see if I can find out.

:o)

Ant
thanks folks.  it would be good to know.

-ken
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for trying to run this down.

-ken
My pleasure - sorry things weren't more positive for you.

Ant