Fixed album changing process
This commit is contained in:
parent
64fec1af74
commit
78eb16d137
@ -29,7 +29,7 @@ $app->get('/apiv1/music/album-songs/:albumid', function($albumid) use($app) {
|
||||
$album = $app->album->where('id', $albumid)->first();
|
||||
|
||||
if ($album) {
|
||||
$json = ['songs' => $album->songs()];
|
||||
$json = ['songs' => $album->songs];
|
||||
echo json_encode($json);
|
||||
} else {
|
||||
$app->notFound();
|
||||
|
@ -52,25 +52,30 @@ function getAlbumSongs(albumElem) {
|
||||
|
||||
$.get('/apiv1/music/album-songs/' + albumElem.data('albumid'), function(data) {
|
||||
var json = $.parseJSON(data);
|
||||
var playlist = $('#now-playing-list');
|
||||
var playlist = $('.now-playing-list');
|
||||
playlist.empty();
|
||||
|
||||
for (var i = 0; i < json.songs.length; i++) {
|
||||
var song = json.songs[i];
|
||||
var classString = '';
|
||||
|
||||
var songElem = $('<li></li>')
|
||||
.addClass('music-track')
|
||||
.data('trackid', song.id)
|
||||
.data('title', song.title)
|
||||
.data('album', song.album_id)
|
||||
.data('order', song.track_order)
|
||||
.data('path', song.audio_file);
|
||||
|
||||
if (i === 0) {
|
||||
classString = 'music-track selected';
|
||||
} else {
|
||||
classString = 'music-track';
|
||||
songElem.addClass('selected');
|
||||
}
|
||||
|
||||
var songElem = '<li class="' + classString + '" data-trackid="' + song.id + '" data-title="' + song.title + '" data-album="' + song.album_id + '" data-order="' + song.track_order + '" data-path="' + song.audio_file + '">' +
|
||||
'<span>' + song.track_order + '. ' + song.title + '</span>' +
|
||||
'</li>';
|
||||
songElem.html('<span>' + song.track_order + '. ' + song.title + '</span>');
|
||||
|
||||
playlist.append(song);
|
||||
playlist.append(songElem);
|
||||
}
|
||||
|
||||
changeSelectedTrack(playlist.find('.selected'));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user