@vlads As I mentioned in my private email, the AppLovin plugin is broken for iOS 14+. Does anyone know how to fix it so that audio control and playback will return to Solar2D after displaying the first ad? It works fine for Android but is broken on iOS 14+.
I have spent hours attempting to track down this error and we’ve taken it as far as we can without your help.
You can download my sample project to duplicate the issue. In this folder, you can find a .MOV file to see the problem (hear the game and the ad, but no more game sounds after the ad).
Here is how we’ve fully documented the problem so that you can see it and use our Test Project to try and fix it, but you’ll need to follow the instructions here carefully, mainly, to use your own app id, not ours.
– We have Game playing Music in background all the time.
– We have implemented AppLovin Ads to our Game
– On iOS v12, everything works fine. However, on iOS v14 and v15, because AppLovin Ad will not suspend the App when displayed on screen, we have to stop or pause the Audio and resume or reply again after AppLovin Ad hidden
– We already set the code to stop/pause the audio when Ad display Ad on Screen and resume/replay back when ad hidden
– this code is working perfectly fine on one of our iOS 12 device , but not working correctly on iOS 14 devices (tested on iPhone XR and iPad Pro)
Steps to reproduce BUG :
– you have to update your AppLovin SDK Key in the main.lua (now it has our own game key)
- Open Sample App on your iOS 14 device
- You will hear our game music file playing in background
- Now click “Load Ads”
- After Ad loads successfully, you will see “show Ad” button enabled
- Click “Show Ad” button. The Ad will then be displayed and our Game Music is stopped
- Now close the Ad
- At this point, our code restarts the Game Music after we get ‘hidden’ callback from Applovin
On iOS 14+, we can’t hear any music. You can try clicking the Play Music button again to restart music. As you will see, it’s not working, either.
– We are not sure what’s happening here with Audio library of Solar2D
This example works fine on our iOS 12 test device. The issue occurs on two different iOS 14.5 and 15 test devices.
This seems to be a bug in applovin framework. They tried to fix it. I’m working on a workaround on our side. Aso trying to report it to them.
I have no idea how to reach them, as I had the same idea.
I have the same problem on iOS 15.1. As soon as a rewarded ad has completed I lose all my sound effects. I don’t have game music. The only way I can get my sound effects to resume is to suspend and resume the app. Ouch! Now, if only I knew how to programmatically suspend and resume or some other workaround…
This audio glitch has been a - dare I say it - a feature of mobile development for some years. It was (is?) an ongoing problem for Vungle for many years. LOL!
media.playSound() works after an AppLovin ad has shown. However, the documentation does not recommend using it. Quote from the docs: “Only one sound can be playing using this sound API.”
Also, audio works when playing an AdMob ad after an AppLovin ad. Alas, the audio is only present in the AdMob ad. No sound effects in the app itself once an AppLovin ad has been shown.
Not ideal, but I’ve gone with this solution:
I thought code formatting was enabled by tapping spacebar a few times. I can’t get it to work…
*EDIT - actually - media.playSound() is no good in certain situations. Aargh! Another half day on this pesky sound problem! Hopefully a fix is imminent.
Since the Applovin source code is available to me, if you create a sample app that I can reproduce the problem by typing in my keys. I would take a look at it.
@agramonte - that’s most kind of you. I will do so as soon as I’m back at my desk. Thank you kindly sir
I’ve just noticed that @troylyndon has a sample project linked to in this thread.
@agramonte well, I must say - very kind of you to do that. Thank you so much.
I was puzzled as to why it works for you until I noticed the version of iOS you are running: 12.5.4.
I’m running 15.1 on iPad Mini 4. @troylyndon also has the same problem. iOS 14+ fails to restore sound and yet the sound works fine on iOS 12. Eek!
Someone commented in another thread that if presented with an ‘x’ close button immediately after the end of the ad then sound returns once the ad is closed. If the ad presents you with a ‘>>’ button (and when the user taps that) is presented with a ‘x’ close button then the sounds never returns after the ad is closed.
On a side note - I remain cynical towards AppLovin. Always, they have delayed and delayed presenting the user with a close button. Now they have taken it to another level and give the user a delay, then a ‘>>’ button followed by ‘x’ close button. AppLovin really put obstacles in front of the user to close the ad!
Yes. Applovin is as my daughter likes to say: “sus”. I will test with 14+ and try to fix it.
Suspect is the word! A delay, then the ‘>>’ then the ‘x’. Yikes! Thank you so much for trying to fix the sound issue.
Well, I noticed today while testing it is more like:
Delay then >>> then-new playable screen with a delay then >> then a final screen with a delay then impossible to click the first time x.
On another note, I looked on google and found this issue is common. Apparently, there is no way to stop the applovin videos from stoping your channel unless you make your sounds “ambient mix”. I don’t know what impact this will have on other things but for most games, I believe it will be fine. Please test.
Luckily solar2d already has a function you can call. Adding this to the top of the test app solved the issue for me:
if audio.supportsSessionProperty then audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode) end
@agramonte - wow! I have no idea why or how your fix works - but it does! You’ve got more tricks, magic and powers than Hogwarts, DC and Marvel combined! Not for the first time on here you have worked your magic. All I can say is thank you so much. You have attained the rank of Jedi Master Programmer!
I am sure your work on here is appreciated. I certainly am most impressed!
You are very kind but I am not any of those things. Just an old man from Dominican Republic. But thank you. In my youth I would have taken it to heart.
- Once the game comes back in focus iOS it will throw an error in the console.
- Took the entire error and searched on Google.
- I believe the top entry was the exact same error but in Cordova.
- In that thread there is a solution that uses a call in object c.
- Searched the solar 2d source code for the object c method call and it was already mapped to a Lua function.
- From their it was fairly easy to figure out what options to provide to match the solution for Cordova.
- Tested it out and was surprised that it worked.
Me and my wife have holidayed a couple of times in the Dominican Republic. Lovely part of the world.
As to your point no.7 that always gives a warm glow!
Well, at the risk of tooting my own horn, I have a PhD in Computer Science from The University of Manchester here in the UK. But you sir, and some other developers on here are ahead of me when it comes to many aspects of mobile development. My passion and expertise was formerly software rendering. At one time I had much of the OpenGL calls mimicked in software. Now I can barely recall how to render a textured triangle or camera/view frustum transformations. My new passion as I have reached 50 is in reading novels by the greats - Dickens, Brontes, Austen, Kafka, Hardy, Dostoevsky, Tolstoy and the like. My days of coding low level graphics are long gone!
I’ve been in mobile since 2013 using Corona/Solar 2D and have yet to earn any real money. Not so smart after all!
@agramonte I just wanted to thank you for your solution above. I struggled mightily trying to figure out why IOS devices would not resume audio after playing a video and your three lines of code above did it! Thank you for all that you do for this community.