OtherAudioIsPlaying

Hello, all.

I just noticed that something stopped working in my app. I haven’t pinpointed exactly when it changed, but I figure it was around build 591.

I had code similar to this in my app:

[lua]-- in main.lua
local function set_audio(event)
if (not event or event.type == “applicationResume”)
and audio.getSessionProperty( audio.OtherAudioIsPlaying ) == 1 then
audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)
end
end
Runtime:addEventListener( “system”, set_audio )
set_audio()

– in an included module
function play_music(music, options)
if audio.getSessionProperty( audio.OtherAudioIsPlaying ) ~= 1 then
audio.play(music, options)
end
end[/lua]

…and this worked relatively well for allowing external music to continue playing when starting my app. However, I believe somewhere along the line this broke, because I just noticed my app took over the audio once again.

I know this is an undocumented, unsupported API…but I figured I’d ask if there was any info on what may have changed? …or maybe it’s gone completely? …or maybe it’s still working and the error’s on my end? hehe Thanks in advance for your help. [import]uid: 21712 topic_id: 13925 reply_id: 313925[/import]

This is going to sting:

The features I talk about in this article are untested, unsupported, and we reserve the right to remove these APIs at any time. Use at your own risk. We do not want these features to be support issues for us, so do not send us bug reports with code using any of these features.

directly from Eric’s blog

http://blog.anscamobile.com/2011/07/the-secretundocumented-audio-apis-in-corona-sdk/

.- Eric is OOO so as soon as he gets back depending on his work load he may look at it.

Thanks :wink:

.c
[import]uid: 24 topic_id: 13925 reply_id: 51622[/import]

@Carlos

Thanks. Yeah, I knew…hence why I said “I know this is an undocumented, unsupported API”. I just figured someone might have an answer. Thanks…hope it makes it back in. [import]uid: 21712 topic_id: 13925 reply_id: 51624[/import]

Nothing was removed or changed as far as I know. We haven’t touched that section of code in quite awhile. What your are trying to do should work.

Can you verify audio.getSessionProperty( audio.OtherAudioIsPlaying ) is returning what you think it is? Apple says it will return a non-zero value if true, so it may not actually be 1 and your comparison will fail.

Some other random things to try:

  • Make sure this used to work for you (use older build)
  • Try setting a different category for comparison.
  • Try setting audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode) in a performWithDelay callback in your resume event. Maybe there is an ordering bug where the audio engine is still shutdown in the resume callback and the call is ignored. But I thought we already fixed that once.

Also, a note, don’t try changing the audio category on a suspend event. By that point, it’s already too late to change it the category to prevent the current set behavior.

[import]uid: 7563 topic_id: 13925 reply_id: 51637[/import]

@ewing

Thanks for responding. Glad to hear it’s an error on my end…hehe I’ll take a look later tonight or tomorrow night; I have no doubt I wrote it incorrectly. Thanks for the input.

…and thanks again for publicizing the APIs. I know it’s thin ice stuff, but I’m loving it. hehe [import]uid: 21712 topic_id: 13925 reply_id: 51638[/import]

@ewing

Just an update…sorry for the false alarm, but now I can’t get it to break again. hehe So, it appears as though it is working. I may change that comparison to check for zero like you said…but overall, it’s working fine.

If there is some fringe case where it doesn’t work, I’ll wait for someone to report it, but I’m not too worried about it. Thanks again for everything.
Sincerely,
Christopher David YUDICHAK [import]uid: 21712 topic_id: 13925 reply_id: 52015[/import]