FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 00e87b27 authored by Silas S. Brown's avatar Silas S. Brown
Browse files

player utility

parent d6d94651
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,8 @@ online synthesizers (or real people) to the synth cache
transliterate.py - make a transliterated vocab report
(for use with grep or on PDAs or whatever)
player.py - play
diagram.py - make a diagram of a gradint lesson
trace.py - make a raytraced animation of a lesson
#!/usr/bin/env python2
# Simple sound-playing server
# Silas S. Brown - public domain - no warranty
# connect to port 8124 (assumes behind firewall)
# and each connection can send WAV or MP3 data
# so gradint advanced.txt can do
# wavPlayer = mp3Player = "nc HostName 8124 -q 0 <"
import socket, os
os.environ["PATH"] += ":/usr/local/bin"
s=socket.socket()
s.bind(('',8124))
s.listen(5)
while True:
c,a = s.accept()
d = c.recv(4)
if d=='RIFF': player = "play - 2>/dev/null" # WAV
elif d=='STOP':
c.close()
while not d=='START':
c,a = s.accept() ; d = c.recv(5) ; c.close()
continue
else: player = "mpg123 - 2>/dev/null" # MP3
player = os.popen(player,"w")
while d:
try: player.write(d)
except IOError: break # it was probably killed
d = c.recv(4096)
try:
c.close() ; player.close()
except: pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment