Javascript Image Slider / Posts /

Force video slider to automatically play the video only for the first time

68
Is there anyway in having a video within a slideshow, that automatically plays, then continues playing the slideshow, but the next time the video comes it doesn’t play automatically.
 
For example. I now have autoplayvideo=true, and then the slide continues after the video has finishes, but then the video plays again. I want it not play the next time.
Greg  11 years ago   viewed: 20365    

3 Answers

0

How does the function `afterSlideChange()` help in controlling the autoplay behavior of the video?

boxing random

Johnnie Austin
  23 days ago
-2
Thank you very much for this solution! Much Appreciated.
Greg   11 years ago
-5
[admin] Since version v2013.8.27, just add attribute data-autovideo="1" to the video and the slider will only auto play for the first time. Please visit Video Slider for details.

The post below is the solution for previous versions of the slider.

Take the downloaded demo 6 as an example. The fifth slide automatically plays. By adding the following script to the page, you can get what you expected: the video auto plays only for the first time, but will not auto-play afterwards.
<script type="text/javascript"> function getVideoLink(slideImage) { var link = null; if (slideImage.parentNode.nodeName == "A") link = slideImage.parentNode; return link; } function afterSlideChange(args) { //args[0]-currentSlide index, args[1]-currentImage if (args[0] == 4) { var videoLink = getVideoLink(args[1]); if (videoLink != null && videoLink.getAttribute("autoPlayVideo")=="true") { videoLink.setAttribute("autoPlayVideo", "false"); } } } </script>
milo
  11 years ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: