Adds the left and right keys to get previous / next song
Removes the previous code in main-controller.js
This commit is contained in:
parent
a85865371c
commit
5a7a06d1a2
4 changed files with 41 additions and 74 deletions
|
@ -178,66 +178,37 @@ angular.module('JamStash')
|
|||
// $document.keydown(function (e) {
|
||||
// $scope.scrollToIndex(e);
|
||||
// });
|
||||
// $scope.scrollToIndex = function (e) {
|
||||
// var source = e.target.id;
|
||||
// if (e.target.tagName.toUpperCase() != 'INPUT') {
|
||||
// var unicode = e.charCode ? e.charCode : e.keyCode;
|
||||
// if (globals.settings.Debug) { console.log('Keycode Triggered: ' + unicode); }
|
||||
// if (unicode == 49) { // 1
|
||||
// $('#action_Queue').click();
|
||||
// } else if (unicode == 50) {
|
||||
// $('#action_Library').click();
|
||||
// } else if (unicode == 51) {
|
||||
// $('#action_Archive').click();
|
||||
// } else if (unicode == 52) {
|
||||
// $('#action_Settings').click();
|
||||
// } else if (unicode == 53) {
|
||||
// } else if (unicode == 54) { // 6
|
||||
// }
|
||||
// if (unicode >= 65 && unicode <= 90 && $('#tabLibrary').is(':visible')) { // a-z
|
||||
// var key = utils.findKeyForCode(unicode);
|
||||
// if (key == 'x' || key == 'y' || key == 'z') {
|
||||
// key = 'x-z';
|
||||
// }
|
||||
// var el = '#' + key.toUpperCase();
|
||||
// if ($(el).length > 0) {
|
||||
// $('#left-component').stop().scrollTo(el, 400);
|
||||
// }
|
||||
// } else if (unicode == 39 || unicode == 176) { // right arrow
|
||||
// player.nextTrack();
|
||||
// } else if (unicode == 37 || unicode == 177) { // back arrow
|
||||
// player.previousTrack();
|
||||
// // } else if (unicode == 32 || unicode == 179 || unicode.toString() == '0179') { // spacebar
|
||||
// // player.togglePause();
|
||||
// // return false;
|
||||
// } else if (unicode == 36 && $('#tabLibrary').is(':visible')) { // home
|
||||
// $('#left-component').stop().scrollTo('#MusicFolders', 400);
|
||||
// }
|
||||
// if (unicode == 189) { // dash - volume down
|
||||
// var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
|
||||
// if (volume <= 1 && volume > 0 && source === '') {
|
||||
// volume += -0.1;
|
||||
// $(globals.Player1).jPlayer({
|
||||
// volume: volume
|
||||
// });
|
||||
// utils.setValue('Volume', volume, true);
|
||||
// if (globals.settings.Debug) { console.log('Volume: ' + Math.round(volume * 100) + '%'); }
|
||||
// }
|
||||
// }
|
||||
// if (unicode == 187) { // equals - volume up
|
||||
// var volume = utils.getValue('Volume') ? parseFloat(utils.getValue('Volume')) : 1;
|
||||
// if (volume < 1 && volume >= 0 && source ==- '') {
|
||||
// volume += 0.1;
|
||||
// $(globals.Player1).jPlayer({
|
||||
// volume: volume
|
||||
// });
|
||||
// utils.setValue('Volume', volume, true);
|
||||
// if (globals.settings.Debug) { console.log('Volume: ' + Math.round(volume * 100) + '%'); }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// };
|
||||
$scope.scrollToIndex = function (e) {
|
||||
var source = e.target.id;
|
||||
if (e.target.tagName.toUpperCase() != 'INPUT') {
|
||||
var unicode = e.charCode ? e.charCode : e.keyCode;
|
||||
if (globals.settings.Debug) { console.log('Keycode Triggered: ' + unicode); }
|
||||
if (unicode == 49) { // 1
|
||||
$('#action_Queue').click();
|
||||
} else if (unicode == 50) {
|
||||
$('#action_Library').click();
|
||||
} else if (unicode == 51) {
|
||||
$('#action_Archive').click();
|
||||
} else if (unicode == 52) {
|
||||
$('#action_Settings').click();
|
||||
} else if (unicode == 53) {
|
||||
} else if (unicode == 54) { // 6
|
||||
}
|
||||
if (unicode >= 65 && unicode <= 90 && $('#tabLibrary').is(':visible')) { // a-z
|
||||
var key = utils.findKeyForCode(unicode);
|
||||
if (key == 'x' || key == 'y' || key == 'z') {
|
||||
key = 'x-z';
|
||||
}
|
||||
var el = '#' + key.toUpperCase();
|
||||
if ($(el).length > 0) {
|
||||
$('#left-component').stop().scrollTo(el, 400);
|
||||
}
|
||||
} else if (unicode == 36 && $('#tabLibrary').is(':visible')) { // home
|
||||
$('#left-component').stop().scrollTo('#MusicFolders', 400);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
$scope.scrollToIndexName = function (index) {
|
||||
var el = '#' + index;
|
||||
if ($(el).length > 0) {
|
||||
|
@ -342,7 +313,7 @@ angular.module('JamStash')
|
|||
in order to bind keypresses to <body> and have global shortcuts */
|
||||
$scope.togglePause = function () {
|
||||
if(globals.settings.Jukebox) {
|
||||
$scope.sendToJukebox('pause');
|
||||
$scope.sendToJukebox('stop');
|
||||
} else {
|
||||
player.togglePause();
|
||||
}
|
||||
|
@ -368,6 +339,9 @@ angular.module('JamStash')
|
|||
persistence.saveVolume(volume);
|
||||
};
|
||||
|
||||
$scope.nextTrack = player.nextTrack;
|
||||
$scope.previousTrack = player.previousTrack;
|
||||
|
||||
$rootScope.addToJukebox = function (id) {
|
||||
if (globals.settings.Debug) { console.log("LOAD JUKEBOX"); }
|
||||
$.ajax({
|
||||
|
|
|
@ -93,12 +93,12 @@ describe("Main controller", function() {
|
|||
});
|
||||
|
||||
describe("When I toggle pause,", function() {
|
||||
it("given that we're using the Jukebox mode, it sends a 'pause' command to the jukebox", function() {
|
||||
it("given that we're using the Jukebox mode, it sends a 'stop' command to the jukebox", function() {
|
||||
mockGlobals.settings.Jukebox = true;
|
||||
spyOn(scope, "sendToJukebox");
|
||||
|
||||
scope.togglePause();
|
||||
expect(scope.sendToJukebox).toHaveBeenCalledWith('pause');
|
||||
expect(scope.sendToJukebox).toHaveBeenCalledWith('stop');
|
||||
});
|
||||
|
||||
it("it toggles pause using the player service", function() {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<link href="styles/Mobile.css" rel="stylesheet" type="text/css" data-name="main" />
|
||||
<link href="" rel="stylesheet" type="text/css" data-name="theme" />
|
||||
</head>
|
||||
<body ui-keypress="{'32 179': 'togglePause()', '187 61 43': 'turnVolumeUp()', '189 95 45': 'turnVolumeDown()'}">
|
||||
<body ui-keypress="{'32 179': 'togglePause()', '43 61 187': 'turnVolumeUp()', '45 95 189': 'turnVolumeDown()'}" ui-keydown="{'right 176': 'nextTrack()', 'left 177': 'previousTrack()'}">
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<div id="messages">
|
||||
|
|
|
@ -11,9 +11,7 @@ angular.module('jamstash.player.controller', ['jamstash.player.service', 'jamsta
|
|||
function($scope, player, globals){
|
||||
'use strict';
|
||||
|
||||
$scope.getPlayingSong = function () {
|
||||
return player.getPlayingSong();
|
||||
};
|
||||
$scope.getPlayingSong = player.getPlayingSong;
|
||||
|
||||
$scope.play = function () {
|
||||
if (globals.settings.Jukebox) {
|
||||
|
@ -31,13 +29,8 @@ angular.module('jamstash.player.controller', ['jamstash.player.service', 'jamsta
|
|||
}
|
||||
};
|
||||
|
||||
$scope.previousTrack = function () {
|
||||
player.previousTrack();
|
||||
};
|
||||
|
||||
$scope.nextTrack = function () {
|
||||
player.nextTrack();
|
||||
};
|
||||
$scope.previousTrack = player.previousTrack;
|
||||
$scope.nextTrack = player.nextTrack;
|
||||
|
||||
//TODO: Hyz: updateFavorite - leave in rootScope ?
|
||||
}]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue