Re: Player.playState
- From: "Neil Smith [MVP Digital Media]" <neil@xxxxxxxxxx>
- Date: Sun, 05 Mar 2006 21:00:24 GMT
On Sun, 5 Mar 2006 12:17:27 -0800, wraevn
<wraevn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thanks for your reply Neil. In all my searching on the web you're apparently
the only person on the planet who has ever addressed these issues.
I agree that running the stuff locally I'm missing stuff - and I _am_
recording all the playstates in a variable then checking to see what happened
after the fact (as well as during playbabck etc.).
My big question though - why does the player seem to act contrary to what
the playstate is registering? When I see the video playing it says it's
paused (2), when it's paused it says it's stopped (1). Often, when I try to
play it and it stops itself (another bug I'm trying to work out) it says
3,0,3,0.
It's because as I said this line :
var timer = window.setInterval("setFlashvar_WMP_status()", 250);
Interrogates the player synchronously, every 1/4 second. It's not
firing those events on a timer, it's firing them asynchronously from
your timer - so this line
if (oldState != getVideoPlayer().playState)
Could quite easily be 3,6,3,7,3,10,9,3 at 200, 499, 749, 990ms (etc
etc) and you're only displaying those values which *happen* to
conicide with when your timer activates (which ain't that accurate in
javascript, either)
So in between those time slots it's been through 5 other states that
you never displayed or even knew about. Log the playstate to a
textarea instead to prove this. You'll need to use attachEvent instead
to get the player to *actually* send events to the browser when they
happen.
<script language="javascript1.2" type="text/javascript">
var WMP=new Object();
function onload_AttachEvent() {
// Get a global handle to our media player object
WMP=document.getElementById("MediaPlayer");
// Set up an onload event on the document so this is attached
// to media player once the page loads and WMP is active
WMP.attachEvent("playStateChange",setFlashvar_WMP_status);
// Setup position timer for 1/4 second feedback
var timer = window.setInterval("setFlashvar_WMP_position()",
250);
}
function setFlashvar_WMP_status(){
myFlashMovie.SetVariable("/:WMP_status",
WMP.playState);
}
}
function setFlashvar_WMP_position(){
codebase.SetVariable("/:WMP_currentPosition",
WMP.Controls.currentPosition);
}
</script>
Another thing I'd do is to keep a handle to the player (WMP) not keep
looking it up repeatedly in the DOM. It's a performance hit. The code
above sets a dummy object, then applies the WMP object to it when the
page has loaded.
And finally, the currentPosition value is a method of the
player.Controls object, not of the player itself (unlike playState).
You would need (as above)
player.Controls.currentPosition;
but player.playState;
HTH
Cheers - Neil (aka Obi Wan ;-)
.
- References:
- Re: Player.playState
- From: Neil Smith [MVP Digital Media]
- Re: Player.playState
- Prev by Date: Re: 'Device not detected'
- Next by Date: Re: WMP10 - Am I missing codecs ++Updated Info++
- Previous by thread: Re: Player.playState
- Next by thread: Re: Player.playState
- Index(es):
Relevant Pages
|