Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. MediaPlayer starts playback with wrong volume
Forum Updated to NodeBB v4.3 + New Features

MediaPlayer starts playback with wrong volume

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 186 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MeierS
    wrote on last edited by
    #1

    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 is Loaded. As a workaround I figured out, that calling pause changes the status to Buffered 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()
                }
            }
        }
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved