1

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?

Gingko

  • Have you looked at the MediaElement documentation? It looks like you probably want a combination of the methods setSrc and load. – phatskat Sep 21 '18 at 20:18
  • Yes I did. Of course I may want to use a combination of setSrc and load but what I am not able to find actually in this documentation is how to locate the existing object instance on which to apply the setSrc and load methods … especially into the WordPress implementation of it. – GingkoFr Sep 22 '18 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.