PDA

View Full Version : JS HTML5 - auto start playing video



NeoDreamer
May 3rd, 2010, 08:51 PM
I'm developing a video website for iPad. I couldn't get the video to autoplay. I couldn't even force it to play after it loaded. The following code is written with the Prototype framework, but I can assure you, it doesn't even work with straight up JS.



$('container').appendChild(
new Element(
'video', {
id: 'iPadVideo',
src: 'http://site.com/live.m3u8',
controls: 'controls',
autoplay: 'autoplay',
width: '100%',
height: '100%'
}
)
);

$('iPadVideo').play();


The only way I could get play() to work is:

use my finger to hit the play button overlayed on the player
call $('iPadVideo').pause()
call $('iPadVideo).play()


But I really just wanted it to autoplay without the user doing anything. How do I do that?

NeoDreamer
May 7th, 2010, 04:17 AM
solution found

iPad purposely disables auto-start of video so AT&T doesn't lose money over lost bandwidth. A workaround is to assign the start call to an onclick listener of a button. Then call the click function of that button.