mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-07 14:26:44 +01:00
Implement ng-controllers for cached track downloads
This commit is contained in:
parent
a5bc7491e0
commit
58e49cc2f5
2 changed files with 33 additions and 4 deletions
|
@ -21,8 +21,8 @@ window.pfm.preloaders['album'] = [
|
|||
]
|
||||
|
||||
angular.module('ponyfm').controller "album", [
|
||||
'$scope', 'albums', '$state', 'playlists', 'auth', '$dialog'
|
||||
($scope, albums, $state, playlists, auth, $dialog) ->
|
||||
'$scope', 'albums', '$state', 'playlists', 'auth', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, albums, $state, playlists, auth, $dialog, cachedAlbum, $window, $timeout) ->
|
||||
album = null
|
||||
|
||||
albums.fetch($state.params.id).done (albumResponse) ->
|
||||
|
@ -40,4 +40,18 @@ angular.module('ponyfm').controller "album", [
|
|||
if auth.data.isLogged
|
||||
playlists.refreshOwned().done (lists) ->
|
||||
$scope.playlists.push list for list in lists
|
||||
|
||||
$scope.getCachedAlbum = (id, format) ->
|
||||
$scope.isEncoding = true
|
||||
|
||||
cachedAlbum.download('albums', id, format).then (response) ->
|
||||
albumUrl = response
|
||||
$scope.albumUrl = albumUrl
|
||||
if albumUrl == 'error'
|
||||
$scope.isEncoding = false
|
||||
else if albumUrl == 'pending'
|
||||
$timeout $scope.getCachedAlbum(id, format), 5000
|
||||
else
|
||||
$scope.isEncoding = false
|
||||
$window.open albumUrl, '_blank'
|
||||
]
|
||||
|
|
|
@ -21,8 +21,8 @@ window.pfm.preloaders['track'] = [
|
|||
]
|
||||
|
||||
angular.module('ponyfm').controller "track", [
|
||||
'$scope', 'tracks', '$state', 'playlists', 'auth', 'favourites', '$dialog'
|
||||
($scope, tracks, $state, playlists, auth, favourites, $dialog) ->
|
||||
'$scope', 'tracks', '$state', 'playlists', 'auth', 'favourites', '$dialog', 'download-cached', '$window', '$timeout'
|
||||
($scope, tracks, $state, playlists, auth, favourites, $dialog, cachedTrack, $window, $timeout) ->
|
||||
track = null
|
||||
|
||||
tracks.fetch($state.params.id).done (trackResponse) ->
|
||||
|
@ -72,4 +72,19 @@ angular.module('ponyfm').controller "track", [
|
|||
|
||||
playlists.addTrackToPlaylist(playlist.id, $scope.track.id).done (res) ->
|
||||
playlist.message = res.message
|
||||
|
||||
$scope.getCachedTrack = (id, format) ->
|
||||
$scope.isEncoding = true
|
||||
|
||||
cachedTrack.download('tracks', id, format).then (response) ->
|
||||
trackUrl = response
|
||||
$scope.trackUrl = trackUrl
|
||||
console.log(trackUrl);
|
||||
if trackUrl == 'error'
|
||||
$scope.isEncoding = false
|
||||
else if trackUrl == 'pending'
|
||||
$timeout $scope.getCachedTrack(id, format), 5000
|
||||
else
|
||||
$scope.isEncoding = false
|
||||
$window.open trackUrl, '_blank'
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue