Colleagues. The problem is as follows.

There is a music site .

  1. One-button player to the left of each song. Everything is perfectly reproduced.

  2. There is a button "Load more songs." Through Ajax, 20 more songs are loaded .

  3. If you start playing a song from a new loaded block, two songs will be played simultaneously , although the one that was playing should stop.

  4. If you stop everything and turn on the song again - it will start playing twice , i.e. for example, "ve-ve-ter with mo-mo-a-ri-doo-dul, na-gon-nyal be-be-du-du-du".

  5. Then if you load another 20 songs, the player is initialized again and the song will be played three times at the same time!

The wiretap becomes impossible! The same song overlaps itself several times.

Please help sort out. How to tame this script? The player is called ubaPlayer I attach a screenshot of the code. Highlights commented screenshot

  • The screenshot shows that you really initialize the player every time after downloading the content, here in this line is $ ("# ubaplayer"). UbaPlayer (...). Perhaps it will help to carry it higher (before the click), or then the player does not lose the tracks? - PavelGorobtsov
  • I tried to transfer. In all cases, swears that the file path is not found. There simply data is not loaded - empty data comes. Outside the script, in the main page in the code, the player is already initialized. Here it starts a second time. If you do not register it here, when you click on the player, the page reloads altogether, while there are no entries in the console. - tlustenko

0