Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / December 2005



Tip: Looking for answers? Try searching our database.

howto change quicktime src with javascript?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Encapsulin - 27 Dec 2005 21:36 GMT
Hello everybody.
I'm trying to change src of quicktime embedded object with javascript:

<html><body>
<script language="JavaScript">
function Exchange()
{
    document.qtvr.src = "sample2.pano";
    document.embeds["mov"].src = "sample2.mov";
}
</script>

<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
width="600" height="400"
codebase="http://www.apple.com/qtactivex/qtplugin.cab" id="qtvr">
<param name="autoplay" value="true">
<param name="controller" value="true">
<param name="pluginspage"
value="http://www.apple.com/quicktime/download/indext.html">
<param name="target" value="myself">
<param name="type" value="video/quicktime">
<param name="src" value="sample1.pano">
<embed src="sample1.mov" width="600" height="400" autoplay="true"
controller="true" border="0"
pluginspage="http://www.apple.com/quicktime/download/indext.html"
target="myself" type="video/quicktime" name="mov"></embed>
</object>

<a href="#" onclick="javascript:Exchange()">exchange</a>
</body></html>

but IE said that "document.embeds.mov.src is not object", and image
isn't changed ( IE,Mozilla) when user click on the link "exchange".
What is wrong, how to do this correctly?
Thank in advance.
Andrew Poulos - 28 Dec 2005 03:25 GMT
> Hello everybody.
> I'm trying to change src of quicktime embedded object with javascript:
[quoted text clipped - 31 lines]
> What is wrong, how to do this correctly?
> Thank in advance.

To change the source of a QT movie you use the SetURL method like so,
document.getElementById("qtvr").SetURL("sample2.mov");

Though the sample code you've included above contains deprecated
features and mistakes which I have to leave to someone else to fix.

Andrew Poulos
Thomas 'PointedEars' Lahn - 28 Dec 2005 03:50 GMT
>> [...]
>> <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
[quoted text clipped - 14 lines]
>>
>> <a href="#" onclick="javascript:Exchange()">exchange</a>

`javascript:' does not belong into intrinsic event handlers.  Declare
the default scripting language for event handler attributes in the `head'
element instead:

 <meta http-equiv="Content-Script-Type" content="text/javascript">

The `click' event should be canceled properly, and the script-only link
should be written via script:

 <script type="text/javascript">
   document.write('<a href="#" onclick="Exchange();'
     + ' return false;">exchange<\/a>');
 </script>

>> </body></html>
>>
[quoted text clipped - 5 lines]
> To change the source of a QT movie you use the SetURL method like so,
> document.getElementById("qtvr").SetURL("sample2.mov");

 document.applets["qtvr"].SetURL("sample2.mov");

should suffice.  However, it is error-prone to assume that the QuickTime
plugin would always be used for displaying this object and so a SetURL()
method would be available; `param' elements' values need not to be
followed, the `data' attribute is missing and the codebase is in a format
that would not be understood on non-Windows systems.  Here in Mozilla/5.0
(X11; U; Linux i686; en-US; rv:1.8) Gecko/20051224 Debian/1.5.dfsg-3
Firefox/1.5 Mnenhy/0.7.3.0 that is likely to trigger the assigned mplayer
plugin instead.

Therefore, I would refrain from calling SetURL() but instead use the `data'
attribute in the first place and attempt to change the value of that
attribute via its representative property:

 document.applets["qtvr"].data = "sample2.mov";

See also
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-9893177>
<URL:http://www.w3.org/TR/html4/struct/objects.html#edef-OBJECT>

However, that is untested as well.

> Though the sample code you've included above contains deprecated
> features and mistakes which I have to leave to someone else to fix.

<URL:http://validator.w3.org/>

PointedEars
Andrew Poulos - 28 Dec 2005 05:36 GMT
>>><a href="#" onclick="javascript:Exchange()">exchange</a>
>
[quoted text clipped - 11 lines]
>       + ' return false;">exchange<\/a>');
>   </script>

Sorry but I don't understand why code created dynamically is "correct"
whereas the the same code written directly in the page is "wrong"?

> Therefore, I would refrain from calling SetURL() but instead use the `data'
> attribute in the first place and attempt to change the value of that
[quoted text clipped - 7 lines]
>
> However, that is untested as well.

I tested doc.applets, as opposed to using SetURL, and couldn't get it to
work.

Andrew Poulos
bwucke@gmail.com - 28 Dec 2005 12:36 GMT
Andrew Poulos napisal(a):
> > Therefore, I would refrain from calling SetURL() but instead use the `data'
> > attribute in the first place and attempt to change the value of that
[quoted text clipped - 12 lines]
>
> Andrew Poulos

I tried a few approaches, I don't know if it was result of my mistakes
or it was simply unsupported, but none of the gentle methods of
replacing data source worked. I used brute force instead:
createElement('object'), set the properties and children, then
replaceNode. Rip the whole player out of the page and replace it with a
new instance of the player with the new movie assigned. Worked.
Thomas 'PointedEars' Lahn - 28 Dec 2005 14:58 GMT
>>>> <a href="#" onclick="javascript:Exchange()">exchange</a>
>>
[quoted text clipped - 14 lines]
> Sorry but I don't understand why code created dynamically is "correct"
> whereas the the same code written directly in the page is "wrong"?

It is _not_ the same code.  Besides, what makes the former also wrong is
that the link will do nothing without script support; the latter approach
will not generate the link at all without script support, so in that case
there would be nothing that did not do nothing :)

>> Therefore, I would refrain from calling SetURL() but instead use the
>> `data' attribute in the first place and attempt to change the value of
[quoted text clipped - 10 lines]
> I tested doc.applets, as opposed to using SetURL, and couldn't get it to
> work.

Did you provide the `data' attribute value for the `object' element instead
of using the `param' element?

PointedEars
Thomas 'PointedEars' Lahn - 30 Dec 2005 18:35 GMT
>> Therefore, I would refrain from calling SetURL() but instead use the
>> `data' attribute in the first place and attempt to change the value of
[quoted text clipped - 10 lines]
> I tested doc.applets, as opposed to using SetURL, and couldn't get
> it to work.

You could not get it to work because I misread the specification.
HTMLDocument::applets applies to `object' elements that refer to
applets and `applet' elements only.  We do have an `object' element
here but not one that refers to an applet.

It should work with document.getElementsById('qtvr').data = "sample.mov"
(without the Reference Worm, of course.)

Regards,
PointedEars
Encapsulin - 28 Dec 2005 20:33 GMT
It works, thank you!!!
Encapsulin - 28 Dec 2005 21:17 GMT
oops,problem with Mozilla (but IE is ok):

this is works:
<object><embed src="sample2.mov"></object>

but this isn't works:
<object><embed src="../samples/sample2.mov"></object>

WHY?
Encapsulin - 28 Dec 2005 21:37 GMT
sorry, I need to detalize the problem:

this code is ok:
<object><embed src="sample2.mov" id="gtvr"></object>
<SCRIPT language="JavaScript">
document.getElementById("qtvr").SetURL("sample1.mov");
</SCRIPT>

but problem with the following code:
<object><embed src="../samples/sample2.mov" id="gtvr"></object>
<SCRIPT language="JavaScript">
document.getElementById("qtvr").SetURL("../samples/sample1.mov");
</SCRIPT>
Thomas 'PointedEars' Lahn - 28 Dec 2005 21:53 GMT
> sorry, I need to detalize the problem:
>
[quoted text clipped - 3 lines]
> document.getElementById("qtvr").SetURL("sample1.mov");
> </SCRIPT>

It is still not OK.

PointedEars
Randy Webb - 28 Dec 2005 22:53 GMT
Thomas 'PointedEars' Lahn said the following on 12/28/2005 4:53 PM:

>>sorry, I need to detalize the problem:
>>
[quoted text clipped - 5 lines]
>
> It is still not OK.

More "clues" from the clueless?

"It is still not OK" is about as useless an answer as "It doesnt work"
is a description.

If you have nothing positive to contribute then please stop wasting
peoples time by having them read your garbage.

Signature

Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Encapsulin - 29 Dec 2005 13:56 GMT
I'm still not understood, why relative path to the .mov doesn't works.
I have the following html-code:
             <OBJECT
classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"

codebase="http://www.apple.com/qtactivex/qtplugin.cab"
                      width="180" height="160"
                      id="movie" >
               <PARAM name="src" value="">
               <EMBED width="180" height="160"
                      src=""
                      TYPE="video/quicktime"
                      PLUGINSPAGE="www.apple.com/quicktime/download"
                      name="movie2"
                      enablejavascript="true">
               </EMBED>
              </OBJECT>
<br><a
href="javascript:document.movie.SetURL('sample1.mov');">sample1</a>
<br><a
href="javascript:document.movie.SetURL('sample2.mov');">sample2</a>
<br><a
href="javascript:document.movie.SetURL('./mov/sample1.mov');">sample1</a>
<br><a
href="javascript:document.movie.SetURL('./mov/sample2.mov');">sample2</a>

The problem is: first 2 jscripts  works properly, but last 2 doesn't
works in both IE and Mozilla. Does anybody know why???
bwucke@gmail.com - 29 Dec 2005 14:09 GMT
Encapsulin napisal(a):
> href="javascript:document.movie.SetURL('./mov/sample1.mov');">sample1</a>
> <br><a
> href="javascript:document.movie.SetURL('./mov/sample2.mov');">sample2</a>
>
> The problem is: first 2 jscripts  works properly, but last 2 doesn't
> works in both IE and Mozilla. Does anybody know why???

Just a thought: Are you testing it on a real server, or just loading a
file from the disk, on Windows? In this case, you might want to try
'.\mov\sample2.mov' instead. And then fix the path back to
'./mov/sample2.mov' before uploading, because webserver should handle
it correctly.
Thomas 'PointedEars' Lahn - 29 Dec 2005 15:18 GMT
> I'm still not understood,

what is expected behavior here?  Yes, indeed, alas.

<URL:http://jibbering.com/faq/#FAQ2_3>

> why relative path to the .mov doesn't works.
> I have the following html-code:
[quoted text clipped - 4 lines]
>                        width="180" height="160"
>                        id="movie" >

Again, that is not going to work on non-Windows systems or those without
the QuickTime plugin, that includes systems using another application for
QuickTime movies.

>                 <PARAM name="src" value="">
>                 <EMBED width="180" height="160"
[quoted text clipped - 4 lines]
>                        enablejavascript="true">
>                 </EMBED>

This is the last time I am going to tell you to get rid of that invalid
`embed' element.

news:1135771022.561695.27700@g44g2000cwa.googlegroups.com
(VK is correct about the obsolete status of that proprietary element)

news:1186994.3eK83MmBpW@PointedEars.de

<URL:http://validator.w3.org/>

>                </OBJECT>
> <br><a
> href="javascript:document.movie.SetURL('sample1.mov');">sample1</a>

That is not what was suggested by Andrew.  Have you even read what was
posted?

> <br><a
> href="javascript:document.movie.SetURL('sample2.mov');">sample2</a>
> <br><a
> href="javascript:document.movie.SetURL('./mov/sample1.mov');">sample1</a>
> <br><a
> href="javascript:document.movie.SetURL('./mov/sample2.mov');">sample2</a>

<URL:http://jibbering.com/faq/#FAQ4_24>

> The problem is: first 2 jscripts  works properly, but last 2 doesn't
> works in both IE and Mozilla.

"Does not work" is a useless error description. [psf 4.11]

<URL:http://jibbering.com/faq/#FAQ4_43>

> Does anybody know why???

Your Question Mark key is borken.

Possibilities:

1. The path is wrong: there is no `mov/sample1.mov' but a `sample1.mov'.
  Check the path by accessing the resource directly (Address Bar etc.)

2. The plugin cannot handle this type of relative paths.
  Omit the "./".

HTH

PointedEars
VK - 28 Dec 2005 11:57 GMT
> Hello everybody.
> I'm trying to change src of quicktime embedded object with javascript:
[quoted text clipped - 30 lines]
> isn't changed ( IE,Mozilla) when user click on the link "exchange".
> What is wrong, how to do this correctly?

Of course it says that:

The <object><embed></embed></object> structure was used in the past to
cover browsers with object or embed support (but not both).
Thus if browser understands <object> it will *ignore* internal <embed>.
And if it doesn't understand <object> then it will skip on it and use
internal <embed> instead. As all known to me modern browsers do
understand <object> tag - your <embed> is never parsed so no use to
address it.

Also please note an erroneus link syntacs which will work for a *very
tolerant* browser only:
javascript: psi-protocol can be indicated in the href attribute only,
not in event handlers. The correct way would be:
<a href="noscript.html" onclick="Exchange();return false">exchange</a>
or at least:
<a href="javascript:Exchange()">exchange</a> (problems prone)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.