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

Forums

OverviewFelgo 3 Support (Qt 5) › Android Hardware Volume Buttons

Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9771

    Alec

    Hi,

     

    Is there any way to force the Android hardware volume buttons to control the media volume. Something like the native call

     

    setVolumeControlStream(AudioManager.STREAM_MUSIC)

     

    If a sound effect is playing in my game, the volume buttons control the media volume. However, if no sound effect is playing, the buttons control the ringtone volume. As I’m only using very short sound effects it is very difficult to control the volume and users won’t know to press the buttons when a sound is playing.

     

    This was tested on a device running Lollipop and it also happens in the AudioTest example (it makes more sense in that context though).

     

    Any help would be much appreciated.

     

    alb

    #9818

    Günther
    Felgo Team

    Hi alb!

    Sadly, we never encountered a use-case where we had to change this setting with Qt/Qml up until now … maybe you can get an answer on how to do it at the official Qt/Qml support forums.

    In case you do not find a good answer, I tried to solve your problem by using a little “hack”:
    At least for my android phone and the current qt version, it works if a muted sound is played endlessly in the background of the app. The device is then tricked into thinking that music is playing and lets you control the media volume. (even though nothing can actually be heard)

    This is how I did it:

    import QtMultimedia 5.0
    
    // ...
    
    Scene {
    
    
        BackgroundMusic {
          id: muted_loop
          loops: SoundEffect.Infinite
          muted: true
          source: "../assets/Click1.wav"
        }
    
        // ...
    }
    
    // ...

     

    Cheers,

    GT

     

     

     

     

    #9820

    Alec

    Thanks for getting back to me. Your workaround seems like a decent solution, I’ll give it a try.

     

    If the qt forums have a better answer, I’ll post it here.

Viewing 3 posts - 1 through 3 (of 3 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