Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio plays back with about a second and a half delay on the Microsoft Surface / Windows 8 Phone #72

Closed
volkipp opened this issue Feb 12, 2013 · 13 comments

Comments

@volkipp
Copy link
Contributor

volkipp commented Feb 12, 2013

All audio plays back as it should, however it plays with about a second and a half delay every time.

In flambe if you play a sound, then immediately pause it like so:
var playback:Playback = mySound.play(); playback.paused = true; // Do something else for awhile... playback.paused = false;

Then the sound plays without a delay when you un-pause it.

My best guess is that when element is getting cloned, IE doesn't have the sound cached in a way that allows immediate playback.

Relates to #48

@aduros
Copy link
Owner

aduros commented Feb 13, 2013

Urgh, yeah, unspecified cache behavior is one of the reasons HTML5 audio sucks for games. Is it actually getting re-downloaded after every play? Have you tried serving up sound files with a far future HTTP Expires header?

@volkipp
Copy link
Contributor Author

volkipp commented Feb 13, 2013

From what I can tell, it does look like it's getting re-downloaded from the server every time. I haven't looked into the HTTP Expires header. Is there an easy way to do that with the SimpleHTTPServer python has?

@aduros
Copy link
Owner

aduros commented Feb 13, 2013

I don't know of any way to configure headers in SimpleHTTPServer, I guess it wouldn't be too Simple then ;)

Does this page cause sounds to be re-downloaded: https://aduros.com/flambe/demos/horses/?flambe=html ? That web server is set up to serve assets with an Expires header.

I'm planning to add instructions on how to do this in nginx and apache to the wiki, as it's useful even outside of sound playing. You probably noticed the ?v=(MD5 hash) parameter appended to all asset requests, that can be used to aggressively perma-cache assets.

@volkipp
Copy link
Contributor Author

volkipp commented Feb 13, 2013

Ha, true. I tried out that link, and unfortunately it's having the same trouble on the surface tablet. I've tried poking around to see if I could find some kind of clever hack to make it play back correctly, but no luck so far. :(

@aduros
Copy link
Owner

aduros commented Feb 13, 2013

Maybe the way to go is to have HtmlSound pool a bunch of <audio> elements instead of creating one for each playback.

@volkipp
Copy link
Contributor Author

volkipp commented Feb 14, 2013

Yeah, I definitely think that would solve the problem for most scenarios. Three sounds being spooled up initially would probably be plenty. You want me to take a stab at this, or would you prefer to do it?

@volkipp
Copy link
Contributor Author

volkipp commented Feb 14, 2013

Hm, you know I've been so focused on mobile devices I hadn't tried IE10 in Windows 8 for the Desktop. It appears that IE10 desktop has the same issues for me. Trying the horses demo you posted on desktop, there is the long delay on the first playback, but subsequent playbacks seem to be much better. Using the simple python server, the sound delay happens every time on the desktop, just like the Surface.

@aduros
Copy link
Owner

aduros commented Feb 15, 2013

Feel free to take on the sound pooling if you can. I'm not as well equipped to test things on Windows 8.

Ideally the pool can grow if you request too many playbacks. HtmlSound should probably avoid adding audio elements to the DOM, to prevent leaks when it's garbage collected.

@aduros
Copy link
Owner

aduros commented Feb 15, 2013

Also, the fact that the horses demo has a long pause on the first play seems to suggest HtmlAssetPackLoader isn't preloading sounds correctly for some reason.

@volkipp
Copy link
Contributor Author

volkipp commented May 8, 2013

I'm not sure what changed with audio loading / support in the nightly builds, but recompiling some past projects are giving me latency-free playback on the Surface RT!

@volkipp volkipp closed this as completed May 8, 2013
@aduros
Copy link
Owner

aduros commented May 8, 2013

Great! That's surprising, I don't think anything changed on Flambe's end with sound loading/playing.

@volkipp
Copy link
Contributor Author

volkipp commented May 8, 2013

I couldn't see anything there either that would have affected sound playback. At first I thought it was a MS software update, but setting my Flambe version back down to 2.2b re-introduced the delay.... Anyway, I'm glad it's working now!

@aduros
Copy link
Owner

aduros commented May 8, 2013

Asset loading internals have changed substantially since 2.2b, but sound shouldn't be affected... but good to hear anyways :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants