Reputation: 2255
I have MediaElement set up to play some audio. I know how to change the source with JavaScript, the problem is I need to have both a .mp3
source and a .ogg
source and I can't figure out how to set both.
Right now I have it set up to change one source. This works, I just need to be able to have both for compatibility.
mediaElement.addEventListener('ended', function (e) {
mediaElement.setSrc("audio/budget_2.ogg");
setTimeout(function () {
mediaElement.play();
},1000);
}, true);
Upvotes: 1
Views: 1448
Reputation: 36448
Per the source, setSrc()
can take either a single string, or an array of URL/type objects. e.g.
mediaElement.setSrc(
[ { src: 'audio/budget_2.ogg', 'type': 'audio/ogg' },
{ src: 'audio/budget_2.mp3', 'type': 'audio/mpeg' }
]
);
Upvotes: 1