Forum Discussion

randykepple's avatar
randykepple
Community Member
1 month ago

Embedded Videos and Locked Navigation

Hello Heroes, 

I'm working on a medical course for clinical staff and have been asked to embed a YouTube video that is less than 3 minutes in the course. Further, they want to ensure the learner has watched the video before moving forward in the course, which is pretty common. My first challenge was getting the embed code to work properly with the requested start/stop point. I was able to fine tune that embed code from YouTube using Copilot and it works great in Storyline. 

Here's where I'm stuck. I embedded the video on a slide by itself. On the previous slide, I have a notice that coming up next is a video with audio, etc. Then, when they click "NEXT" it goes to the embedded video and starts playing. To prevent the learner from moving forward in the course until ensuring they have viewed the video, I thought I could disable the next button and set a trigger to go to the next slide when the timeline ends. However, because it's an embedded video, the timeline is 2-3 seconds, basically whatever I make it and it ends up advancing to the next slide before the video starts. 

I could adjust the timeline so that it runs for the 2:50 and have a layer pop up at the end with a button to move forward? What would you recommend me doing to accomplish this? The course includes another video that I'll have to configure as well, so I would really like to learn how to do this so that it works reliably with little complications. And yes, I have tested the embed code in our LMS and it starts/stops exactly where I want. Appreciate your insights and assistance learning how to make this happen. 

20 Replies

  • I stretch the timeline, yeah. I just extend it the full length of the video. You'd still be able to use the trigger that sends the learner to the next slide when the timeline ends.

  • randykepple's avatar
    randykepple
    Community Member

    The challenge I'm facing with this method is that the timing is not aligning with the parameters set for the embed code. For some reason, there is just enough of a delay that the video ends before the timeline. I've made some adjustments, but it's still not how I'd like it to work. The bigger issue is that you can't preview the changes until you publish the course to the LMS, so it's a LOT of back/forth. 

  • CarlFink1's avatar
    CarlFink1
    Community Member

    Couldn't you use the "When the media completes" trigger?

    • randykepple's avatar
      randykepple
      Community Member

      I appreciate that suggestion, and I did test adding a trigger but because the video is embedded using Insert > Video > Video from Website there is no way for Storyline to know when the embedded video has completed. I added parameters to the embed code to start/stop the video where they wanted it, but that isn't communicated or connected to the trigger. 

      • Nedim's avatar
        Nedim
        Community Member

        randykepple​ 

        By using Insert > Video > Video from Website, you can embed a YouTube video, but the embedded player does not expose the YouTube IFrame API, so events such as ENDED cannot be detected directly.

        A more flexible approach is to embed the video through a Web Object that loads a custom index.html. This allows you to initialize the YouTube IFrame API, listen for the player's onStateChange event, and detect when the video reaches the ENDED state. When that event occurs, use the Storyline Player API (GetPlayer().SetVar()) to update a Storyline variable (for example, videoComplete). You can then create a Storyline trigger to enable the Next button or advance to the next slide when that variable changes.

        Alternatively, if you want the Next button to be disabled each time the learner revisits the slide, disable it when the timeline starts and enable it only after the video reaches the ENDED state. This ensures the learner must watch the video to completion on every visit before the Next button becomes available. 

        Example HTML and demonstration are provided below.

        <div id="player"></div>
        
        <script src="https://www.youtube.com/iframe_api"></script>
        
        <script>
        function onYouTubeIframeAPIReady() {
          new YT.Player("player", {
            width: "100%",
            height: "100%",
            videoId: "taIdxEH_Kus",
            events: {
              onStateChange(e) {
                if (e.data === YT.PlayerState.ENDED) {
                  window.parent.GetPlayer().SetVar("videoComplete", true);
                  //optionally enable the next button when the video is complete
                  const  next = window.parent.document.querySelector('#next');
                  next.classList.remove('cs-disabled');
                }
              }
            }
          });
        }
        </script>
  • sarah02's avatar
    sarah02
    Community Member

    Storyline can't tell when an embedded YouTube video has finished, so the Next button can't be unlocked automatically. A simple workaround is to match the slide timer to the video's length and show the Next button only after that time has passed.

    • CarlFink1's avatar
      CarlFink1
      Community Member

      Will that work if the viewer pauses the video and doesn't restart it for, say, one minute?

      • randykepple's avatar
        randykepple
        Community Member

        All of this is a non-starter if I can't get the embed script to work and it's not, despite my best efforts, the assistance and insights from Nedim and others and hours of testing and AI troubleshooting. I'm done trying to make this work. They also want this activity gated, so they can ensure the video was watched before moving forward in the course. I'm just going to capture a screen recording of the video using Camtasia and creating my own MP4 file that I can drop into my course and program. Frustrating beyond words that embedding a YouTube video in today's modern world is so fraught with challenges like this. :)