|
128 | 128 | */ |
129 | 129 |
|
130 | 130 | function convertDropbox(obj) { |
131 | | - if (obj.includes("www.dropbox") || obj.includes("dl.dropbox.com")) { |
| 131 | + if (obj && (obj.includes("www.dropbox") || obj.includes("dl.dropbox.com"))) { |
132 | 132 | obj = obj.replace("www.dropbox", "dl.dropbox").replace("dl.dropbox.com", "dl.dropboxusercontent.com"); |
133 | 133 | } |
134 | 134 | return obj; |
|
197 | 197 | plugin: buildfire.context.instanceId, myId: el.id |
198 | 198 | }; |
199 | 199 | }); |
200 | | - NowPlaying.playList = []; |
| 200 | + $rootScope.playListItems = []; |
201 | 201 | for (var i = 0; i < pluginSongs.length; i++) { |
202 | 202 | audioPlayer.addToPlaylist(pluginSongs[i]); |
203 | | - NowPlaying.playList.push(pluginSongs[i]); |
| 203 | + $rootScope.playListItems.push(pluginSongs[i]); |
204 | 204 | } |
205 | 205 | } |
206 | 206 | } else { |
|
358 | 358 | ready = false; |
359 | 359 | updateAudioLastPosition(media.id, 0.1) |
360 | 360 | if(typeof $rootScope.audioFromPlayList === 'number'){ |
361 | | - NowPlaying.playlistPause(NowPlaying.playList[$rootScope.audioFromPlayList]); |
| 361 | + NowPlaying.playlistPause($rootScope.playListItems[$rootScope.audioFromPlayList]); |
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | if ($rootScope.autoPlay) { |
365 | 365 | $rootScope.playNextItem(); |
366 | 366 | } else { |
367 | 367 | if (NowPlaying.isItLast && NowPlaying.settings.loopPlaylist) { |
368 | 368 | audioPlayer.getCurrentTrack((track) => { |
369 | | - if (NowPlaying.playList && NowPlaying.playList.length > 0) { |
370 | | - NowPlaying.playList.forEach(element => { |
| 369 | + if ($rootScope.playListItems && $rootScope.playListItems.length > 0) { |
| 370 | + $rootScope.playListItems.forEach(element => { |
371 | 371 | element.playing = false |
372 | 372 | }); |
373 | | - let currentTrack = NowPlaying.playList.find(x => x.title == track.title && x.url == track.url && x.album == track.album && x.image == track.image && x.backgroundImage == track.backgroundImage) |
| 373 | + let currentTrack = $rootScope.playListItems.find(x => x.title == track.title && x.url == track.url && x.album == track.album && x.image == track.image && x.backgroundImage == track.backgroundImage) |
374 | 374 | if (currentTrack) { |
375 | 375 | currentTrack.playing = true |
376 | 376 | } |
|
409 | 409 | case 'next': |
410 | 410 | if(typeof $rootScope.audioFromPlayList === 'number'){ |
411 | 411 | $rootScope.audioFromPlayList = e.data.index; |
412 | | - NowPlaying.playList[$rootScope.audioFromPlayList].playing = true; |
| 412 | + $rootScope.playListItems[$rootScope.audioFromPlayList].playing = true; |
413 | 413 | if(!NowPlaying.settings.autoJumpToLastPosition){ |
414 | 414 | audioPlayer.setTime(0); |
415 | 415 | } |
|
419 | 419 | case 'previous': |
420 | 420 | if(typeof $rootScope.audioFromPlayList === 'number' && NowPlaying.settings.autoPlayNext){ |
421 | 421 | $rootScope.audioFromPlayList = e.data.index; |
422 | | - NowPlaying.playList[$rootScope.audioFromPlayList].playing = true; |
| 422 | + $rootScope.playListItems[$rootScope.audioFromPlayList].playing = true; |
423 | 423 | audioPlayer.setTime(0); |
424 | 424 | return false; |
425 | 425 | } |
426 | 426 | $rootScope.playPrevItem(); |
427 | 427 | break; |
428 | 428 | case 'removeFromPlaylist': |
429 | | - NowPlaying.playList = e.data && e.data.newPlaylist && e.data.newPlaylist.tracks; |
| 429 | + case 'addToPlaylist': |
| 430 | + $rootScope.playListItems = e.data.newPlaylist.tracks; |
430 | 431 | break; |
431 | 432 |
|
432 | 433 | } |
|
675 | 676 | if (isAudioEnded) { |
676 | 677 | NowPlaying.currentTrack.lastPosition = 0 |
677 | 678 | } |
678 | | - NowPlaying.currentTrack.url = validateURL(NowPlaying.currentTrack.url); |
679 | 679 | audioPlayer.play(NowPlaying.currentTrack); |
680 | 680 | audioPlayer.pause(); |
681 | 681 | setTimeout(() => { |
|
809 | 809 | buildfire.dialog.toast({ |
810 | 810 | message: NowPlaying.playListStrings.removedFromPlaylist |
811 | 811 | }); |
812 | | - if (NowPlaying.playList) { |
813 | | - NowPlaying.playList.filter(function (val, index) { |
| 812 | + if ($rootScope.playListItems) { |
| 813 | + $rootScope.playListItems.filter(function (val, index) { |
814 | 814 | if (val.url == track.url) { |
815 | 815 | audioPlayer.removeFromPlaylist(index); |
816 | 816 | } |
|
836 | 836 | }); |
837 | 837 |
|
838 | 838 | }; |
839 | | - NowPlaying.getFromPlaylist = function () { |
| 839 | + NowPlaying.showPlaylistPage = function () { |
| 840 | + NowPlaying.openMoreInfo = false; |
| 841 | + $rootScope.showPlaylist = true; |
| 842 | + } |
| 843 | + NowPlaying.getPlaylistData = function (openPlaylist = false) { |
840 | 844 | audioPlayer.getPlaylist(function (err, data) { |
841 | 845 | if (data && data.tracks) { |
842 | | - NowPlaying.playList = data.tracks; |
| 846 | + $rootScope.playListItems = data.tracks; |
843 | 847 | if (!$scope.$$phase) { |
844 | 848 | $scope.$digest(); |
845 | 849 | if(typeof $rootScope.audioFromPlayList === 'number' ){ |
846 | | - NowPlaying.playList[$rootScope.audioFromPlayList].playing = true; |
| 850 | + $rootScope.playListItems[$rootScope.audioFromPlayList].playing = true; |
847 | 851 | } |
848 | 852 | } |
849 | 853 | } |
850 | 854 | }); |
851 | | - NowPlaying.openMoreInfo = false; |
852 | | - $rootScope.playlist = true; |
853 | 855 | }; |
| 856 | + NowPlaying.getPlaylistData(); |
854 | 857 | NowPlaying.changeTime = function (time) { |
855 | 858 | audioPlayer.setTime(time); |
856 | 859 | }; |
|
886 | 889 | NowPlaying.openSettings = false; |
887 | 890 | }; |
888 | 891 | NowPlaying.closePlayListOverlay = function () { |
889 | | - $rootScope.playlist = false; |
| 892 | + $rootScope.showPlaylist = false; |
890 | 893 | }; |
891 | 894 | NowPlaying.closeMoreInfoOverlay = function () { |
892 | 895 | NowPlaying.openMoreInfo = false; |
|
896 | 899 | toggle ? track.swiped = true : track.swiped = false; |
897 | 900 | }; |
898 | 901 |
|
899 | | - // this method to make the audio url replaying multi times |
900 | | - function validateURL(url) { |
901 | | - if (url.includes('?')) return (url + '&' + Math.floor(Math.random() * 1000)) |
902 | | - return (url + '?' + Math.floor(Math.random() * 1000)) |
903 | | - } |
904 | | - |
905 | 902 | /** |
906 | 903 | * Track Smaple |
907 | 904 | * @param title |
|
1064 | 1061 | NowPlaying.playlistPause(track); |
1065 | 1062 | } |
1066 | 1063 | else { |
1067 | | - if (NowPlaying.playList && NowPlaying.playList.length > 0) { |
1068 | | - NowPlaying.playList.forEach(element => { |
| 1064 | + if ($rootScope.playListItems && $rootScope.playListItems.length > 0) { |
| 1065 | + $rootScope.playListItems.forEach(element => { |
1069 | 1066 | element.playing = false |
1070 | 1067 | }); |
1071 | 1068 | } |
1072 | 1069 | NowPlaying.playlistPlay(track, index); |
1073 | 1070 | } |
1074 | 1071 | } |
1075 | 1072 | else if (NowPlaying.paused) { |
1076 | | - NowPlaying.playList.forEach(element => { |
| 1073 | + $rootScope.playListItems.forEach(element => { |
1077 | 1074 | element.playing = false |
1078 | 1075 | }); |
1079 | 1076 | if (track.url == NowPlaying.currentTrack.url) { |
|
0 commit comments