Setting volume per instance in QML Audio/Video elements?

I want to fade out the volume of an audio file while fading in the sound of a video in QML. This should be no problem with animations, but I'm hitting a wall here. It seems like the volume property is somehow shared between all instances of all media elements in QML. See for example the following code:

Rectangle
{
    id:mainScreen
    focus: true

    Video
    {
        id:video
        anchors.fill: parent
        source: "path/to/file.mp4";
        volume:1
        onVolumeChanged: console.warn("video: "+volume)
        autoPlay: true
    }
    Audio
    {
        source: "path/to/file.mp3";
        id:audio
        volume:1
        onVolumeChanged: console.warn("audio: "+volume)
        autoPlay: true
    }


    Keys.onPressed:
    {
        audio.volume = Math.random(1);
    }
}

When I press a key, the onVolumeChanged-Handlers of both video and audio are called. Is there a way to control the volume of the elements independently?

Or should I file a Qt bug report? This is the OpenGL MSVC2010 build of Qt 5.2.0 in case it matters.

Answers


Kakadu, you were right. I hit this bug and the provided patch fixes it! With that patch, everything works as-is.


Need Your Help

PHP: Convert hex color from color input to PHP hex number

php colors hex color-picker

I want to convert my hex color from a color input (example: #FFFFFF) to a PHP hex number format (example: 0xFFFFFF).

How to use curl to get a GET request exactly same as using Chrome?

curl user-agent

I have a web api http://something.com/api and I want to use GET to get the response body.