Video in Qualtrics not loading properly | XM Community
Skip to main content

Hello all, I am trying to make a video in Qualtrics that is pinned to the top of the page (so that respondents don’t have to scroll down to view it) and that can be responded to with the keyboard (e.g., pressing “J” to answer a question about the video). While that code has successfully worked, I have run into a different problem; when the page with the video loads, it sort of glitches for a second as it reconfigures to fit the video size, like so (at the 2 and 7-second marks):

 

The problem might be browser-specific (it is very bad on Chrome, less noticeable on Safari, for instance). Below is the JavaScript and HTML code for the first video in the example attached. Any ideas of what is going wrong and how I can fix it? I need the loading to be normal and smooth. Thanks in advance for the help!:

<video autoplay="" class="qmedia" height="400" preload="auto" width="800"><source src="https://unc.az1.qualtrics.com/CP/File.php?F=F_56Y5CBojAj0j0YS" type="video/mp4" /><embed align="middle" autoplay="false" bgcolor="white" class="qmedia" height="400" pluginspage="http://www.apple.com/quicktime/download/" src="https://unc.az1.qualtrics.com/CP/File.php?F=F_56Y5CBojAj0j0YS" type="video/quicktime" width="800" /></video>

 

Qualtrics.SurveyEngine.addOnload(function() {
    var base_element = document.querySelector(".SkinInner");
    base_element.insertAdjacentHTML('afterbegin', '<div id="sticky_vid" style="position: sticky; top:0;" align="middle">');

    var new_element = document.querySelector("#sticky_vid");
    new_element.innerHTML = '<video autoplay class="qmedia" height="400" preload="auto" width="800"><source src="https://unc.az1.qualtrics.com/CP/File.php?F=F_5zp3qW9UH4DmAbc" type="video/mp4" /><embed align="middle"  bgcolor="white" class="qmedia" height="400" pluginspage="http://www.apple.com/quicktime/download/" src="https://unc.az1.qualtrics.com/CP/File.php?F=F_5zp3qW9UH4DmAbc" type="video/quicktime" width="800" /></video>';

    base_element.style.zIndex = 1;
    new_element.style.zIndex = 10;

    this.hideNextButton();
    this.hidePreviousButton();

    var that = this;
    document.addEventListener('keydown', function keydownCallback(e) {
        var choiceID = null;
        switch (e.keyCode) {
            case 74: // 'J' was pressed
                choiceID = 1;
                break;
            case 75: // 'K' was pressed
                choiceID = 2;
                break;
        }
        if (choiceID) {
            document.removeEventListener('keydown', keydownCallback);
            that.setChoiceValue(choiceID, true);
            that.clickNextButton();
        }
    });
});

Hi @V.E. 

One of them is to use the “preload” attribute in your video tag and set it to “metadata” instead of “auto”. This will tell the browser to only load the video metadata (such as duration, dimensions, etc.) and not the entire video file. This may reduce the loading time and prevent the glitching effect. You can try changing your HTML code like this:

 

<video autoplay=“” class=“qmedia” height=“400” preload=“metadata” width=“800”><source src=“https://unc.az1.qualtrics.com/CP/File.php?F=F_56Y5CBojAj0j0YS” type=“video/mp4” /><embed align=“middle” autoplay=“false” bgcolor=“white” class=“qmedia” height=“400” pluginspage=“http://www.apple.com/quicktime/download/” src=“https://unc.az1.qualtrics.com/CP/File.php?F=F_56Y5CBojAj0j0YS” type=“video/quicktime” width=“800” /></video>

 


@Gaurav_27 Hi, thanks for the suggestion! It looks like the video doesn’t load at all anymore with that code. Do you have any ideas as to why? 


Hi @V.E. 

have you tried change the above mentioned.


@Gaurav_27 Yes, when I changed the code to what you had suggested, the video stopped loading.


@V.E. I think @TomG might be able to help you with this complex thing


@V.E. Did you copy @Gaurav_27 ‘s code as is?

The quotes in his code have been incorrectly formatted : “ and ” should be replaced with "

<video autoplay="" class="qmedia" height="400" preload="metadata" width="800"><source src="https://unc.az1.qualtrics.com/CP/File.php?F=F_56Y5CBojAj0j0YS" type="video/mp4" /><embed align="middle" autoplay="false" bgcolor="white" class="qmedia" height="400" pluginspage="http://www.apple.com/quicktime/download/" src="https://unc.az1.qualtrics.com/CP/File.php?F=F_56Y5CBojAj0j0YS" type="video/quicktime" width="800" /></video>

 


@vgayraud Thank you for the suggestion. I’ve tested your code, and although the bug now happens less frequently, it did still occur a couple of times when I tried it out. Any more ideas? I really appreciate the help!


@Gaurav_27 So sorry for the inconvenience but I’m still having trouble with the bug - I would really appreciate any suggestions you might have!


Leave a Reply