ios - html video javascript play method not working in mobile Safari -
this question has answer here:
- can autoplay html5 videos on ipad? 6 answers
i have video element in ember.js app i'm setting src
of window.url.createobjecturl(file)
generate preview before uploading. after capturing video file input, rendered html looks this:
<video class="video-review" controls="1" autoplay="1" src="blob:http://66efcd0.ngrok.com/bb427ce0-af04-4763-bb59-3be85b936895"> </video> // * ngrok port forwarding util testing
the video shows fine, , plays fine if manually tap on it.
i need video play after has loaded. the problem autoplay not work, , can not video play javascript. in console (after video has loaded vid.load()
) tried:
vid = $('video.video-review').get(0) vid.play()
this not work. however, if manually tap on video , play it, (and give focus) calling vid.play()
console work , plays video fine. tried giving video focus:
vid.focus() , jquery $(vid).focus() vid.play()
no luck.
how can html video play javascript in mobile safari?? - , why autoplay not working?
also here code assigns video attributes (triggered observer on file change event):
var file = this.get('file'); window.url = window.url || window.webkiturl; var vid = this.$('.video-review').get(0); vid.src = window.url.createobjecturl(file); vid.file = file; vid.addeventlistener('canplaythrough', function() { this.play(); }, false); vid.load();
you can't. calling play on video works if it's in response user action, in click event handler. design.
Comments
Post a Comment