Add mute button.

This commit is contained in:
Jim Driessen
2017-09-05 14:02:27 +02:00
parent aadeb44b43
commit 984a068880
4 changed files with 20 additions and 1 deletions

View File

@ -18,4 +18,5 @@ urlpatterns = [
url(r'^upload', views.upload), url(r'^upload', views.upload),
url(r'^volumedown', views.volume_down), url(r'^volumedown', views.volume_down),
url(r'^volumeup', views.volume_up), url(r'^volumeup', views.volume_up),
url(r'^mute', views.mute),
] ]

View File

@ -267,3 +267,13 @@ def volume_up(request):
command = QueueCommand(queue=request.user.queue, command='volume_up') command = QueueCommand(queue=request.user.queue, command='volume_up')
command.save() command.save()
return JsonResponse({}) return JsonResponse({})
@require_http_methods(["POST"])
@api_auth_required
def mute(request):
if not request.user.has_perm('queues.can_control_volume'):
return HttpResponseForbidden()
command = QueueCommand(queue=request.user.queue, command='mute')
command.save()
return JsonResponse({})

View File

@ -97,6 +97,11 @@ $(function () {
$.post('/api/volumeup', {csrfmiddlewaretoken: csrf_token}); $.post('/api/volumeup', {csrfmiddlewaretoken: csrf_token});
}); });
$('#mute').click(function(e){
e.preventDefault();
$.post('/api/mute', {csrfmiddlewaretoken: csrf_token});
});
$(document).on('touchstart', '.artist, .title', function(){ $(document).on('touchstart', '.artist, .title', function(){
noRemove = true; noRemove = true;
setTimeout(function(){ noRemove = false; }, 500); setTimeout(function(){ noRemove = false; }, 500);

View File

@ -45,7 +45,10 @@
</div> </div>
<div id="queue-container"> <div id="queue-container">
<h1 class="h1">Now Playing</h1> <h1 class="h1">
Now Playing{% if perms.queues.can_control_volume %}
<a id="mute" class="glyphicon glyphicon-volume-off" href="#"></a>{% endif %}
</h1>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>