Skip to content

Commit

Permalink
#2 add playlist info
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyer Aurélien committed Sep 13, 2016
1 parent f800f32 commit 100be11
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 15 deletions.
44 changes: 42 additions & 2 deletions app/app.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function RemoteController($scope,$http,settingsService) {
vm.track = "";
vm.album = "";
vm.artist = "";
vm.presets = [];

vm.pushUpButton = pushUpButton;
vm.pushDownButton = pushDownButton;
Expand All @@ -42,6 +43,7 @@ function RemoteController($scope,$http,settingsService) {
vm.toggleSettings = toggleSettings;
vm.toggleSources = toggleSources;
vm.setVolume = setVolume;
vm.openSettingIfnoDevice = openSettingIfnoDevice;

var settings;
var volume;
Expand All @@ -66,14 +68,20 @@ function RemoteController($scope,$http,settingsService) {
if(vm.device){
getNowPlaying();
getSources();
getPresets();
}
});

function openSettingIfnoDevice(){
if(!vm.device)
toggleSettings();
}

function defaultData(){
clearInterval(timer);
vm.art = "img/img_loader.gif";
vm.track = "No SoundTouch Selected";
vm.artist = "Go to Settings !";
vm.artist = "Go to Settings ";
vm.album = "";
vm.ratingClass = "fa-heart-o";
vm.playStatus = 'fa-play';
Expand Down Expand Up @@ -138,6 +146,28 @@ function RemoteController($scope,$http,settingsService) {
console.log(event);
}

function getPresets(){
//
var url = 'http://'+vm.device.ipAddress+':8090/presets';
$http.get(url, {}).then(function(response) {
if (window.DOMParser){
parser = new DOMParser();
var xmlDoc = parser.parseFromString(response.data,"text/xml");
for (var i = 0; i < xmlDoc.getElementsByTagName("preset").length; i++) {
var preset = xmlDoc.getElementsByTagName("preset")[i];
vm.presets.push({
'id' : preset.getAttribute("id"),
'source' : preset.childNodes[0].getAttribute("source"),
'account' : preset.childNodes[0].getAttribute("sourceAccount"),
'isPresetable' : preset.childNodes[0].getAttribute("isPresetable"),
'type' : preset.childNodes[0].getAttribute("type"),
'name': preset.getElementsByTagName("itemName")[0].childNodes[0].nodeValue
});
}
}
});
}

//Now Playing display
function getNowPlaying(){

Expand Down Expand Up @@ -202,9 +232,19 @@ function RemoteController($scope,$http,settingsService) {

}else{
if(xmlDoc.getElementsByTagName("ContentItem")[0].getAttribute("source") == 'STANDBY'){
vm.track = "SoundTouch on Stanby";
vm.track = "SoundTouch on Standby";
vm.artist = "";
vm.itemName = "No playlist selected"
vm.buttonStart = true;
}else if(xmlDoc.getElementsByTagName("ContentItem")[0].getAttribute("source") == 'INVALID_SOURCE'){
vm.art = "img/img_loader.gif";
vm.track = "No Music Source Selected";
vm.artist = "Choice playlist !";
vm.album = "";
vm.ratingClass = "fa-heart-o";
vm.playStatus = 'fa-play';
vm.timeInfo = false;
vm.progressBar = false;
}
}
}
Expand Down
25 changes: 12 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div id="main" ng-class="remote.showSettings ? 'moveUp': ''" ng-controller="RemoteController as remote">

<div id="content">
<div id="cover" class="cover" style="background-image:url({{remote.art}});background-repeat: no-repeat;">
<div id="cover" class="cover" style="background:url({{remote.art}});background-repeat: no-repeat;background-size: cover;">
<div ng-if="remote.timeInfo" class="timeInfo">{{remote.timeInfo}}</div>
</div>
<div ng-if="remote.progressBar" class="progressBarContenair">
Expand All @@ -21,7 +21,7 @@

<span id="track">{{remote.track}}</span>
<span id="album">{{remote.album}}</span>
<span id="artist">{{remote.artist}}</span>
<span id="artist" ng-click="remote.openSettingIfnoDevice()">{{remote.artist}} <i ng-if="!remote.device" class="fa fa-cog"></i></span>

<span class="stanby" ng-if="remote.buttonStart" ng-mousedown="remote.pushDownButton('POWER')"><i class="fa fa-power-off"></i></span>

Expand All @@ -44,23 +44,22 @@
</div>

<div class="sourceControl {{remote.showSources}}">
<div class="itemName">
Playlist : {{remote.itemName}}
<div class="">
<span ng-if="remote.itemNewName">{{remote.itemNewName}}</span>
<span ng-if="!remote.itemNewName">Playlist : {{remote.itemName}}</span>
</div>
<div class="buttonList">
<span ng-mousedown="remote.pushUpButton('PRESET_1')">1</span>
<span ng-mousedown="remote.pushUpButton('PRESET_2')">2</span>
<span ng-mousedown="remote.pushUpButton('PRESET_3')">3</span>
<span ng-mousedown="remote.pushUpButton('PRESET_4')">4</span>
<span ng-mousedown="remote.pushUpButton('PRESET_5')">5</span>
<span ng-mousedown="remote.pushUpButton('PRESET_6')">6</span>
<div class="buttonList" ng-mouseleave="remote.itemNewName = null;remote.newSource = null">
<span ng-repeat="preset in remote.presets" ng-mouseover="remote.itemNewName=preset.name;remote.newSource=preset.source" ng-mousedown="remote.pushUpButton('PRESET_{{preset.id}}')">{{preset.id}}</span>
</div>
</div>

<div class="footerPopup">
<i class="fa fa-list-ul" ng-if="!remote.showSettings" ng-click='remote.toggleSources()'></i>
<i class="fa fa-cog cog-left" ng-if="remote.showSettings"></i>
<span ng-if="!remote.showSettings">{{remote.source}}</span>
<span ng-if="!remote.showSettings">
<span ng-if="!remote.newSource">{{remote.source}}</span>
<span ng-if="remote.newSource">{{remote.newSource}}</span>
</span>
<span ng-if="remote.showSettings">Settings</span>
<i class="fa" ng-class="remote.showSettings ? 'fa-times': 'fa-cog'" ng-click="remote.toggleSettings()"></i>
</div>
Expand Down Expand Up @@ -119,7 +118,7 @@
<span>{{device.name}}</span>
<span>{{device.type}}</span>
<span>{{device.ipAddress}}</span>
<span class="choice">Choice</span>
<span class="choice">Select</span>
</div>
<svg width="67" height="97" xmlns="http://www.w3.org/2000/svg">
<g>
Expand Down

0 comments on commit 100be11

Please sign in to comment.