Re: Some issues with player control, keep resizing automatically.
- From: "eug_acc" <eugacc@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Feb 2006 06:11:31 -0800
Neil,
Thanks it helps, the trick is happened that as soon as I moved code for
attachEvent() after appending child control , everyhting started works.
Other code seems do not affecting operation, but I will try play with other
staff and will check how it works with other browsers.
So I only changed:
elWmp.autoStart="-1";
elWmp.attachEvent("onPlayStateChange",PlayState);
________________________^^ should be attachEvent("playstatechange"
elWmp.attachEvent("onresize",trapSize);
________________________^^ should be attachEvent("resize"
elDivPlayer.appendChild(elWmp);
for the code:
elDivPlayer.appendChild(elWmp); //and then after
elWmp.attachEvent("PlayStateChange",PlayState);
for some reason "onresize" event works fine even when attached before (I
guess because it is common browser event) and with "onresize" as a key word .
The player url is assigned much later in a code. First I just opening blank
media platyer and then user choosing url to play, that why you don't see it.
I didn't put all code because there to many other GUI elements, events not
related to media player, that why I didn't bother post it.
"Neil Smith [MVP Digital Media]" wrote:
On Fri, 10 Feb 2006 14:31:18 -0800, "eug_acc".
<eugacc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Here is part of code to create player:
var elWmp=document.createElement("object");
elWmp.classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6";
//elWmp.className="forplayer";
elWmp.uiMode='full';
elWmp.windowlessVideo='true';
elWmp.id='wmp';
elWmp.stretchToFit='true';
elWmp.playCount="1";
elWmp.autoStart="-1";
elWmp.attachEvent("onPlayStateChange",PlayState);
________________________^^ should be attachEvent("playstatechange"
elWmp.attachEvent("onresize",trapSize);
________________________^^ should be attachEvent("resize"
//elWmp.fullScreen='false';
//elWmp.innerHTML=htmlM;
elDivPlayer.appendChild(elWmp);
I'm not sure it works in all browsers, but you may need to attach
those events *after* appending the child to the DOM - before that I'm
not clear that the events are in scope until the object is part of the
DOM.
//obviousely, elDivPlayer created already and it is just container for
OK
player control. //At the end I added elDIvPlayer to document.body
function PlayState()
{
//for now I only would like get laert message
alert(document.all.wmp.playState);
}
I can't get any "error" or any messages at all.
I'm not able to determine from your code, because again you've only
posted part of the code : Where are you setting the player URL and
telling the player to 'play()' ? The playstatechange event is only
triggered when the media player changes playing state. Given the
(modified) code above, that event will never be triggered.
So now we look at the code you've posted. There are several areas in
error which as I requested before, you probe by setting the browser to
report javascript errors.
It's clear you didn't bother doing that, because you would have seen
one of the errors immediately with the code above :
'Can not set property at runtime' (referring to the attempt to set the
classID dynamically on the object). This is documented here, and here
http://msdn.microsoft.com/workshop/author/dhtml/overview/activating_activex.asp
http://karma.nucleuscms.org/item/108
It refers to the fact you can't create an ActiveX object without first
atttaching the parent to the DOM, as I suggested above for the event
handlers.
I changed the code above to a complete set which does work in IE :
================================================
<script language="javascript1.2">
var elWmp;
function loadPlayer() {
var elDivPlayer=document.getElementById("divplayer");
elWmp=document.createElement("object");
elDivPlayer.appendChild(elWmp);
elWmp.width="390";
elWmp.height="250";
elWmp.classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6";
elWmp.uiMode="full";
elWmp.windowlessVideo="true";
elWmp.id="wmp";
elWmp.stretchToFit="true";
elWmp.playCount="1";
elWmp.autoStart="false";
elWmp.URL="falluja.asf";
elWmp.attachEvent("playstatechange",PlayState);
}
function PlayState() {
alert("This is my playstate : "+elWmp.playState);
}
</script>
<div id="divplayer" style="width: 400px; height: 300px; border: 1px
solid #333333; background-color: #FFCC33"></div>
<input type="button" name="playstart" id="playstart" value="Load
Player" onclick="loadPlayer()" />
================================================
That code likely won't work in Firefox, Opera, Safari etc.
Those browsers have no concept of "classID" which is the correct
interpretation of the W3C DOM. You need to specify a
type="video/x-ms-wmv" for video in those browser.
You will need to browser sniff for W3C as opposed to MS DOM support,
because if you set ClassID *and* type for WMP OCX, the browser will
fail with the setting type at runtime error. You specify either MIME
type of the content OR classID depending on browser (probably using
test for document.createImplementation vs document.createElement)
HTH
Cheers - Neil
- Follow-Ups:
- Re: Some issues with player control, keep resizing automatically.
- From: Neil Smith [MVP Digital Media]
- Re: Some issues with player control, keep resizing automatically.
- References:
- Re: Some issues with player control, keep resizing automatically.
- From: Neil Smith [MVP Digital Media]
- Re: Some issues with player control, keep resizing automatically.
- From: Neil Smith [MVP Digital Media]
- Re: Some issues with player control, keep resizing automatically.
- From: eug_acc
- Re: Some issues with player control, keep resizing automatically.
- From: Neil Smith [MVP Digital Media]
- Re: Some issues with player control, keep resizing automatically.
- Prev by Date: Re: Some issues with player control, keep resizing automatically.
- Next by Date: Re: Some issues with player control, keep resizing automatically.
- Previous by thread: Re: Some issues with player control, keep resizing automatically.
- Next by thread: Re: Some issues with player control, keep resizing automatically.
- Index(es):
Relevant Pages
|