Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

To Hide Next Button Until Video Is watched

  • mnelson
  • mnelson's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 5 months ago #207280 by mnelson
Hi,
Is it possible to hide the next button the question that Im displaying the video until the video is watched then the button is active.

Lime Version 3.24.2
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207282 by Joffm
Replied by Joffm on topic To Hide Next Button Until Video Is watched
Use this:
Code:
<div class="embed-responsive embed-responsive-16by9">
<video autoplay="autoplay" id="myvideo"><source src="path_to_video.mp4" type="video/mp4" /> Browser does not support this format.</video>
</div>
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {  
 
    // Hide the "Next" button
    $('#ls-button-submit').hide();
 
    var vid = document.getElementById("myvideo");
 
                // Set a volume if necessary
                vid.volume = 0.3; 
                // When video is watched show the NEXT-button and proceed to the next question
    vid.onended = function() {
      // Show the "Next" button
      $('#ls-button-submit').show().trigger('click');
    }
    });
</script>

If you don't want to proceed after the video change the last line to
$('#ls-button-submit').show();

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • mnelson
  • mnelson's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 5 months ago - 3 years 5 months ago #207295 by mnelson
Replied by mnelson on topic To Hide Next Button Until Video Is watched
Thanks for this, I was using a video from YouTube and im finding it a bit hard to integrate it in the below:

<div class="videodetector"><iframe frameborder="0" src="https://www.youtube.com?autohide=1&amp;controls=1&amp;showinfo=0">


<p> </p>
Last edit: 3 years 5 months ago by mnelson.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207296 by tpartner
Replied by tpartner on topic To Hide Next Button Until Video Is watched
You will need to use the YouTube iframe API - developers.google.com/youtube/iframe_api_reference

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose