End video with black frame | XM Community
Skip to main content

I want to end a video with a black frame.

 

I am thinking about inserting a frame at the end of vid or getting the question to unload, hide, collapse, disappear…

I want the video to not end on its last frame. 

 

I looked for solutions with Javascript hide function with QuestionContainer and html video function, but can’t get it to work.

 

The video is in a multiple choice question.

These are the base codes, I would appreciate any suggestions on this please.

Thank you.

 

{html}

<div style="text-align:center;"><span style="color:#ffffff;">.</span>
<video class="qmedia" controls="true" controlslist="nodownload noplaybackrate" disablepictureinpicture="" height="336" preload="none" width="600"><source src="abcabc" type="video/mp4" /></video>
</div>

 

{java}

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/
    this.hideNextButton();


});

Qualtrics.SurveyEngine.addOnReady(function()
                                  {
    /*Place your JavaScript here to run when the page is fully displayed*/
    this.showNextButton.delay(10);
    
});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

Something like this might work:

<video id="my-video" controls>
  <source src="path/to/video.mp4" type="video/mp4">
</video>
<div id="replacement"></div>

<script>
  const video = document.getElementById("my-video");
  const replacement = document.getElementById("replacement");
 
  video.addEventListener("ended", function() {
    // Remove the video element
    video.remove();
    
    // Create and append the replacement element
    const replacementElement = document.createElement("img");
    replacementElement.src = "path/to/image.jpg";
    replacement.appendChild(replacementElement);
  });
</script>


Jesper Anderson, thank you very much.

This works perfectly, fabulously well.

I decided to just use the remove function without the replace to keep my codes simple, but I got both to work just fine.

You have saved me a lot of energy, I appreciate you very much.

Thank you,


Good to hear @SoT , and happy to hear this worked for you :)


Leave a Reply