Picture of Anders Ekman
Play media on load
by Anders Ekman - Tuesday, 4 October 2016, 12:51 PM
 

Is there any way to play media when the page has finnished loading?

/Anders

Picture of Matt Leathes
Re: Play media on load
by Matt Leathes - Tuesday, 4 October 2016, 2:46 PM
 

Not as it stands, no.

You could do this fairly easily by adding a call to this.onOverlayClick() at the end of the onPlayerReady function

Note that it would not work in iOS as iOS does not allow media to be played automatically - playback can only be initiated as the direct result of a 'user gesture' - except in iOS10 where you can now autoplay video if there's no audio track or the player is muted.

Picture of Anders Ekman
Re: Play media on load
by Anders Ekman - Wednesday, 5 October 2016, 6:52 AM
 

Okay cool. In what file shall I add this?

Picture of Matt Leathes
Re: Play media on load
by Matt Leathes - Wednesday, 5 October 2016, 8:47 AM
 

https://github.com/adaptlearning/adapt-contrib-media/blob/master/js/adapt-contrib-media.js#L281-L297

One thing to be careful of - if you have more than one media component on the page then they will ALL start playing on page load, which I suspect is not something you want...

Picture of Anders Ekman
Re: Play media on load
by Anders Ekman - Wednesday, 5 October 2016, 9:26 AM
 

How can I make this work with the authoring tool? I updated the file and added a console.log(), nothing shows up :/

Picture of Matt Leathes
Re: Play media on load
by Matt Leathes - Wednesday, 5 October 2016, 11:29 AM
 

I strongly suggest you get this working in the Framework before attempting to use it in the Authoring Tool