Automatically scroll playlist and Pause when clicking on a track

41 views
Skip to first unread message

Владимир Сафьянов

unread,
Apr 25, 2019, 8:00:49 AM4/25/19
to jPlayer: HTML5 Audio & Video for jQuery
Good day!
I have a couple of questions that I can not implement:
1. There is a fixed height for the playlist 
.jp-playlist{ height: 185px; overflow: auto}
 how can I make the list automatically go up when switching a track, if the composition does not fit into the specified height (see screenshot)?
2. The first click on the track name in the list starts the music, how can pause the music when  click again?


Название не видно.jpg

Nick C

unread,
May 17, 2020, 11:12:50 PM5/17/20
to jPlayer: HTML5 Audio & Video for jQuery
Nick H (Harambee?) used this a while back to update the functionality of my jPlaylister (http://jplaylister.yaheard.us) for his implementation and I quickly added the code to my code-base because it is a great little feature!  The code should be pretty obvious based on below:

playlistOptions: {
},
/*auto scroll playlist */
play: function() {
$("#jp_playlist_1").animate({
scrollTop: $(".jp-playlist-current").position().top -
$("ul#playlist").position().top - ($("#scroll").height()/2) + ($(".jp-playlist-current").height()/2) + 5
}, 2000,'easeOutCirc');
},
/*end autoscroll playlist code from Nick H*/
swfPath: "js",
supplied: "mp3, m4v"  

(I also had to add a <div id="scroll"></div> around the playlist item <div id="jp_playlist_1"></div> -- but I don't think anything else was necessary for the code to work.

The code is from him and I just pasted it into the relevant place in my setup code.

As far as play/pause, I feel like you'd have to modify the "onclick" event for the playlist item to point to a function that was aware if the song was playing, and if it was...it would use the built-in play/pause function the play button uses.  I don't think I'd bother with it, personally.  I'd modify user expectations and have them use the play/pause button...but it probably wouldn't be terrible to do.

Good luck!
Reply all
Reply to author
Forward
0 new messages