0
votes

Is there a way to load the audio file sources through jquery? Instead of loading it inline through HTML?

Example:

<audio controls="controls">
  <source src="track.ogg" type="audio/ogg" />
  <source src="track.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>

Technically wouldnt I be able to call on the children of the audio and replace the attr of src to my desired URL?

1
You might want to look at load(), although I'm not sure exactly what you're asking.Jay Blanchard

1 Answers

0
votes

jPlayer is an HTML5 audio and video player for jQuery. It can dynamically load a media : http://jplayer.org/latest/developer-guide/#jPlayer-setMedia

$('#jquery_jplayer').jPlayer('setMedia', {
    mp3: 'media/audio/song.mp3',
  });