How to custom code to force 1.5x speed in an embedded video | XM Community
Skip to main content

ISSUE DESCRIPTION

I am trying to embed a video into qualtrics, such that the participant cannot interact with the video player, and it autoplays. This setup currently works, as I use the following HTML code:

<iframe height="800" src="https://www.youtube.com/embed/Crhpyg_a5XY?autoplay=1&controls=0&amp;showinfo=0&amp;loop=1" style="pointer-events: none" width="800"></iframe>

 

However, for another video, I would like to change the playback speed to 1.5x, again without the participant having to do so manually.

 

I tried to use the following JavaScript code in the question, but it did not work.

Qualtrics.SurveyEngine.addOnload(function() {
    // Function to set playback rate via YouTube API
    function setPlaybackRate() {
        var iframe = document.getElementById('video');
        iframe.contentWindow.postMessage('{"event":"command","func":"setPlaybackRate","args":k1.5],"id":1}', '*');
    }

  
});

 

How should I go about forcing the playback speed to 1.5x? Thanks!

In most cases, youtube is just going to ignore your playback rate and fallback on what the user has set.

Your best option is to download the video, open it up in an editing software, increase speed to 1.5x, reupload to youtube and use that link.

 


In most cases, youtube is just going to ignore your playback rate and fallback on what the user has set.

Your best option is to download the video, open it up in an editing software, increase speed to 1.5x, reupload to youtube and use that link.

 

Hi ahmed, thanks for your reply. I’ve tried your workaround before, but the issue is that youtube will copyright block reuploaded content, even if sped up and left unlisted, which is why I’m looking for a solution that will force the speed to 1.5x in the qualtrics embed. Is there any other alternative?

 

Thanks!


Hi ahmed, thanks for your reply. I’ve tried your workaround before, but the issue is that youtube will copyright block reuploaded content, even if sped up and left unlisted, which is why I’m looking for a solution that will force the speed to 1.5x in the qualtrics embed. Is there any other alternative?

@IndyMuk If Youtube will copyright claim, you can just host it elsewhere.


Hi ahmed, thanks for your reply. I’ve tried your workaround before, but the issue is that youtube will copyright block reuploaded content, even if sped up and left unlisted, which is why I’m looking for a solution that will force the speed to 1.5x in the qualtrics embed. Is there any other alternative?

@IndyMuk If Youtube will copyright claim, you can just host it elsewhere.

Oh, I wasn’t aware that I could use the HTML code and embedding in qualtrics for the Youtube video would work for another hosting site. What other sites are Qualtrics compatible that you might recommend?

 

Thanks!


Oh, I wasn’t aware that I could use the HTML code and embedding in qualtrics for the Youtube video would work for another hosting site. What other sites are Qualtrics compatible that you might recommend?

@IndyMuk Have you consider Vimeo? As I remember, you can even change the playback rate on Vimeo embedded video, unlike Youtube.


Oh, I wasn’t aware that I could use the HTML code and embedding in qualtrics for the Youtube video would work for another hosting site. What other sites are Qualtrics compatible that you might recommend?

@IndyMuk Have you consider Vimeo? As I remember, you can even change the playback rate on Vimeo embedded video, unlike Youtube.

That would be a fantastic option then! Do you happen to know how to code to change the playback rate on the Vimeo embed?

 

Thanks!


That would be a fantastic option then! Do you happen to know how to code to change the playback rate on the Vimeo embed?

@IndyMuk I think I saw something like that on this Community, but I don’t remember exactly where. Anyway, you can do the trick that @ahmedA told you.


@IndyMuk You could upload the video in the Qualtrics library and then use it inside a video element in your question HTML. Multiple posts on the community detail that.

For the playback rate, add this JS:

 

Qualtrics.SurveyEngine.addOnReady(function () {
const quest = this;
const qc = quest.getQuestionContainer();

const video = qc.querySelector("video");
video.playbackRate = 1.5;
});

 


@IndyMuk You could upload the video in the Qualtrics library and then use it inside a video element in your question HTML. Multiple posts on the community detail that.

For the playback rate, add this JS:

 

Qualtrics.SurveyEngine.addOnReady(function () {
const quest = this;
const qc = quest.getQuestionContainer();

const video = qc.querySelector("video");
video.playbackRate = 1.5;
});

 

Hi Ahmed,

 

Thank you for the JS code. However, Qualtrics’ library has a very conservative file limit for videos - is there a way to deal with that?


That would be a fantastic option then! Do you happen to know how to code to change the playback rate on the Vimeo embed?

@IndyMuk I think I saw something like that on this Community, but I don’t remember exactly where. Anyway, you can do the trick that @ahmedA told you.

 

Hi Nam, thanks for the note - however, I am having trouble embedding the Vimeo video with the same conditions as per the youtube video in the original post (forcing autoplay, without info, and without the participant able to interact with the video player). I tried using this code, but it does not work - could you please help me with this?

 

Thanks!

 

<iframe height="800" src="https://player.vimeo.com/video/1008494331?&amp;autoplay=1&amp;controls=0&amp;showinfo=0&amp;loop=1&amp;start=90" style="pointer-events: none" width="800"></iframe>


<iframe height="800" src="https://player.vimeo.com/video/1008494331?&amp;autoplay=1&amp;controls=0&amp;showinfo=0&amp;loop=1&amp;start=90" style="pointer-events: none" width="800"></iframe>

@IndyMuk Well, it worked for me, autoplay, no info, no interaction when I hover my mouse over it.
 

 


You could reencode to reduce the file size. 

There are multiple upload options GIthub, S3, Netlify, any other server.

 

However, some questions you should ask before searching for alternatives:

How long is your video? Do you really need the full video?

Do you really need to show it in such high quality that it exceeds the file size? 

 


<iframe height="800" src="https://player.vimeo.com/video/1008494331?&amp;autoplay=1&amp;controls=0&amp;showinfo=0&amp;loop=1&amp;start=90" style="pointer-events: none" width="800"></iframe>

@IndyMuk Well, it worked for me, autoplay, no info, no interaction when I hover my mouse over it.
 

 

Hi Nam - 

 

Apologies - it does work! Thank you so much all for the help :)

 

Much appreciated.


Hi Nam - 

Apologies - it does work! Thank you so much all for the help :)

Much appreciated.

@IndyMuk You’re welcome 😁


Leave a Reply