Re: Player.playState

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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



Relevant Pages

  • Re: Preload Buffer Recplacement ??
    ... with an image in on top of the object and when playstate ... > Thanks I'll take a look, But if you look in the global definition, ... > 100ms delay if the player is actually playing, ...
    (microsoft.public.windowsmedia.player.web)
  • Re: How to tell if WMP is finished
    ... application how do I tell if the media player is finished play the ... Are you saying that the movie plays, but the .playState never changes? ... 'playing' state of the player. ...
    (microsoft.public.vb.general.discussion)
  • Re: Preload Buffer Recplacement ??
    ... OK, first turn on error reporting for javascript in IE first of all, ... and the width and height on each player to zero. ... playstate becomes 3 twice, once when buffering and again when playing, ...
    (microsoft.public.windowsmedia.player.web)
  • Re: Player.playState!!!!
    ... and it will check the playState every 500ms. ... you may be starting a *completely* different player by ... >which i found out onfinishdoes not apply to embed tag. ... >i attach my script that i used to trigger. ...
    (microsoft.public.windowsmedia.player.web)
  • Re: DCSS: Questions about timed vaults
    ... But why not announce their existance to the player, ... the timed vault for just few turns, ... That's supposed to start the "long" timer while giving ... stuck to the current exploration pattern. ...
    (rec.games.roguelike.misc)