Esempio n. 1
0
def pause(request, shouldPause, username):
    current = QueueItem.current()
    if not shouldPause:
        if player.status == Status.idle and QueueItem.objects.count()>0:
            from jukebox.cache import is_cached
            if is_cached(current.what):
                play_current(player)
        elif player.status == Status.paused:
            player.unpause()
            ChatItem(what="resume", info=current.what, who=username).save()
    else:
        if player.status == Status.playing:
            player.pause()
            ChatItem(what="pause", info=current.what, who=username).save()

    return status_info(request)
Esempio n. 2
0
def pause(request, shouldPause, username):
    current = QueueItem.current()
    if not shouldPause:
        if player.status == Status.idle and QueueItem.objects.count() > 0:
            from jukebox.cache import is_cached
            if is_cached(current.what):
                play_current(player)
        elif player.status == Status.paused:
            player.unpause()
            ChatItem(what="resume", info=current.what, who=username).save()
    else:
        if player.status == Status.playing:
            player.pause()
            ChatItem(what="pause", info=current.what, who=username).save()

    return status_info(request)
Esempio n. 3
0
File: player.py Progetto: Ferada/nih
def pause(request, shouldPause, username):
    logger.debug("pause request: shouldPause %s, queueitems %s, status %s", shouldPause, QueueItem.objects.count(), player.status)
    current = QueueItem.current()
    if not shouldPause:
        if player.status == Status.idle and QueueItem.objects.count()>0:
            from jukebox.cache import is_cached
            if is_cached(current.what):
                play_current(player)
        elif player.status == Status.paused:
            player.unpause()
            ChatItem(what="resume", info=current.what, who=username).save()
        elif player.status == Status.playing and QueueItem.objects.count() == 0:
            logger.info("Weird playback, as we're playing but there's no queue items, so stopping")
            player.stop()
    else:
        if player.status == Status.playing:
            player.pause()
            ChatItem(what="pause", info=current.what, who=username).save()

    return status_info(request)
Esempio n. 4
0
File: queue.py Progetto: Ferada/nih
def enqueue(request, username, tracks, atTop):
    logger.debug("enqueue: %s", tracks)
    for t in tracks:
        q = QueueItem(who = username, what = MusicFile.objects.get(url=t['url']))
        cached(q.what)
        try:
            if atTop:
                items = QueueItem.objects.all().order_by("index")
                if len(items)> 1:
                    q.index = (items[0].index+items[1].index)/2
                else:
                    q.index = items[0].index + 1 # only current item in queue
            else:
                q.index = QueueItem.objects.order_by("-index")[0].index + 1 # only current item in queue
        except IndexError: # nothing else in queue
            q.index = 0
        q.save()

    # Newly queued items get automagically played if the player is idle. This is only needed if they're already cached
    if is_cached(QueueItem.current().what) and get_status() == Status.idle:
        play_current(player)
    return status_info(request)