libsaria: Added queue_changed callback
This callback is used when ids are either added or removed from the queue.
This commit is contained in:
parent
93f2f6b918
commit
5d336d4815
|
@ -36,3 +36,7 @@ def load_playlist():
|
|||
on_new_source = null_cb
|
||||
def new_source():
|
||||
on_new_source()
|
||||
|
||||
on_queue_changed = null_cb
|
||||
def queue_changed():
|
||||
on_queue_changed()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Bryan Schumaker (5 / 7 / 2011)
|
||||
|
||||
import threading
|
||||
from libsaria import callbacks
|
||||
queue_lock = threading.Lock()
|
||||
lock_queue = queue_lock.acquire
|
||||
unlock_queue = queue_lock.release
|
||||
|
@ -12,6 +13,7 @@ def add_ids(id_list):
|
|||
lock_queue()
|
||||
queue_list.extend(id_list)
|
||||
unlock_queue()
|
||||
callbacks.queue_changed()
|
||||
|
||||
def rm_ids(id_list):
|
||||
lock_queue()
|
||||
|
@ -19,6 +21,7 @@ def rm_ids(id_list):
|
|||
if id in queue_list:
|
||||
queue_list.remove(id)
|
||||
unlock_queue()
|
||||
callbacks.queue_changed()
|
||||
|
||||
def pop():
|
||||
lock_queue()
|
||||
|
@ -26,6 +29,7 @@ def pop():
|
|||
if len(queue_list) > 0:
|
||||
id = queue_list.pop(0)
|
||||
unlock_queue()
|
||||
callbacks.queue_changed()
|
||||
return id
|
||||
|
||||
def reset():
|
||||
|
|
Loading…
Reference in New Issue