Jump to content

PIXI sound & playback started


Recommended Posts

I'm using PIXI.sound in my project, and it's working very well. But, I'm finding that IE11 (yeah, I know) is very slow to play MP3s. What I'd like to do is have an onstarted event when the playback has actually begun  but there doesn't seem to be anything in PIXI.sound that I can use this way.


Can anyone tell me a way to add an event listener so I can confirm the playback of an audio clip has started.

Link to comment
Share on other sites

Yeah I took a brief look at the source, it uses HTMLAudioElement on IE and runs a tick to check where the sound is so it can detect when the sound is done playing and dispatch an event.

Now for playing the first time a sound plays the HTMLAudioElement will load it in async so delay can be expected but probably not the second time. There are no event the HTMLAudioElement dispatches when it starts playing so the only way to to it would be to run a tick when play() is called and then dispatch a 'started' event when the position of the sound starts changing. 

Link to comment
Share on other sites

thanks @botmaster that's all very useful.

I did a ticker to check when the mediaelement progress > 0 - and that did work, although as some of the clips are long, the wait was 'uncomfortable'

Unfortunately my use case has a lot of audio clips which need to be sequenced (and played alongside a separate video clip). This means I  delete them from the cache after use (and they are expected to only be viewed once anyway.) It was working ok, but any network slow down caused it to fail.

Ultimately, I've made separate arrangements for IE11.

Link to comment
Share on other sites

Both HTMLAudioElement and WebAudioAPI do need to load the entire sound before playing it which with long sound might explain the delay you experience. WebAudioAPI can stream sounds but not out of the box, this has to be implemented in code and I could be wrong but I didn't see such type of code in PIXI.sound but don't take my words for it.

If you have exclusive sound needs then when running in IE you have no choice but dropping html and either use plugin technology or not support IE altogether. All my html5 apps are replaced with Flash on IE just because of IE not supporting WebAudioAPI. This will have to do at least for now.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...