Skip to content

Commit

Permalink
Merge pull request #6 from BuildFire/show-global-playlist
Browse files Browse the repository at this point in the history
show play list in nowplying
  • Loading branch information
mas-iota authored Aug 21, 2024
2 parents be7c989 + 72b9bd8 commit 949613c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 39 deletions.
21 changes: 10 additions & 11 deletions widget/controllers/widget.home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
WidgetHome.totalRecord = null;
$rootScope.loadingData = true;
$rootScope.autoPlay = true;

/* const isLauncher = window.location.href.includes('launcherPlugin');
const slideElement = document.querySelector(".slide");
if (isLauncher) {
Expand Down Expand Up @@ -66,7 +66,7 @@
}

var MediaCenterInfo = null;

MediaCenter.get().then(function success(result) {
if (result && result.data && result.id) {
MediaCenterInfo = result;
Expand All @@ -91,7 +91,7 @@
WidgetHome.media = MediaCenterInfo;
}
);

var _skip = 0,
_limit = 15,
searchOptions = {
Expand Down Expand Up @@ -281,7 +281,7 @@
if (order) {
var sort = {};
sort[order.key] = order.order;

if ((order.name == "Media Title A-Z" || order.name === "Media Title Z-A")) {
if (order.name == "Media Title A-Z") {
WidgetHome.media.data.content.updatedRecords ? searchOptions.sort = { titleIndex: 1 }
Expand Down Expand Up @@ -326,7 +326,7 @@
/**
* loadMore method loads the items in list page.
*/

$rootScope.removeFromGlobalPlaylist = ($event, item, index) => {
$event.stopImmediatePropagation();

Expand Down Expand Up @@ -374,7 +374,7 @@
$rootScope.showCountdown = true;

if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply();

$rootScope.delayCountdownText = `Next will play in ${delay}`;
if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply();
if (delayInterval) clearInterval(delayInterval);
Expand Down Expand Up @@ -405,7 +405,7 @@
if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply();
return;
}

$rootScope.loadingData = true;
WidgetHome.isBusy = true;
buildfire.spinner.show();
Expand Down Expand Up @@ -465,7 +465,7 @@
getCurrentUser(() => {
// Get limit from appData
getGlobalPlaylistLimit();

getGlobalPlaylistItems()
.finally(() => {
WidgetHome.isBusy = false;
Expand All @@ -474,7 +474,7 @@
WidgetHome.globalPlaylistLoaded = true;
if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply();

// A work around for the spinner not disappearing
// A work around for the spinner not disappearing
clearInterval(interval);
interval = setInterval(() => buildfire.spinner.hide(), 300);
setTimeout(() => clearInterval(interval), 2000);
Expand Down Expand Up @@ -519,12 +519,11 @@
}

$rootScope.showFeed = false;

if (ind != -1) {
if ($rootScope.autoPlay && !WidgetHome.items[ind]) ind = 0;

$rootScope.currentIndex = ind;

if (!$rootScope.skipMediaPage || ($rootScope.skipMediaPage && WidgetHome.items[ind].data.videoUrl)
|| ($rootScope.skipMediaPage && !WidgetHome.items[ind].data.videoUrl && !WidgetHome.items[ind].data.audioUrl)) {
Location.go('#/media/' + WidgetHome.items[ind].id, true);
Expand Down
36 changes: 17 additions & 19 deletions widget/controllers/widget.nowplaying.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
settingsArrayOfStrings.forEach(function(el){
NowPlaying.settingsStrings[el.key] = strings.get("settings."+el.key)?strings.get("settings."+el.key):el.text;
});

/**
* slider to show the slider on now-playing page.
* @type {*|jQuery|HTMLElement}
Expand Down Expand Up @@ -153,7 +153,7 @@
var index=NowPlaying.findTrackIndex(userPlayList,filteredPlaylist[i]);
if(index!=-1)
audioPlayer.removeFromPlaylist(index);
}
}
}
});
}
Expand Down Expand Up @@ -249,7 +249,7 @@
NowPlaying.settings.autoPlayNext=false;
}
audioPlayer.settings.set({autoPlayNext:false});
var myInterval=setInterval(function(){
var myInterval=setInterval(function(){
if(ready){
if(!NowPlaying.isItLast){
NowPlaying.settings.autoPlayNext=true;
Expand All @@ -263,7 +263,7 @@
});
break;
case 'timeUpdate':
ready = e.data.duration && e.data.duration!=null && e.data.duration > 0;
ready = e.data.duration && e.data.duration!=null && e.data.duration > 0;
if(NowPlaying.forceAutoPlay)
if(ready&&e.data.currentTime>=e.data.duration&&!first){
first=true;
Expand All @@ -279,7 +279,7 @@
clearInterval(myInterval);
first=false;
}
}, 100);
}, 100);
}, 500);
}else if(ready&&(NowPlaying.settings.autoPlayNext||NowPlaying.forceAutoPlay))
{
Expand Down Expand Up @@ -404,7 +404,7 @@
}
NowPlaying.playing = true;
if (track) {
audioPlayer.play({ url: track.url });
audioPlayer.play({ url: track.url ? track.url : track.audioUrl });
track.playing = true;
}
if (!$scope.$$phase) {
Expand Down Expand Up @@ -515,27 +515,25 @@
});

};
NowPlaying.removeTrackFromPlayList = function (index) {
NowPlaying.removeTrackFromPlayList = function (index,item) {
Modals.removeTrackModal().then(function (data) {
audioPlayer.removeFromPlaylist(index);
buildfire.dialog.toast({
message: NowPlaying.playListStrings.removedFromPlaylist
});
GlobalPlaylist.delete(item.id).then(() => {
delete $rootScope.globalPlaylistItems.playlist[item.id];
$rootScope.myItems.splice(index, 1);
if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply();
buildfire.dialog.toast({
message: strings.get('playlist.removedFromPlaylist'),
type: 'success',
duration: 2000
});
});
},
function (err) {
console.error(err);
});

};
NowPlaying.getFromPlaylist = function () {
audioPlayer.getPlaylist(function (err, data) {
if (data && data.tracks) {
NowPlaying.playList = data.tracks;
if (!$scope.$$phase) {
$scope.$digest();
}
}
});
NowPlaying.openMoreInfo = false;
$rootScope.playlist = true;
};
Expand Down
18 changes: 9 additions & 9 deletions widget/templates/layouts/now-playing.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,27 @@ <h4 class="margin-zero ellipsis whiteTheme">{{NowPlaying.currentTrack.title}}</h
<div class="list-item overflow-hidden"
ng-swipe-right="NowPlaying.addEvents($event, $index, false,track)"
ng-swipe-left="NowPlaying.addEvents($event, $index, true,track)"
ng-repeat="track in NowPlaying.playList">
ng-repeat="track in myItems">
<div class="list-item-media text-left" ng-class="{'edit' : track.swiped}">
<div class="list-media-holder square-icon pull-left">
<img ng-if="track.image" load-image="2x1" crop-width="55" crop-height="22"
crop-type="crop" data-ng-src="{{track.image}}">
<img ng-if="track.data.topImage" load-image="2x1" crop-width="55" crop-height="22"
crop-type="crop" data-ng-src="{{track.data.topImage}}">
</div>
<div class="list-item-copy text-left padding-left-ten padding-right-ten">
<p class="margin-bottom-zero ellipsis margin-top-twenty bodyTextTheme">
{{track.title}}</p>
{{track.data.title}}</p>
</div>
<div class="btns text-center">
<a ng-class="track.playing ? 'icon-pause-circle' : 'icon-play-circle'"
class="icon primaryTheme" ng-click="NowPlaying.playlistPlayPause(track)"></a>
<a ng-class="track.data.playing ? 'icon-pause-circle' : 'icon-play-circle'"
class="icon primaryTheme" ng-click="NowPlaying.playlistPlayPause(track.data)"></a>
</div>
<div class="remove-btn text-center dangerBackgroundTheme" style="background:red;"
ng-click="NowPlaying.removeTrackFromPlayList($index)">
ng-click="NowPlaying.removeTrackFromPlayList($index,track)">
<span class="whiteTheme">{{NowPlaying.playListStrings.removePlayListButton}}</span>
</div>
</div>
</div>
<div ng-if="!NowPlaying.playList.length">
<div ng-if="!myItems.length">
<h3>{{NowPlaying.playListStrings.emptyPlaylist}}</h3>
</div>
</div>
Expand Down Expand Up @@ -239,4 +239,4 @@ <h4 class="margin-zero ellipsis whiteTheme">{{NowPlaying.currentTrack.title}}</h
</div>
</div>
</div>
</div>
</div>

0 comments on commit 949613c

Please sign in to comment.