Re: JavaScript concurrency issues & initialization delay
Forest Bond <[email protected]>
| Newsgroups | gmane.comp.mozilla.mplayerplug-in |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Sep 28, 2007 at 09:52:02AM -0600, Kevin DeKorte wrote:
> Forest Bond wrote:
> > I think it might just be a bug. I've attached the logfile.
> >
> > It's definitely not releated to setTimeout, because I hit the same issue with or
> > without that call. What's interesting is that I can make the problem go away by
> > placing an alert(...) call after calling Stop(). I don't know why that would
> > be.
> >
> > My code is doing something like this:
> >
> > --------------------------------------------------------------------------------
> > if(mplayer.isplaying()) {
> > mplayer.Stop();
> > while(mplayer.playState != 1) {
> > ;
> > }
> > }
> > //alert('after Stop: ' + mplayer.playState);
> >
> > mplayer.Open(new_url);
> >
> > mplayer.Play();
> > while(mplayer.playState != 3) {
> > ;
> > }
> > --------------------------------------------------------------------------------
> >
> > As I mentioned above, uncommenting that alert(...) call makes the problem go
> > away. Very strange.
> >
> > What do you think?
> >
> > -Forest
>
> I agree that it is really odd.. have you tried putting a "sleep" inside
> the while loop? I'm not sure if javascript has that or not, but if so
> then maybe there and then maybe one more after the loop is done. I think
> 100usec should be enough.
This seems to do the trick, although I'm not entirely happy with it because it
introduces all kinds of race conditions. I'll probably have to implement an
instruction queue.
--------------------------------------------------------------------------------
if(mplayer.isplaying()) {
mplayer.Stop();
while(mplayer.playState != 1) {
;
}
}
x = function() {
mplayer.Open(new_url);
mplayer.Play();
while(mplayer.playState != 3) {
;
}
}
setTimeout(x, 100);
--------------------------------------------------------------------------------
-Forest
--
Forest Bond
http://www.alittletooquiet.net
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mplayerplug-in-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mplayerplug-in-devel
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFG/S4xRO4fQQdv5AwRAkXFAKC2oU9n6esq9pTOigLiY7XdWkErfQCfdPAK pmXsbyOnSB7fjHbz/Z+bLLc= =Dhma -----END PGP SIGNATURE-----