David Healey
David Healey

Reputation: 566

jQuery attach mediaelement.js to dynamically created audio tags

I'm using the mediaelement.js plugin as my media player for HTML5 audio tags.

I attach the player to the tags using $('audio, video').mediaelementplayer(); But I'd like to know how I can do this for dynamically created audio tags. Is there a solution like live or on like there is for events?

Upvotes: 0

Views: 957

Answers (1)

r8n5n
r8n5n

Reputation: 2059

When you create the audio element dynamically can you create the mediaelement at the same time?

var audio = my new audio element

var player = new MediaElementPlayer('#id of new audio element',/* Options */);
// ... more code ...
player.pause();
player.setSrc('mynewfile.mp3');
player.play();

etc.

Upvotes: 2

Related Questions