Sound plugins using pycanberra and gst-python

master
Dmitri Bogomolov 6 years ago
parent 1f47a4060e
commit 53c3eeb8f7
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

@ -304,6 +304,9 @@ if __name__ == "__main__":
'[gir, notify2]'
],
'bitmessage.notification.sound': [
'theme.canberra = pybitmessage.plugins.sound_canberra',
'file.gstreamer = pybitmessage.plugins.sound_gstreamer'
'[gir]',
'file.fallback = pybitmessage.plugins.sound_playfile'
'[sound]'
],

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from pybitmessage.bitmessageqt import sound
import pycanberra
_canberra = pycanberra.Canberra()
_theme = {
sound.SOUND_UNKNOWN: 'message-new-email',
sound.SOUND_CONNECTED: 'network-connectivity-established',
sound.SOUND_DISCONNECTED: 'network-connectivity-lost',
sound.SOUND_CONNECTION_GREEN: 'network-connectivity-established'
}
def connect_plugin(category, label=None):
try:
_canberra.play(0, pycanberra.CA_PROP_EVENT_ID, _theme[category], None)
except (KeyError, pycanberra.CanberraException):
pass

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst # noqa: E402
Gst.init(None)
_player = Gst.ElementFactory.make("playbin", "player")
def connect_plugin(sound_file):
_player.set_state(Gst.State.NULL)
_player.set_property("uri", "file://" + sound_file)
_player.set_state(Gst.State.PLAYING)
Loading…
Cancel
Save