Playing audio file with QMediaPlayer pause Media player

Hi.

I am using QMediaPlayer with QMediaPlaylist to play short audio samples. Source code is here: https://github.com/Framstag/libosmscout/blob/master/libosmscout-client-qt/src/osmscout/InstalledVoicesModel.cpp#L138

It works fine, but when some music is played by Jolla Media Player, it is paused in the moment when start playing my samples… I tried to setup different audio roles, for example mediaPlayer->setAudioRole(QAudio::NotificationRole); but without success. Moreover, mediaPlayer->supportedAudioRoles(); gives me empty list.

I tried to search related pulseaudio features, but without success.

output of pacmd list-sink-inputs:

    index: 13
        driver: <protocol-native.c>
        flags: START_CORKED 
        state: CORKED
        sink: 0 <sink.primary>
        volume: front-left: 15246 /  23% / -38,00 dB,   front-right: 15246 /  23% / -38,00 dB
                balance 0,00
        muted: no
        current latency: 110,00 ms
        requested latency: 80,00 ms
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        resample method: speex-fixed-2
        module: 15
        client: 11 <jolla-mediaplayer>
        properties:
                media.name = "'Tarantula' by '$pyda/Fresh/Pendulum/Tenor Fly'"
                application.name = "jolla-mediaplayer"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "32"
                application.process.id = "19088"
                application.process.user = "nemo"
                application.process.host = "Sailfish"
                application.process.binary = "threaded-ml"
                application.language = "cs_CZ.utf8"
                application.process.machine_id = "1e2da36a728b4bbabd8ddd58634d2cbe"
                application.process.arg0 = "/usr/bin/jolla-mediaplayer"
                policy.group = "player"
                policy.stream_flags = hex:00000000
                media.role = "x-maemo"
                module-stream-restore.id = "sink-input-by-media-role:x-maemo"
                media.title = "Tarantula"
                media.artist = "$pyda/Fresh/Pendulum/Tenor Fly"
    index: 322
        driver: <protocol-native.c>
        flags: START_CORKED 
        state: RUNNING
        sink: 0 <sink.primary>
        volume: front-left: 15246 /  23% / -38,00 dB,   front-right: 15246 /  23% / -38,00 dB
                balance 0,00
        muted: no
        current latency: 93,85 ms
        requested latency: 80,00 ms
        sample spec: float32le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        resample method: speex-fixed-2
        module: 15
        client: 157 <harbour-osmscout>
        properties:
                media.name = "Playback Stream"
                application.name = "harbour-osmscout"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "32"
                application.process.id = "30408"
                application.process.user = "nemo"
                application.process.host = "Sailfish"
                application.process.binary = "booster-silica-qt5"
                application.language = "cs_CZ.utf8"
                application.process.machine_id = "1e2da36a728b4bbabd8ddd58634d2cbe"
                application.process.arg0 = "/usr/bin/harbour-osmscout"
                policy.group = "player"
                policy.stream_flags = hex:00000000
                media.role = "x-maemo"
                module-stream-restore.id = "sink-input-by-media-role:x-maemo"

I tried to reproduce it with paplay with various properties, but without success too :frowning:

paplay -v --property=media.role=x-maemo --property=policy.group=player sample.ogg

It is possible to keep player playing, possibly just decrease volume for short time?

If you’re just playing short sounds, QSoundEffect is a better choice and wont pause the media player

1 Like