Add carbon support.
parent
5f198c92cc
commit
e089f4d0e3
9
host.py
9
host.py
|
@ -4,6 +4,7 @@ import sys
|
|||
import os
|
||||
import time
|
||||
import random
|
||||
import socket
|
||||
import pygame
|
||||
|
||||
from pygame.locals import *
|
||||
|
@ -28,6 +29,12 @@ MAPPING = [
|
|||
|
||||
SPATH = "sounds/"
|
||||
|
||||
def logmesohard(name):
|
||||
s = socket.socket()
|
||||
s.connect(('10.8.1.1', 2003))
|
||||
s.sendall('hackerspace.soundboard.{} 1'.format(name.replace('.', '_'_)))
|
||||
s.close()
|
||||
|
||||
class SimpleSound:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
@ -36,6 +43,7 @@ class SimpleSound:
|
|||
self.s = pygame.mixer.Sound(SPATH + self.path)
|
||||
def play(self):
|
||||
print("Playing {}".format(self.path))
|
||||
logmesohard(self.path)
|
||||
self.s.play()
|
||||
return self.s.get_length() * 0.5
|
||||
|
||||
|
@ -47,6 +55,7 @@ class RandomSound:
|
|||
self.sounds = [(pygame.mixer.Sound(SPATH + p), p) for p in self.paths]
|
||||
def play(self):
|
||||
s, path = random.choice(self.sounds)
|
||||
logmesohard(self.paths[0])
|
||||
print("Playing {}".format(path))
|
||||
print(s)
|
||||
s.play()
|
||||
|
|
Loading…
Reference in New Issue