howto change quicktime src with javascript?

E

Encapsulin

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

Andrew Poulos

Encapsulin said:
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.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
 
T

Thomas 'PointedEars' Lahn

Andrew said:
Encapsulin said:
[...]
<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>');
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
 
A

Andrew Poulos

Thomas said:
`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
 
B

bwucke

Andrew Poulos napisal(a):
Thomas said:
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.
 
T

Thomas 'PointedEars' Lahn

Andrew said:
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
 
E

Encapsulin

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?
 
E

Encapsulin

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

Thomas 'PointedEars' Lahn

Encapsulin said:
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.


PointedEars
 
R

Randy Webb

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




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

Encapsulin

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???
 
B

bwucke

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

Thomas 'PointedEars' Lahn

Encapsulin said:
I'm still not understood,

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

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.

(VK is correct about the obsolete status of that proprietary element)


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

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]

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
 
T

Thomas 'PointedEars' Lahn

Andrew said:
Thomas said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top