SmartestVEGA
SmartestVEGA

Reputation: 8889

Stop autoplay for HTML video

I have a html video where i have image which loads initially. and that image dissapear and play that video.

I want the image should always appear,unill i click on the image. Once i click on the image, video should play.

Please find the jsfiddle:

http://jsfiddle.net/pwxcvxe8/173/

We have tried autoplay = "" and also removing autoplay from the video tag but no joy.

What change i need to make, if i want to play the video on click of image?

Upvotes: 0

Views: 13205

Answers (5)

Patrick Mlr
Patrick Mlr

Reputation: 2965

Try adding autoplay="false" or delete the autoplay. This worked for me.

Hope this will help.

Upvotes: 1

acabra85
acabra85

Reputation: 369

Taken from the MDN Web Docs https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video "The autoplay attribute has precedence over preload. If autoplay is specified, the browser would obviously need to start downloading the video for playback."

  1. As answered above (by Zac Webb) remove the attribute autoplay.
  2. And if you have the attribute preload make sure it is set to none preload="none", since the default for this attribute is auto.

This worked for me.

Upvotes: 0

shyamm
shyamm

Reputation: 550

try removing autoplay="false" or just remove autoplay property

Upvotes: 1

SivaPrasad Aluri
SivaPrasad Aluri

Reputation: 46

Here is Updated Code, You Can Remove autoplay attribute from video element, so it will never play autoplay, apart from that if you need to stop autoplay through script you can register event on it and use Dom Method "element.pause()" to stop the video here

Upvotes: 0

Zac Webb
Zac Webb

Reputation: 663

Removing the autoplay from the <video> tag worked fine to stop it autoplaying.
To make it so the image plays when you click, use the following jQuery:

$('#vid').click(function() {
  $('#vid').get(0).play()
});

Here is an updated JSFiddle


Feel free to ask any questions.

Upvotes: 2

Related Questions