Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions dist/angular-soundmanager2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4419,15 +4419,15 @@ ngSoundManager.filter('humanTime', function () {

ngSoundManager.factory('angularPlayer', ['$rootScope', '$log',
function($rootScope, $log) {

var currentTrack = null,
repeat = false,
autoPlay = true,
isPlaying = false,
volume = 90,
trackProgress = 0,
playlist = [];

return {
/**
* Initialize soundmanager,
Expand Down Expand Up @@ -4569,8 +4569,14 @@ ngSoundManager.factory('angularPlayer', ['$rootScope', '$log',
return playlist[key];
}
},
addToPlaylist: function(track) {
playlist.push(track);
addToPlaylist: function(track, index) {
//if an index is specified, add track at index
if(index) {
playlist.splice(index, 0, track);
//otherwise add track to the end of playlist
} else {
playlist.push(track);
}
//broadcast playlist
$rootScope.$broadcast('player:playlist', playlist);
},
Expand All @@ -4593,7 +4599,7 @@ ngSoundManager.factory('angularPlayer', ['$rootScope', '$log',
}
}
},
addTrack: function(track) {
addTrack: function(track, index) {
//check if track itself is valid and if its url is playable
if (!this.isTrackValid) {
return null;
Expand All @@ -4609,7 +4615,7 @@ ngSoundManager.factory('angularPlayer', ['$rootScope', '$log',
url: track.url
});
//add to playlist
this.addToPlaylist(track);
this.addToPlaylist(track, index);
}
return track.id;
},
Expand Down
Loading