sound notifications
This commit is contained in:
parent
371ae6a622
commit
ba3261b76b
@ -18,11 +18,12 @@ Toxygen is simple [Tox](https://tox.chat/) client written on pure Python 2.7
|
|||||||
- [x] Avatars
|
- [x] Avatars
|
||||||
- [x] Multiprofile
|
- [x] Multiprofile
|
||||||
- [x] Multilingual
|
- [x] Multilingual
|
||||||
|
- [x] Sound notifications
|
||||||
- [ ] Inline images
|
- [ ] Inline images
|
||||||
- [ ] Sound notifications
|
|
||||||
- [ ] Audio
|
- [ ] Audio
|
||||||
- [ ] Video
|
- [ ] Video
|
||||||
- [ ] Save file encryption
|
- [ ] Save file encryption
|
||||||
|
- [ ] File resuming
|
||||||
- [ ] Typing notifications
|
- [ ] Typing notifications
|
||||||
- [ ] Changing nospam
|
- [ ] Changing nospam
|
||||||
- [ ] Group chats
|
- [ ] Group chats
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from PySide import QtGui, QtCore
|
from PySide import QtGui, QtCore
|
||||||
from PySide.phonon import Phonon
|
|
||||||
from util import curr_directory
|
from util import curr_directory
|
||||||
# TODO: rewrite sound notifications
|
import wave
|
||||||
|
import pyaudio
|
||||||
|
|
||||||
|
|
||||||
SOUND_NOTIFICATION = {
|
SOUND_NOTIFICATION = {
|
||||||
@ -32,6 +32,30 @@ def tray_notification(title, text, tray, window):
|
|||||||
tray.connect(tray, QtCore.SIGNAL("messageClicked()"), message_clicked)
|
tray.connect(tray, QtCore.SIGNAL("messageClicked()"), message_clicked)
|
||||||
|
|
||||||
|
|
||||||
|
class AudioFile(object):
|
||||||
|
chunk = 1024
|
||||||
|
|
||||||
|
def __init__(self, fl):
|
||||||
|
self.wf = wave.open(fl, 'rb')
|
||||||
|
self.p = pyaudio.PyAudio()
|
||||||
|
self.stream = self.p.open(
|
||||||
|
format=self.p.get_format_from_width(self.wf.getsampwidth()),
|
||||||
|
channels=self.wf.getnchannels(),
|
||||||
|
rate=self.wf.getframerate(),
|
||||||
|
output=True
|
||||||
|
)
|
||||||
|
|
||||||
|
def play(self):
|
||||||
|
data = self.wf.readframes(self.chunk)
|
||||||
|
while data:
|
||||||
|
self.stream.write(data)
|
||||||
|
data = self.wf.readframes(self.chunk)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.stream.close()
|
||||||
|
self.p.terminate()
|
||||||
|
|
||||||
|
|
||||||
def sound_notification(t):
|
def sound_notification(t):
|
||||||
"""
|
"""
|
||||||
Plays sound notification
|
Plays sound notification
|
||||||
@ -43,6 +67,6 @@ def sound_notification(t):
|
|||||||
f = curr_directory() + '/sounds/file.wav'
|
f = curr_directory() + '/sounds/file.wav'
|
||||||
else:
|
else:
|
||||||
f = curr_directory() + '/sounds/contact.wav'
|
f = curr_directory() + '/sounds/contact.wav'
|
||||||
m = Phonon.MediaSource(f)
|
a = AudioFile(f)
|
||||||
player = Phonon.createPlayer(Phonon.MusicCategory, m)
|
a.play()
|
||||||
player.play()
|
a.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user