This is a bug in MediaElementJS, autoplay works for native and silverlight, but needs a little help with Flash.
You can listen for canPlay event and start playing as soon as the flash player is ready.
setTimeout tricks may fail in race conditions.
[code lang=”javascript”]
$(‘#playerid’).mediaelementplayer({
plugins: [‘flash’, ‘silverlight’],
success: function(mediaElement, domObject) {
if (mediaElement.pluginType == ‘flash’) {
mediaElement.addEventListener(‘canplay’, function() {
mediaElement.play();
}, false);
}
},
error: function() {
alert(‘Error setting media!’);
}
});[/code]
Comments
One response to “Autoplay for media element js”
Simple but really useful. You save me a lot of time. Thanks