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();
|
$album = $app->album->where('id', $albumid)->first();
|
||||||
|
|
||||||
if ($album) {
|
if ($album) {
|
||||||
$json = ['songs' => $album->songs()];
|
$json = ['songs' => $album->songs];
|
||||||
echo json_encode($json);
|
echo json_encode($json);
|
||||||
} else {
|
} else {
|
||||||
$app->notFound();
|
$app->notFound();
|
||||||
|
@ -52,25 +52,30 @@ function getAlbumSongs(albumElem) {
|
|||||||
|
|
||||||
$.get('/apiv1/music/album-songs/' + albumElem.data('albumid'), function(data) {
|
$.get('/apiv1/music/album-songs/' + albumElem.data('albumid'), function(data) {
|
||||||
var json = $.parseJSON(data);
|
var json = $.parseJSON(data);
|
||||||
var playlist = $('#now-playing-list');
|
var playlist = $('.now-playing-list');
|
||||||
playlist.empty();
|
playlist.empty();
|
||||||
|
|
||||||
for (var i = 0; i < json.songs.length; i++) {
|
for (var i = 0; i < json.songs.length; i++) {
|
||||||
var song = json.songs[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) {
|
if (i === 0) {
|
||||||
classString = 'music-track selected';
|
songElem.addClass('selected');
|
||||||
} else {
|
|
||||||
classString = 'music-track';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 + '">' +
|
songElem.html('<span>' + song.track_order + '. ' + song.title + '</span>');
|
||||||
'<span>' + song.track_order + '. ' + song.title + '</span>' +
|
|
||||||
'</li>';
|
|
||||||
|
|
||||||
playlist.append(song);
|
playlist.append(songElem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeSelectedTrack(playlist.find('.selected'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user