Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › Audio keeps playing when app is in the background

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22569

    sAMA SAMA

    I have a soundtrack to be played through the run time as the main theme:

    App{
          ...............
       Audio{
            source: "../assets/Art Of Silence_V2.mp3"
            autoPlay: true
            loops : Audio.Infinite
       }
          .......
    }

    <div class=”post-text”>

    How do I stop it from playing when the app is in the background and resume it afterwards?

    </div>
    <div class=”post-taglist grid gs4 gsy fd-column”>I tried changing the code to this:</div>
    <div>

    Audio{
            readonly property bool forground : Window.visibility !== Window.Minimized &&
                                                 Window.visibility !== Window.Hidden
            source: "../assets/Art Of Silence_V2.mp3"
            autoPlay: true
            loops : Audio.Infinite
            onForgroundChanged: { forground ? start() : stop() }
       }

    SinceAppĀ is a subclass of Window it should have worked but it didn't, what can I do?

     

    </div>

    #22570

    Alex
    Felgo Team

    I guess you need too give your App component an id, e.g. “app” and then you can check app.visibility.

    Also you can use onApplicationPaused and onApplicationResumed signal handlers of the App component.

    Alternatively you can also use the BackgroundMusic component, which already handles this for you.

    Cheers,
    Alex

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.