From 681c80c9ce4387388a59db48ac189d21ca64ce2f Mon Sep 17 00:00:00 2001 From: Jing Sun Date: Tue, 27 Dec 2016 19:28:13 +0100 Subject: [PATCH] volume slider --- client/static/index.html | 36 ++++++++++++++++++++++++------------ protocol | 3 ++- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/client/static/index.html b/client/static/index.html index af500d1..2dbbf7f 100644 --- a/client/static/index.html +++ b/client/static/index.html @@ -175,16 +175,21 @@ height: 50px;
-
Volume
- - volume_down - - - volume_up - - - volume_off + + volume_mute + + + volume_off + + + + + volume_down + + volume_up + +
@@ -255,11 +260,15 @@ var chapterCommand = function(isForward) { }; var playCommand = { command: 'play' }; var pauseCommand = { command: 'pause' }; +var muteCommand = { command: 'mute' }; +var unmuteCommand = { command: 'unmute' }; // --------------------------------------------------------- $scope.status = ''; $scope.currentDurationSeconds = 0; $scope.totalDurationSeconds = 1; +$scope.currentVolume = 0; $scope.isPlaying = false; +$scope.isMuted = false; $scope.fileName = ''; $scope.connectionStatus = ''; $scope.alert = ''; @@ -304,6 +313,8 @@ var updateState = function(state) { $scope.totalDurationSeconds = state.totalDuration; $scope.isPlaying = state.isPlaying; $scope.fileName = state.fileName; + $scope.isMuted = state.isMuted; + $scope.currentVolume = state.volume; $scope.$apply(); }; connect(); @@ -315,7 +326,7 @@ $scope.onDurationChange = function() { $scope.previousChapter = function() { sendCommand(chapterCommand(false)) }; $scope.nextChapter = function() { sendCommand(chapterCommand(true)) }; -$scope.back = function() {}; +$scope.back = function() { sendCommand(seekCommand(Math.max(0, $scope.currentDurationSeconds - 10))) }; $scope.play = function() { $scope.isPlaying = true; sendCommand(playCommand); @@ -324,10 +335,11 @@ $scope.pause = function() { $scope.isPlaying = false; sendCommand(pauseCommand); }; -$scope.forward = function() {}; +$scope.forward = function() { sendCommand(seekCommand(Math.min($scope.totalDurationSeconds, $scope.currentDurationSeconds + 10))) }; $scope.volumeUp = function() { volume(5) }; $scope.volumeDown = function() { volume(-5) }; -$scope.toggleMute = function() { }; +$scope.mute = function() { sendCommand(muteCommand) }; +$scope.unmute = function() { sendCommand(unmuteCommand) }; $scope.showListBottomSheet = function($event) { $scope.alert = ''; diff --git a/protocol b/protocol index 24a6fbd..2fceb1e 100644 --- a/protocol +++ b/protocol @@ -8,7 +8,8 @@ Response: "currentDuration": 2, "volume": 50, "fileName": "Foo", - "isPlaying": true + "isPlaying": true, + "isMuted": false } -------------------------------------------------------------------------------- Seek: