MediaPlayer starts playback with wrong volume
-
Hello together,
I'm facing some unexpected behavior when using Qml MediaPlayer (also QMediaPlayer). I want to preload sounds due to performance reasons. Therefore I already create a QMediaPlayer and set it's media in advance.
As the volume is dependent to a setting, I set the volume and call play in order to start the sound playback. The issue is, that the sound then starts with 100% volume and after a short while the volume gets reduced to the selected one.
This only happens the very first time the sound gets started, when the status of the player isLoaded
. As a workaround I figured out, that callingpause
changes the status toBuffered
and then the issue does not occur, but this is only a workaround in my point of view.See following short example to reproduce the issue. (Happens with gsteramer version 1.0)
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtMultimedia 5.15 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") MediaPlayer { id: player } Column { Text { text: "Media status: " + player.status } Button { text: "Load Sound" onClicked: player.source = "qrc:/taunt.wav" } Button { text: "Play Sound" onClicked: { player.volume = 0.1 // Workaround: // if (player.status === MediaPlayer.Loaded) // player.pause() player.play() } } } }