Exemple #1
0
def player_status(request):
    # ToDo: make this more nicer...z 
    current_song = current_song = Song.objects.filter(is_playing=True).values( 
        'pk', 'title', 'artist', 'album', 'duration')
    if len(current_song) != 1:
        current_song = []
    else:
        current_song = current_song[0]
    songs = Song.objects.filter(is_playing=False).annotate(nr_votes=Count('votes')) .order_by('-nr_votes').values(
        'pk', 'title', 'artist', 'album', 'duration', 'nr_votes')
    serialized_songs = []
    for song in songs:
        serialized_songs.append(song)
    
    votes = Song.objects.filter(votes=request.user).values('pk')
    serialized_votes = []
    for vote in votes:
        serialized_votes.append(vote)
    
    return HttpResponse(json.dumps({
        'current_song': current_song,
        'songs': serialized_songs,
        'votes': serialized_votes,
        'player_status': json.loads(MPlayerControl.status())}), mimetype='application/javascript')
Exemple #2
0
def skip(request):
    r = MPlayerControl.skip()
    logging.debug('skip')
    return HttpResponseRedirect(reverse('player-index'))
Exemple #3
0
def pause(request):
    MPlayerControl.pause()
    return HttpResponseRedirect(reverse('player-index'))
Exemple #4
0
def stop(request):
    MPlayerControl.stop()
    return HttpResponseRedirect(reverse('player-index'))