volume slider

master
Jing Sun 9 years ago
parent da94041f2d
commit 681c80c9ce

@ -175,16 +175,21 @@ height: 50px;
<section layout="row" layout-sm="column" layout-align="center center" layout-wrap> <section layout="row" layout-sm="column" layout-align="center center" layout-wrap>
<div class="label">Volume</div> <md-button ng-show="isMuted" class="md-fab" aria-label="Unmute" ng-click="unmute()">
<md-button class="md-fab" aria-label="Volume down" ng-click="volumeDown()"> <md-icon class="material-icons">volume_mute</md-icon>
<md-icon class="material-icons">volume_down</md-icon> </md-button>
</md-button> <md-button ng-hide="isMuted" class="md-fab" aria-label="Mute" ng-click="mute()">
<md-button class="md-fab" aria-label="Volume up" ng-click="volumeUp()"> <md-icon class="material-icons">volume_off</md-icon>
<md-icon class="material-icons">volume_up</md-icon> </md-button>
</md-button> <md-slider flex="" min="0" ng-change="" max="130" ng-model="currentVolume" aria-label="VolumeSlider" id="volume-slider">
<md-button class="md-fab" aria-label="Toggle mute" ng-click="toggleMute()"> </md-slider>
<md-icon class="material-icons">volume_off</md-icon> <md-button class="md-fab" aria-label="Volume down" ng-click="volumeDown()">
<md-icon class="material-icons">volume_down</md-icon>
</md-button> </md-button>
<md-button class="md-fab" aria-label="Volume up" ng-click="volumeUp()">
<md-icon class="material-icons">volume_up</md-icon>
</md-button>
</section> </section>
<div class="status-container"> <div class="status-container">
@ -255,11 +260,15 @@ var chapterCommand = function(isForward) {
}; };
var playCommand = { command: 'play' }; var playCommand = { command: 'play' };
var pauseCommand = { command: 'pause' }; var pauseCommand = { command: 'pause' };
var muteCommand = { command: 'mute' };
var unmuteCommand = { command: 'unmute' };
// --------------------------------------------------------- // ---------------------------------------------------------
$scope.status = ''; $scope.status = '';
$scope.currentDurationSeconds = 0; $scope.currentDurationSeconds = 0;
$scope.totalDurationSeconds = 1; $scope.totalDurationSeconds = 1;
$scope.currentVolume = 0;
$scope.isPlaying = false; $scope.isPlaying = false;
$scope.isMuted = false;
$scope.fileName = ''; $scope.fileName = '';
$scope.connectionStatus = ''; $scope.connectionStatus = '';
$scope.alert = ''; $scope.alert = '';
@ -304,6 +313,8 @@ var updateState = function(state) {
$scope.totalDurationSeconds = state.totalDuration; $scope.totalDurationSeconds = state.totalDuration;
$scope.isPlaying = state.isPlaying; $scope.isPlaying = state.isPlaying;
$scope.fileName = state.fileName; $scope.fileName = state.fileName;
$scope.isMuted = state.isMuted;
$scope.currentVolume = state.volume;
$scope.$apply(); $scope.$apply();
}; };
connect(); connect();
@ -315,7 +326,7 @@ $scope.onDurationChange = function() {
$scope.previousChapter = function() { sendCommand(chapterCommand(false)) }; $scope.previousChapter = function() { sendCommand(chapterCommand(false)) };
$scope.nextChapter = function() { sendCommand(chapterCommand(true)) }; $scope.nextChapter = function() { sendCommand(chapterCommand(true)) };
$scope.back = function() {}; $scope.back = function() { sendCommand(seekCommand(Math.max(0, $scope.currentDurationSeconds - 10))) };
$scope.play = function() { $scope.play = function() {
$scope.isPlaying = true; $scope.isPlaying = true;
sendCommand(playCommand); sendCommand(playCommand);
@ -324,10 +335,11 @@ $scope.pause = function() {
$scope.isPlaying = false; $scope.isPlaying = false;
sendCommand(pauseCommand); sendCommand(pauseCommand);
}; };
$scope.forward = function() {}; $scope.forward = function() { sendCommand(seekCommand(Math.min($scope.totalDurationSeconds, $scope.currentDurationSeconds + 10))) };
$scope.volumeUp = function() { volume(5) }; $scope.volumeUp = function() { volume(5) };
$scope.volumeDown = 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.showListBottomSheet = function($event) {
$scope.alert = ''; $scope.alert = '';

@ -8,7 +8,8 @@ Response:
"currentDuration": 2, "currentDuration": 2,
"volume": 50, "volume": 50,
"fileName": "Foo", "fileName": "Foo",
"isPlaying": true "isPlaying": true,
"isMuted": false
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Seek: Seek:

Loading…
Cancel
Save