Sounds loaded with audio.loadStream won't play in some cases.

Hello everyone,

I noticed some weird behavior with the audio library.

In the audio api there are two different functions to load an audio file, loadSound and loadStream. On windows, both work fine if used alone, but there seems to be a problem if I load and play more than one type of sound (using different file sources). If I play a sound loaded with loadSound on a given channel, it seems that channel will no longer play a “stream” sound.

For instance, the following code fails at playing the music

local sfx = audio.loadSound("sound.ogg") local stream = audio.loadStream("music.ogg") audio.play(sfx) audio.play(stream)

but if I play the stream audio first it works

local sfx = audio.loadSound("sound.ogg") local stream = audio.loadStream("music.ogg") audio.play(stream) audio.play(sfx)

or if I specify a channel that was not yet play by the “sfx”:

local sfx = audio.loadSound("sound.ogg") local stream = audio.loadStream("music.ogg") audio.play(sfx) audio.play(stream, { channel = 2 })

I just tested this out on a real device and the WP8 emulator.  Unfortunately, I’m not able to reproduce the issue you’re seeing.

(Yes, I’ve tried you’re first code example where you play the sound before the stream.)

Perhaps it might depend on the size of your audio files.  Would you mind sending your 2 ogg files to us so that we can try it out please?

The best way to do that is to click the “Report a Bug” link at the top of this web page.  Zip up your 2 ogg files, attach it to the report, and reference this forum thread and my name “Joshua Quick” so that our support team will send the bug report my way.  I’ll look into it today.  Thanks in advance.

Hey Joshua,

Just posted a bug report, and attached 2 sound files that I used to test, case number 36109. While writing the test case to report I noticed that when simplify my code to post here I cut one step necessary to reproduce. Sorry about that.

The streamed audio should be played after the sound has finished playing. Indeed if you run the code I posted, both audio will play, one in channel 1 the other on channel 2. If you place the second playAudio in a timer, delaying it enough for the first audio to have fully played, it wont play.

In the bug reported I included both audio files and the code I used to reproduce the bug.

Thanks for the bug report and sample project.  I was able to reproduce the issue with it.  I’ll look into solving it tomorrow.

If I had to guess, I *think* this issue only happens when you re-use an audio channel for streaming after it was already used to play a whole sound.  So, if you dedicated a particular channel to only be used for streaming sounds then it would be okay.  Anyways, that’s my rough guess at the moment.  I’ll make this my top priority and have it solve as soon as I can.

Hey Joshua,

I think the issue is on the re-use channel too. I reserved a channel for streamed audio only and it seems to be working, haven’t noticed it failing to play after that, even stopping and switching to different streamed audio files.

This issue is now solved.  The next WP8 CoronaCards update that we’ll send your way will have the fix.

I just tested this out on a real device and the WP8 emulator.  Unfortunately, I’m not able to reproduce the issue you’re seeing.

(Yes, I’ve tried you’re first code example where you play the sound before the stream.)

Perhaps it might depend on the size of your audio files.  Would you mind sending your 2 ogg files to us so that we can try it out please?

The best way to do that is to click the “Report a Bug” link at the top of this web page.  Zip up your 2 ogg files, attach it to the report, and reference this forum thread and my name “Joshua Quick” so that our support team will send the bug report my way.  I’ll look into it today.  Thanks in advance.

Hey Joshua,

Just posted a bug report, and attached 2 sound files that I used to test, case number 36109. While writing the test case to report I noticed that when simplify my code to post here I cut one step necessary to reproduce. Sorry about that.

The streamed audio should be played after the sound has finished playing. Indeed if you run the code I posted, both audio will play, one in channel 1 the other on channel 2. If you place the second playAudio in a timer, delaying it enough for the first audio to have fully played, it wont play.

In the bug reported I included both audio files and the code I used to reproduce the bug.

Thanks for the bug report and sample project.  I was able to reproduce the issue with it.  I’ll look into solving it tomorrow.

If I had to guess, I *think* this issue only happens when you re-use an audio channel for streaming after it was already used to play a whole sound.  So, if you dedicated a particular channel to only be used for streaming sounds then it would be okay.  Anyways, that’s my rough guess at the moment.  I’ll make this my top priority and have it solve as soon as I can.

Hey Joshua,

I think the issue is on the re-use channel too. I reserved a channel for streamed audio only and it seems to be working, haven’t noticed it failing to play after that, even stopping and switching to different streamed audio files.

This issue is now solved.  The next WP8 CoronaCards update that we’ll send your way will have the fix.