Sound plugins using pycanberra and gst-python

This commit is contained in:
Dmitri Bogomolov 2017-09-11 17:44:17 +03:00
parent 1f47a4060e
commit 53c3eeb8f7
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 38 additions and 0 deletions

View File

@ -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]'
],

View File

@ -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

View File

@ -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)