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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support