Zren / plasma-applets

This monolithic repo has been broken up into individual repos for each widget.
84 stars 23 forks source link

Timer notification sound #23

Closed vmorenomarin closed 8 years ago

vmorenomarin commented 8 years ago

Hi.

Is there a way to add a sound to the notification when timer has ended?

Thanks.

Zren commented 8 years ago

So, KDE doesn't completely follow the notification spec (yet?) which does specify sounds (which is what I experimented the first time I went looking).

I could however probably play a SoundEffect with QML with a filename entered in the config.

Having the sound file managed in the SystemSettings > Notifications would be nice, but seems ridiculously complicated for a pure QML appplet.

import QtMultimedia 5.6

    function createNotification() {
        //...
        playSound.play()
    }

    SoundEffect {
        id: playSound
        source: "file:///usr/share/sounds/Oxygen-Sys-Warning.ogg"
        // source: "Oxygen-Sys-Warning.ogg"
    }

Doesn't seem to work QSoundEffect(pulseaudio): Error decoding source. Permission error mayhaps? Nyways, I'll look into it eventually.

Zren commented 8 years ago

Uhg, looks like I was using the wrong class. SoundEffect is used for playing uncompressed file types like wav. I need to use Audio class. Now to pick a good default sound (I'll probably need a file chooser in the settings).

import QtQuick 2.0
import QtMultimedia 5.6

Item {
    Audio {
        id: playSound
        source: "/usr/share/sounds/freedesktop/stereo/complete.oga"
        source: "complete"
    }
    Component.onCompleted: {
        playSound.play()
    }
}
Zren commented 8 years ago

Added in v30.

vmorenomarin commented 8 years ago

Thansk a lot!!!