By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,208 Members | 1,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,208 IT Pros & Developers. It's quick & easy.

howto change quicktime src with javascript?

P: n/a
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.

Dec 27 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Encapsulin wrote:
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.

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

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
Dec 28 '05 #2

P: n/a
Andrew Poulos wrote:
Encapsulin wrote:
[...]
<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>
`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>

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.
To change the source of a QT movie you use the SetURL method like so,
document.getElementById("qtvr").SetURL("sample2.mo v");


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
Dec 28 '05 #3

P: n/a
Thomas 'PointedEars' Lahn wrote:
<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>


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
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.


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

Andrew Poulos
Dec 28 '05 #4

P: n/a
VK

Encapsulin wrote:
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?


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)

Dec 28 '05 #5

P: n/a

Andrew Poulos napisal(a):
Thomas 'PointedEars' Lahn wrote:
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.


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

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.

Dec 28 '05 #6

P: n/a
Andrew Poulos wrote:
Thomas 'PointedEars' Lahn wrote:
<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>


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
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.


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
Dec 28 '05 #7

P: n/a
It works, thank you!!!

Dec 28 '05 #8

P: n/a
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?

Dec 28 '05 #9

P: n/a
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.mo v");
</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>

Dec 28 '05 #10

P: n/a
Encapsulin wrote:
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.mo v");
</SCRIPT>


It is still not OK.
PointedEars
Dec 28 '05 #11

P: n/a
Thomas 'PointedEars' Lahn said the following on 12/28/2005 4:53 PM:
Encapsulin wrote:

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>

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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 28 '05 #12

P: n/a
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.mo v');">sample1</a>
<br><a
href="javascript:document.movie.SetURL('sample2.mo v');">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???

Dec 29 '05 #13

P: n/a

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.

Dec 29 '05 #14

P: n/a
Encapsulin wrote:
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:
<OBJECT
classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"

codebase="http://www.apple.com/qtactivex/qtplugin.cab"
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"
src=""
TYPE="video/quicktime"
PLUGINSPAGE="www.apple.com/quicktime/download"
name="movie2"
enablejavascript="true">
</EMBED>
This is the last time I am going to tell you to get rid of that invalid
`embed' element.

news:11*********************@g44g2000cwa.googlegro ups.com
(VK is correct about the obsolete status of that proprietary element)

news:11****************@PointedEars.de

<URL:http://validator.w3.org/>
</OBJECT>
<br><a
href="javascript:document.movie.SetURL('sample1.mo v');">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.mo v');">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
Dec 29 '05 #15

P: n/a
Andrew Poulos wrote:
Thomas 'PointedEars' Lahn wrote:
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.


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
Dec 30 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.