Reloading a Mediaelement audio player

by GingkoFr   Last Updated September 21, 2018 16:08 PM

I am writing a WordPress plugin (private and not intended to be publicly available) in which I am displaying a huge list of audio files (about a thousand) along with ONE audio player (like the one created by the [audio] shortcode), initially hidden and filled by a dummy audio file.

The idea is that when I select any audio file inside the page, I use javascript (with jQuery) to dynamically replace the current (initially dummy) audio file contained inside the player, move the player near the selected audio file link and make it visible.

This works quite well, and I succeed that way in managing a quite flexible method to quickly access all audio files in my page.

The only problem that I have is when I do that while a previous audio file is already playing: in that case, the player switches to a quite stalling state, and I have to stop and restart it manually in order to play the new file. It still works of course, but this is not very beautiful.

So I am looking for a way to locate the existing mediaelement player (by javascript) in order to apply a stop and reset command to it before (or while) loading the new file.

Please could somebody helps me on that problem?


Tags : shortcode audio

Related Questions

Extending the Audio Shortcode

Updated April 17, 2015 23:03 PM

Use audio tag with FTP address?

Updated October 31, 2018 15:08 PM

Add audio file to post using variable as link

Updated July 23, 2018 03:08 AM