From cbd40cebbef926a046178d0ff378a4e21216508c Mon Sep 17 00:00:00 2001 From: alialaqrabawi3 Date: Mon, 19 Aug 2024 20:24:19 +0300 Subject: [PATCH 1/3] show play list in nowplying --- widget/controllers/widget.home.controller.js | 24 ++++++++------ .../widget.nowplaying.controller.js | 33 ++++++++++--------- widget/templates/layouts/now-playing.html | 18 +++++----- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index 5d38eb7..8cb17ed 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -10,7 +10,8 @@ WidgetHome.totalRecord = null; $rootScope.loadingData = true; $rootScope.autoPlay = true; - + $rootScope.currentMedia = null; + /* const isLauncher = window.location.href.includes('launcherPlugin'); const slideElement = document.querySelector(".slide"); if (isLauncher) { @@ -66,7 +67,7 @@ } var MediaCenterInfo = null; - + MediaCenter.get().then(function success(result) { if (result && result.data && result.id) { MediaCenterInfo = result; @@ -91,7 +92,7 @@ WidgetHome.media = MediaCenterInfo; } ); - + var _skip = 0, _limit = 15, searchOptions = { @@ -281,7 +282,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 } @@ -326,7 +327,7 @@ /** * loadMore method loads the items in list page. */ - + $rootScope.removeFromGlobalPlaylist = ($event, item, index) => { $event.stopImmediatePropagation(); @@ -374,7 +375,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); @@ -405,7 +406,7 @@ if (!$scope.$$phase && !$scope.$root.$$phase) $scope.$apply(); return; } - + $rootScope.loadingData = true; WidgetHome.isBusy = true; buildfire.spinner.show(); @@ -465,7 +466,7 @@ getCurrentUser(() => { // Get limit from appData getGlobalPlaylistLimit(); - + getGlobalPlaylistItems() .finally(() => { WidgetHome.isBusy = false; @@ -474,7 +475,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); @@ -511,19 +512,22 @@ WidgetHome.goToMedia = function (ind) { if (typeof ind != 'number') { var foundObj = WidgetHome.items.find(function (el) { return el.id == ind; }); + $rootScope.currentMedia = foundObj; ind = WidgetHome.items.indexOf(foundObj); } if (typeof ind === 'undefined' || !WidgetHome.items[ind]) { + $rootScope.currentMedia = WidgetHome.items[0]; ind = 0; } $rootScope.showFeed = false; - + if (ind != -1) { if ($rootScope.autoPlay && !WidgetHome.items[ind]) ind = 0; $rootScope.currentIndex = ind; + $rootScope.currentMedia = WidgetHome.items[ind]; if (!$rootScope.skipMediaPage || ($rootScope.skipMediaPage && WidgetHome.items[ind].data.videoUrl) || ($rootScope.skipMediaPage && !WidgetHome.items[ind].data.videoUrl && !WidgetHome.items[ind].data.audioUrl)) { diff --git a/widget/controllers/widget.nowplaying.controller.js b/widget/controllers/widget.nowplaying.controller.js index 770d917..24ec679 100644 --- a/widget/controllers/widget.nowplaying.controller.js +++ b/widget/controllers/widget.nowplaying.controller.js @@ -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} @@ -153,7 +153,7 @@ var index=NowPlaying.findTrackIndex(userPlayList,filteredPlaylist[i]); if(index!=-1) audioPlayer.removeFromPlaylist(index); - } + } } }); } @@ -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; @@ -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; @@ -279,7 +279,7 @@ clearInterval(myInterval); first=false; } - }, 100); + }, 100); }, 500); }else if(ready&&(NowPlaying.settings.autoPlayNext||NowPlaying.forceAutoPlay)) { @@ -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) { @@ -515,9 +515,18 @@ }); }; - NowPlaying.removeTrackFromPlayList = function (index) { + NowPlaying.removeTrackFromPlayList = function (index,item) { Modals.removeTrackModal().then(function (data) { - audioPlayer.removeFromPlaylist(index); + 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 + }); + }); buildfire.dialog.toast({ message: NowPlaying.playListStrings.removedFromPlaylist }); @@ -528,14 +537,6 @@ }; 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; }; diff --git a/widget/templates/layouts/now-playing.html b/widget/templates/layouts/now-playing.html index 081ce83..bb2cf99 100644 --- a/widget/templates/layouts/now-playing.html +++ b/widget/templates/layouts/now-playing.html @@ -111,27 +111,27 @@

{{NowPlaying.currentTrack.title}} + ng-repeat="track in myItems">
- +

- {{track.title}}

+ {{track.data.title}}

- +
+ ng-click="NowPlaying.removeTrackFromPlayList($index,track)"> {{NowPlaying.playListStrings.removePlayListButton}}
-
+

{{NowPlaying.playListStrings.emptyPlaylist}}

@@ -239,4 +239,4 @@

{{NowPlaying.currentTrack.title}} - \ No newline at end of file + From 97465e8c97e27c9062606f5e3626f1ae9f140441 Mon Sep 17 00:00:00 2001 From: alialaqrabawi3 Date: Mon, 19 Aug 2024 22:02:46 +0300 Subject: [PATCH 2/3] remove unnesseray code --- widget/controllers/widget.home.controller.js | 5 ----- widget/controllers/widget.nowplaying.controller.js | 3 --- 2 files changed, 8 deletions(-) diff --git a/widget/controllers/widget.home.controller.js b/widget/controllers/widget.home.controller.js index 8cb17ed..9be628a 100644 --- a/widget/controllers/widget.home.controller.js +++ b/widget/controllers/widget.home.controller.js @@ -10,7 +10,6 @@ WidgetHome.totalRecord = null; $rootScope.loadingData = true; $rootScope.autoPlay = true; - $rootScope.currentMedia = null; /* const isLauncher = window.location.href.includes('launcherPlugin'); const slideElement = document.querySelector(".slide"); @@ -512,12 +511,10 @@ WidgetHome.goToMedia = function (ind) { if (typeof ind != 'number') { var foundObj = WidgetHome.items.find(function (el) { return el.id == ind; }); - $rootScope.currentMedia = foundObj; ind = WidgetHome.items.indexOf(foundObj); } if (typeof ind === 'undefined' || !WidgetHome.items[ind]) { - $rootScope.currentMedia = WidgetHome.items[0]; ind = 0; } @@ -527,8 +524,6 @@ if ($rootScope.autoPlay && !WidgetHome.items[ind]) ind = 0; $rootScope.currentIndex = ind; - $rootScope.currentMedia = WidgetHome.items[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); diff --git a/widget/controllers/widget.nowplaying.controller.js b/widget/controllers/widget.nowplaying.controller.js index 24ec679..d12866f 100644 --- a/widget/controllers/widget.nowplaying.controller.js +++ b/widget/controllers/widget.nowplaying.controller.js @@ -527,9 +527,6 @@ duration: 2000 }); }); - buildfire.dialog.toast({ - message: NowPlaying.playListStrings.removedFromPlaylist - }); }, function (err) { console.error(err); From 72b9bd8b797bf5a99695c9b376237383f27e1930 Mon Sep 17 00:00:00 2001 From: alialaqrabawi3 Date: Mon, 19 Aug 2024 22:04:43 +0300 Subject: [PATCH 3/3] fix ternary operator indentation --- widget/controllers/widget.nowplaying.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/controllers/widget.nowplaying.controller.js b/widget/controllers/widget.nowplaying.controller.js index d12866f..78b3d4e 100644 --- a/widget/controllers/widget.nowplaying.controller.js +++ b/widget/controllers/widget.nowplaying.controller.js @@ -404,7 +404,7 @@ } NowPlaying.playing = true; if (track) { - audioPlayer.play({ url: track.url?track.url:track.audioUrl }); + audioPlayer.play({ url: track.url ? track.url : track.audioUrl }); track.playing = true; } if (!$scope.$$phase) {