4

I'm developing an Android/iOS webradio application with Qt Quick in qml. To play my radio stream I use a MediaPlayer qml element and I would like to add a slider to control the volume of the playing music.

For now, I've tried to use a slider link to the MediaPlayer volume property, but this do not control the device volume. Indeed, in Android as in iOS, when I change the slider value only the MediaPlayer volume is changed. And when I press the volume buttons of the device the slider is not impacted.

What I want is a slider with which I could see and control the volume of the device, not only the volume of the MediaPlayer element.

Does anyone know how to do this ?

Julien Chevet
  • 513
  • 5
  • 12
  • There might be an easier and cross platform way to do this, but it's possible to use Java Native Interface (JNI) to be able to call Java/Android API code from your program. I am sure there is something similar for iOS as well. Let us know if you figure it out =) – uniquenamehere Jan 10 '15 at 01:30

1 Answers1

0

As of today, Qt doesn't seems to support setting the global device volume from QML neither C++. You can only set the volume of individual streams of audio generated through Qt. Your best bet would be to connect your slider's signal to a c++ class and from there run native iOS/Android code to set the device volume.

You can check out this question which explains how to do it on iPhone. Something similar is also available for Android.

For cross-platform support, you must do it the old way, which means that the class handling the volume should have access to a generic interface that is platform independent and that has multiple implementations for each platform you wish to support. The decision of which platform-dependant implementation to choose should be done in compilation.

As I said though, this is early 2015. Qt is rapidly evolving and you could see a new class popping up soon in QtMultimedia that handles this for all platforms.

Community
  • 1
  • 1