Added sound notification (for Windows) if not all files are same in one room

This commit is contained in:
Uriziel 2013-01-06 14:18:52 +01:00
parent 59b0cd0b6a
commit 65f3fc87ef
7 changed files with 31 additions and 13 deletions

View File

@ -27,6 +27,7 @@ info = dict(
'compressed': 1
}
},
data_files = [("resources", ["resources/buzzer.wav",]), ("", ["resources/syncplayClientForceConfiguration.bat",])],
zipfile = "lib/libsync",
)

BIN
resources/buzzer.wav Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
Syncplay.exe -g

View File

@ -6,6 +6,7 @@ from twisted.internet.protocol import ClientFactory
from twisted.internet import reactor, task
from syncplay.protocols import SyncClientProtocol
from syncplay import utils, constants
from syncplay.ui import sound
from syncplay.messages import getMessage
class SyncClientFactory(ClientFactory):
@ -195,7 +196,8 @@ class SyncplayClient(object):
if (paused == False and roomFilesDiffer):
self.userlist.roomCheckedForDifferentFiles()
self._player.displayMessage(getMessage("en", "room-files-not-same"), constants.DIFFERENT_FILE_MESSAGE_DURATION)
sound.doBuzz()
def _changePlayerStateAccordingToGlobalState(self, position, paused, doSeek, setBy):
madeChangeOnPlayer = False
pauseChanged = paused != self.getGlobalPaused()

View File

@ -2,7 +2,7 @@ from ConfigParser import SafeConfigParser
import argparse
import os
import sys
from syncplay import constants
from syncplay import constants, utils
from syncplay.messages import getMessage
try:
from syncplay.ui.GuiConfiguration import GuiConfiguration
@ -131,18 +131,8 @@ class ConfigurationGetter(object):
host, port = host.split(':', 1)
return host, int(port)
def _findWorkingDir(self):
frozen = getattr(sys, 'frozen', '')
if not frozen:
path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
elif frozen in ('dll', 'console_exe', 'windows_exe'):
path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
else:
path = ""
return path
def _checkForPortableFile(self):
path = self._findWorkingDir()
path = utils.findWorkingDir()
if(os.path.isfile(os.path.join(path, constants.DEFAULT_CONFIG_NAME))):
return os.path.join(path, constants.DEFAULT_CONFIG_NAME)

11
syncplay/ui/sound.py Normal file
View File

@ -0,0 +1,11 @@
try:
import winsound
except ImportError:
winsound = None
from syncplay import utils
def doBuzz():
buzzPath = utils.findWorkingDir() + "\\resources\\buzzer.wav"
print buzzPath
if(winsound):
winsound.PlaySound(buzzPath, winsound.SND_FILENAME|winsound.SND_ASYNC)

View File

@ -3,6 +3,8 @@ import re
import datetime
from syncplay import constants
from syncplay.messages import getMessage
import sys
import os
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
"""Retry calling the decorated function using an exponential backoff.
@ -75,3 +77,14 @@ def formatTime(timeInSeconds):
return '{0:02.0f}:{1:02.0f}:{2:02.0f}'.format(hours, minutes, seconds)
else:
return '{0:02.0f}:{1:02.0f}'.format(minutes, seconds)
def findWorkingDir():
frozen = getattr(sys, 'frozen', '')
if not frozen:
path = os.path.dirname(os.path.dirname(__file__))
elif frozen in ('dll', 'console_exe', 'windows_exe'):
path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
else:
path = ""
return path