Sound plugins using pycanberra and gst-python
parent
1f47a4060e
commit
53c3eeb8f7
@ -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…
Reference in New Issue