Welcome to the LimeSurvey Community Forum

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

Autoplay and Remove Controls in Embedded Video

  • CessnaStudy
  • CessnaStudy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #199789 by CessnaStudy
Dear Expert,

I am trying to embed a video that will play a video once automatically (autoplay) and with no controls visible to the user.
Ideally there is no pause function. There cannot be a replay (loop) function either, as each participant should see the video only once.

I tried embedding the video using iframe and adding in controls=0 and loop=0 and autoplay=1. This hides the controls except for the replay (which is a problem), but the video will not autoplay unless I refresh the frame.

<iframe src="PATH?autoplay=1&controls=0&loop=0" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

Thanks for the advice.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199796 by Joffm
Hi,
here how I implemented this short time ago.

Without IFrame:
<div class="embed-responsive embed-responsive-16by9">
<video autoplay="autoplay" id="myvideo"><source src="http(s)://myServer.com/myFolder/myVideo.mp4" type="video/mp4" /> browser does not support this</video>
</div>

And with a little snippet you may

hide the "next" button till the end of the video:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

// Hide the "Next" button
$('#ls-button-submit').hide();

var vid = document.getElementById("myvideo");
vid.volume = 0.3;
vid.onended = function() {
// Show the "Next" button
$('#ls-button-submit').show();
}
});
</script>


or proceed to the next page at the end of the video:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

// Hide the "Next" button
$('#ls-button-submit').hide();

var vid = document.getElementById("myvideo");
vid.volume = 0.3;
vid.onended = function() {
// Show the "Next" button
$('#ls-button-submit').trigger('click');
}
});
</script>


By the way: You see the line vid.volume = 0.3;
If there are no controls you may set the volume of the video.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199820 by tpartner
Replied by tpartner on topic Autoplay and Remove Controls in Embedded Video
You should be careful with autoplay and hiding controls. Many browsers now will not allow autoplay unless the sound is also muted.

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