Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Background problem with sound effect

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #8229

    Nour

    Hi

     

    I need to use mp3 sound effects ; just for size purposes, so i used SoundEffectVPlay but it not working for mp3 sounds

    then i tried to run it using BackgroundMusic element, it working well, but when play any sound effect then send the game to mobile background then run it again , the sound run automatically

     

    Scenario again.

    1- add sound element

    BackgroundMusic

        {

            autoPlay: false

            loops: 1

            id:<i>soundShuffling</i>

        }

    2- run it

    <i>soundShuffling.play()</i>

    3- go background and run the game again

    4- the sound play automatically !!!!!!!

    Please advice

    Thanks

    #8230

    Christian
    Felgo Team

    Hi,

    as written in the overview doc and in the docs of SoundEffectVPlay:

    For playing encoded audio files for example in MP3 format or with no latency requirements use the BackgroundMusic component.

    What you are describing is the default behavior on mobile, the audio is resumed when the app gets into foreground again. You can change that default behavior with the BackgroundMusic::autoPauseInBackground property by setting it to false.

    You can then perform your own background handling like that:

     

    Connections {
        target: gameWindow
    
        onApplicationPaused: {     
          // call pause to the backgroundMusic
        }
    
        onApplicationResumed: {
         // dont resume automatically here, but whenever you want it to
        }
      }

     

    Cheers, Chris

     

    #8233

    Nour

    Hi Chris

    I tried to disable “autoPauseInBackground” before, but same thing….Not working

     

    Thanks

    #8236

    Christian
    Felgo Team

    I’ve just tried setting it to both values, and on my test device (Nexus 7, Android 4.4) it behaves as expected:

    • If autoPauseInBackground is true: the music stops when in background and gets resumed when the app gets into foreground again
    • If autoPauseInBackground is false: the music continues playing when in background

    If you want to change these default behaviors, you can use the applicationPaused and applicationResumed signals mentioned above.

    Cheers, Chris

    #8237

    Nour

    Its not music and not pause/resume issue, the sound is very short and i am calling it in game play and stay for 2 sec by max,

    please try to use short mp3 sound effect!!!!

    #8238

    Christian
    Felgo Team

    That is not what you wrote in the first post. Using exclamation marks does not help as well 🙂

    It would be best if you post the example that is not working and provide the sound file that is not working, with a detailed explanation what is not working as expected.

    Anyways, a BackgroundMusic sound is not well suited for short-playing sounds but for long-playing background music. For such short sound files, use SoundEffectVPlay and a wav file.

    Cheers, Chris

    #8240

    Nour

    Hi Chris

    I wrote “sound effect” and i think sound effect is short and there are no need to play it when resume app or come back from background, not like game music  🙂

    i will manage it.

     

    BTW Felgo1 was able to play mp3 files for android which is perfect and good to reduce game size, Strange that i cant play mp3 sound effects with Felgo2

    hope you can implement this soon.

     

    Best

    #8242

    Christian
    Felgo Team

    We are internally using the Qt 5 SoundEffect component for SoundEffectVPlay with a couple of additions like the auto pausing when the app moves to background. You can try if it works with mp3 as well, would be great if you can share it here what you found out.

    Cheers, Chris

    #8243

    Nour

    just solved it by using Audio element

    i imported multimedia library then start using Audio element

    import QtMultimedia 5.0

    Audio

        {

            loops: 1

            id:<i>soundLetsPlay</i>

            source:“letsplay.mp3”

        }

    Regards

    #8244

    Christian
    Felgo Team

    In that case, it should also work the same with BackgroundMusic, which is a wrapper around the Audio element + the autoPause feature. The SoundEffectVPlay component is similarly with a wrapper around the SoundEffect component.

    Cheers, Chris

    • This reply was modified 10 years ago by  Christian.
    #8246

    Nour

    Maybe same, but the different that is if i played a sound for 1 sec and then send app to background and run it again the sound will not replay/autoplay again

    and that solved my problem.

     

    #8248

    Christian
    Felgo Team

    If you set autoPauseInBackground to false, BackgroundMusic behaves exactly like Audio, with the addition that you can enable/disable all music instances via the gameWindow.settings.musicEnabled property.

    Cheers, Chris

    #8252

    Nour

    Yes, i tried autoPauseInBackground but its do nothing

    and gameWindow property looks interesting may i can try it

     

    Thanks

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

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded