Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Audio Component Distorted on Mobile App when Game Loses Focus

I'm developing a mobile game and right now I'm testing on an Android OS (Samsung Galaxy S8). I've got a master level and two streaming levels. In the master level I have an audio component to play a looping background music (sound cue).

This works fine but when I press the home key on my phone or if the app loses focus in any way the music gets distorted for a second and then shuts off. I'm ok with the music shutting off, ideally all sounds should shut off when the game loses focus. But the distortion right before it shuts off sounds bad.

Is there any way I can catch mobile/Android event for when the home button is clicked or when the game is no longer focused? A few things I've tried:

  • Custom GameViewportClient class that catches the LostFocus and ReceivedFocus events. No effect on my issue

  • Catching GameInstance.AppWillTerminate and AppWillEnterBackground. Same as above, no effect

  • Catching GameInstance.AppWillDeactivate. This had a noticeable effect, basically the sound did shut off without distortion but it takes a few seconds after the app has lost focus.

When catching these events I've tried both stopping the audio component and setting the volume level to 0. Stopping the audio component doesn't seem to do anything and setting the volume to 0 only had an effect when used with the AppWillDeactivate event.

An ideal scenario would be catching some sort of lost focus event and stopping the music as an instantaneous transaction - no delay and no distortion. Is there any way to do this?

Product Version: UE 4.20
more ▼

asked Aug 19 '18 at 06:01 AM in Everything Else

avatar image

1 1 4

avatar image Thokash Aug 19 '18 at 06:05 AM

Also I want to add that the method I thought worked (AppWillDeactivate setting a volume of 0) still has distortion half the time. It's inconsistent, I really don't know why the audio doesn't just shut off entirely.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

This issue goes away when you package the game for distribution. I guess when you're just pushing it to your device it's still set in "editor" mode.

more ▼

answered Aug 29 '18 at 09:47 PM

avatar image

1 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question