JavaScript for uploaded Video | XM Community
Skip to main content

Hello, I want to create a JavaScript script for an uploaded video (from the library) that will address the following issues:
1. The video should appear automatically (autoplay).
2. The size should fit various screens, especially laptops, cellphones, and tablets.
3. Participants will not be able to click on the next button until the video reaches its end.

For issue 1, I'm using this code:
```html
<video autoplay loop=true style="pointer-events: none; width: 80%">
    <source src="my video" type="video/mp4" />
    Sorry, your browser doesn't support embedded videos.
</video>
```

For issue 3, I haven't used any code. Instead, I added another "timing" question to the page and delayed the display of the next button until the end of the video (I inserted the time it should stop).

The problems I'm encountering are:
a. The video continues to play despite the next button appearing at the end of the segment. The video loops, and I want to stop the looping and end playback when the video's time (151 seconds) is up.
b. I'm having difficulty defining the optimal size for the video to fit different screen types. It appears too small on the computer and adjusts better when the phone screen is turned sideways.

I would appreciate your assistance in writing a script that addresses all of the above.

Be the first to reply!

Leave a Reply