Skip to content

Commit

Permalink
playlist数组倒序显示,播放下一首方向修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Meekdai committed Oct 18, 2023
1 parent df9d935 commit db13cb2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ var Player = function(playlist) {
document.querySelector("body").style.backgroundImage = "url(" +media+ encodeURI(playlist[this.index].pic) + ")";

// Setup the playlist display.
playlist.forEach(function(song) {

playlist.reverse().forEach(function(song) {
var div = document.createElement('div');
div.className = 'list-song';
div.innerHTML = song.title;
Expand Down Expand Up @@ -140,7 +141,7 @@ Player.prototype = {

// Get the next track based on the direction of the track.
var index = 0;
if (direction === 'prev') {
if (direction === 'next') {
index = self.index - 1;
if (index < 0) {
index = self.playlist.length - 1;
Expand Down

0 comments on commit db13cb2

Please sign in to comment.