Allow external music

only using audio.* calls Rob

I have many requests from my app users too, asking why my app stops their background music they are listening to.

I also tested the code 

audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)

And it does NOT work.

My app is totally silent & there is no reason (from user’s perspective) to stop their music. I think this feature is very reasonable & should be added to Corona lib asap.

Just to be sure, you are using this with audio.* calls not media.* calls right?

Also have you verified that:  audio.supportsSessionProperty    is returning true??

Rob

I added following code in the start of main.lua:

if audio.supportsSessionProperty == true then print("\n\naudio.supportsSessionProperty == true\n\n") audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode) end

When my app launches, the print statement is executed, so I am sure audio.supportsSessionProperty is true and the audio.setSessionProperty() is called.

And there are two testing results:

(1) When the background music is playing, launch my app, the background music stops.

(2) Launch my app first, press Home key to put my app in the background and start some background music. Launch my app again (from the background), the music continues.

I think the results above are consistent with “greg886” earlier post:

Update - Tested this Rob.  Unfortunately does not work when you launch your app, i.e. background musics drops off.  I do note if your app was already in the background and then you comeback from “sleep” mode (forget correct term) then it works in this case.

I know this works.  So I did a test and what I found is at least with iTunes and Pandora, when my Corona app launched, the music playing in the background paused.  I could go out, resume play and the audio is mixed as expected.  This is on iOS 7.  Perhaps Apple changed something with iOS 7.  But if I swipe up on the control panel, the music resumes without me having to do anything.

On Android it works as expected.

These modes are technically not supported. 

So I don’t know if we can advise you any further on this.

Rob

I can’t educate the users to launch my app, put it into sleep, start music, and relaunch my app in order to listen to the background music.

I am hoping Corona can add some function to make this work. Is it possible? 

For example, if my app does not play any music/sound, it’s weird/unfriendly that my app turns off users music they are listening to.

Besides, I think there are many cases they like to listen to their music while using apps (most apps provide muting feature so no sounds from the apps and the user can listen to their music while playing them).

By the way, from my testing, Android works even without calling “audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)”

have to totally agree with joe528 (hence the feature request) - I see my 11 year daughter not interested in games where she can’t run her music in the background…

This used to work, for example in recent daily version 2115. We verified in this thread that something has changed now. 

Edit: just to clarify, I mean that the sound from music players does not mute during first launch in version 2115 but does so in latest daily.

Filed a bug repot, Case 30208

Hope Corona can fix this regression bug asap. Already got several user complaints for the same case that my app turns off their music (There was none before this month)

I am pretty sure it’s a regression bug.

Many users of my app complains that they can listen to background music before but after they upgraded to my new release (built with latest Corona daily builds), they cannot listen to background music because my app kills it.

Could you please give this bug a higher priority?

If you have no plan to fix this issue in next 2 daily builds, please let me know right now.

I will build & publish my app with CoronaSDK 2014.2126 right away instead of waiting.

If 2126 works, I would publish with it.  I brought it to their attention yesterday, but there is enough work already assigned for the next couple of daily builds.

I’ve published my app with daily build 2126.

But I hope Corona can help to fix this regression bug ASAP, otherwise it’s holding me to upgrade my app to use the latest Corona build.

For example, the latest fix for webView is something I really like to be included in my app, but I can’t due to this bug (which gives me the most number of my user complaints) 

Thanks.

I filed a bug report for this 10 days ago and it’s case #30208

Got a response from Corona earlier today

This will be fixed in the next daily build (2179 or after)

So it should be fixed soon.

Looking forward to it.

fantastic - will it be fully fixed per the feature request I put in? (link below) - i.e. when asking app not to cut off music it shouldn’t cut if off for both (a) initial start up of app, or (b) subsequent return to app…

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5416670-allow-external-music-audio-to-keep-playing-in-back

@greg886

I think (a) is all about the bug report. And this should be fixed of course.

And (b ) should come with (a), otherwise this bug shouldn’t be considered as being fixed.

We will find out soon. 

This bug has been fixed in the latest build 2179

  • Core/iOS/Audio: Fixes casenum: 30208. Background music from other apps were being stopped when a Corona app launches.

I have tested it and verified I can listen to the background music while my app is launched initially or from the sleeping mode.

I have commented out this block of code, by the way.

--[[if audio.supportsSessionProperty == true then print("\n\naudio.supportsSessionProperty == true\n\n") audio.setSessionProperty(audio.OverrideMixWithOthers, audio.MediaPlaybackMixMode) end]]--

You may want to give it a try to see if you need any additional code to make it work for your case.