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
221b096b
Commit
221b096b
authored
Sep 16, 2017
by
kroovy
Browse files
implement stop api
parent
7001182b
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/player.py
View file @
221b096b
...
...
@@ -11,6 +11,7 @@ class Player(threading.Thread):
def
__init__
(
self
):
super
().
__init__
(
target
=
self
)
self
.
_logger
=
logging
.
getLogger
(
"player"
)
self
.
running
=
True
;
def
play
(
self
,
filename
):
self
.
_logger
.
info
(
"start playing {}"
.
format
(
filename
))
...
...
@@ -26,7 +27,7 @@ class Player(threading.Thread):
output
=
True
)
data
=
wave_file
.
readframes
(
chunk
)
while
len
(
data
)
>
0
:
while
len
(
data
)
>
0
and
self
.
running
:
stream
.
write
(
data
)
data
=
wave_file
.
readframes
(
chunk
)
...
...
web/views.py
View file @
221b096b
...
...
@@ -35,6 +35,8 @@ def play(file):
If queing is successfull return the position in the queue. Play the
oldest song in the queue. """
api
.
player
.
player
.
running
=
True
;
if
api
.
index
.
is_indexed
(
file
):
try
:
api
.
queue
.
q
.
put
(
file
,
False
)
...
...
@@ -44,3 +46,15 @@ def play(file):
return
jsonify
({
"queue_size"
:
api
.
queue
.
q
.
qsize
()})
else
:
return
abort
(
404
)
@
web
.
route
(
"/stop/"
)
def
stop
():
""" Immediatly stop the playing song. """
#TODO
api
.
player
.
player
.
running
=
False
;
while
(
api
.
queue
.
qsize
()
!=
0
):
print
(
">>> qsize = {}"
.
format
(
api
.
queue
.
qsize
())
api
.
queue
.
get
()
return
"stopped"
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