Commit 43cfd7ff authored by Andre Julius's avatar Andre Julius 👀
Browse files

Move existing file test into views.py

parent d9b9bddb
......@@ -5,19 +5,18 @@ from config import datadir
def play(filename):
if api.index.is_indexed(filename):
wave_file = wave.open(datadir + "/" + filename)
p = pyaudio.PyAudio()
chunk = 1024
stream = p.open(
format=p.get_format_from_width(
wave_file.getsampwidth()
),
channels=wave_file.getnchannels(),
rate=wave_file.getframerate(),
output=True
)
wave_file = wave.open(datadir + "/" + filename)
p = pyaudio.PyAudio()
chunk = 1024
stream = p.open(
format=p.get_format_from_width(
wave_file.getsampwidth()
),
channels=wave_file.getnchannels(),
rate=wave_file.getframerate(),
output=True
)
data = wave_file.readframes(chunk)
while data != '':
stream.write(data)
data = wave_file.readframes(chunk)
while data != '':
stream.write(data)
data = wave_file.readframes(chunk)
......@@ -20,4 +20,8 @@ def index():
@web.route("/play/<file>")
def play(file):
api.player.play(file)
if api.index.is_indexed(file):
api.player.play(file)
else:
return abort(404)
return "done"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment