Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Kruse
potify
Commits
43cfd7ff
Commit
43cfd7ff
authored
Sep 11, 2017
by
Andre Julius
👀
Browse files
Move existing file test into views.py
parent
d9b9bddb
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/player.py
View file @
43cfd7ff
...
...
@@ -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
)
web/views.py
View file @
43cfd7ff
...
...
@@ -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"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment