Play Audio on Background Mode

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Armenhui
Posts: 71
Joined: Fri Oct 16, 2015 12:44 pm

Play Audio on Background Mode

Post by Armenhui » Wed Sep 28, 2016 8:20 am

Hi every one.

I want to know can I play audio in background mode on LiveCode (iOS and Android platforms) ?

I mean continue playing audio when the app goes to suspend mode.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Play Audio on Background Mode

Post by Klaus » Wed Sep 28, 2016 10:51 am

Hi Armenuhi,

in the standalone builder settings for iOS check "Background Audio (experimental)"! 8)
Not sure if this is also available for Android.


Best

Klaus

Armenhui
Posts: 71
Joined: Fri Oct 16, 2015 12:44 pm

Re: Play Audio on Background Mode

Post by Armenhui » Wed Sep 28, 2016 12:15 pm

Thanks Klaus for the answer, I already tried this option, but it did not work.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Play Audio on Background Mode

Post by Klaus » Wed Sep 28, 2016 12:43 pm

Hm, it is "experimental"! :D
If it does not work, I would create a bug report here: http://quality.runrev.com

Armenhui
Posts: 71
Joined: Fri Oct 16, 2015 12:44 pm

Re: Play Audio on Background Mode

Post by Armenhui » Wed Sep 28, 2016 1:11 pm

I used LiveCode 8.1.0 stable version, and mobilePlaySoundOnChannel command

I even ticked the Background Audio (experimental) option in the standalone settings. But it still did not work.

If you are going to send a bug report please just send me the link so I can follow the updates. As we need this functionality as soon as possible.

Or if you want I can file a bug report myself.

Thanks
Armenuhi

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Play Audio on Background Mode

Post by Klaus » Wed Sep 28, 2016 1:59 pm

I do not develop for mobile, so you should report this bug!

Armenhui
Posts: 71
Joined: Fri Oct 16, 2015 12:44 pm

Re: Play Audio on Background Mode

Post by Armenhui » Wed Sep 28, 2016 2:43 pm

Ok.

Thanks

joseggarza
Posts: 44
Joined: Thu Jul 24, 2014 8:55 pm

Re: Play Audio on Background Mode

Post by joseggarza » Thu Nov 24, 2016 10:09 pm

Armenhui wrote:Ok.

Thanks
any Updates on this topic?

mattyj2001
Posts: 15
Joined: Tue Apr 04, 2017 8:02 am

Re: Play Audio on Background Mode

Post by mattyj2001 » Tue May 16, 2017 9:03 am

I've been tearing my hair out on this one for a while. I think I figured it out.

According to the comments on a LiveCode lesson named "How do I play sounds on an iOS device?" (forums won't allow me to post a link...) you should be able to set iphoneSetAudioCategory to "playback". I found this doesn't work at all.

What does work is using mergAV to do the same thing. Be sure to include mergAV in your standalone's inclusions and check the 'Background audio (experimental)' box on your iOS Standalone app settings:

Code: Select all

   mergAVAudioSessionSetCategory "playback"
   put specialFolderPath("engine") & "/sound/alert.mp3" into tSound
   play tSound
I also found that mobilePlaySoundOnChannel doesn't work in this context, either, you have to use 'play'.

This will allow your sound to continue playing when your app moves to the background our the mute switch is activated. Also works if the phone is locked during play. Neat!

What I can't figure out, and no docs I can find say anything about it, is if you can start the sound while the app is in the background. The above only allows it to continue playing once it's started.

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 818
Joined: Fri Feb 06, 2015 4:03 pm

Re: Play Audio on Background Mode

Post by LiveCode_Panos » Sun Jun 04, 2017 10:38 am

Hi all,

The fact that setting the iphoneSetAudioCategory to "playback" doesn't work in LC 7+ is a bug, and it will be fixed in LC 8.1.5 RC-1:

https://github.com/livecode/livecode/pull/5446

Best,
Panos
--

Post Reply

Return to “Talking LiveCode”