I have written a little customized audio player with a playlist. The playlist is a list of mp3 files found in a particular folder. They are displayed correctly in a table on my page and the file being played is highlighted as intended. I used sprite images for the audio-player controls and when I hover over the sprite images they are highlighted as they should be. Also when I click on any of sprites, the appropriate action is correctly retrieved (Play, Stop, Next Prev) and passed on to the relevant JS function. I also put two buttons on the page for (parallel) comparison purposes whilst I was developing the audio-player sprite controls. My problem is that when I click the buttons (Next, Previous) the script behaves exactly as I would want it to. The buttons allow me to scroll through the playlist and the songs play as and when they are highlighted. However when I click on the corresponding sprite images (for Next and Prev) the same functions (as invoked by the buttons) seem to behave differently. For some reason, when I select 'Next' or 'Prev', the mp3 played always reverts to the first on the list. I am relatively new to JS but keen to learn. :-) Any thoughts?
Asked
Active
Viewed 24 times
0
-
2If you can provide the code snippets, you can get the help quickly. – ABGR Jun 26 '20 at 18:45
-
https://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example?rq=1 – Irish Frank Jun 27 '20 at 11:07
-
I think this is the solution to my problem - it's all about 'closure' :-) – Irish Frank Jun 27 '20 at 11:08
-
Not so sure that this is the case now :-( – Irish Frank Jul 01 '20 at 08:10