Skip to main content
Known Participant
June 17, 2021
Answered

Help getting my video to play properly!

  • June 17, 2021
  • 2 replies
  • 3721 views

Hi,

 

I am trying to make a simple interactive video player. The main screen has two buttons. English and French. If the click English, the english video plays and I'm sure you can figure out what French does 😉

 

The videos are mp4, and I want them hidden while not being played. So when you press english, it should unhide the english video and then play the video. Seems simple enough!

 

However for some reason my video is not playing after it unhides the video. I have to click the button a second time for it to play the video. Also, if I remove the code for hiding and unhiding, my button works fine and plays the video on first click. Any idea what could be causing this? I want my button to unhide the video, and then play the video with one click.

 

English is the instance name for my video component. 

 

 

this.English.visible = false;
canvas.style.zIndex = "1";

this.button_2.addEventListener("click", fl_MouseClickHandler_3.bind(this));
function fl_MouseClickHandler_3() 

{
  this.English.visible = true;
  $("#English")[0].play();
}
​

 

 

Thanks very much!!

    This topic has been closed for replies.
    Correct answer ClayUUID

    Having two video elements exist at the same time, presumably buffering content at the same time, is an irresponsible waste of your users' bandwidth. The proper way to do this would be to have a single video element, that you set the source for when each button is clicked.

    2 replies

    ClayUUIDCorrect answer
    Brainiac
    June 18, 2021

    Having two video elements exist at the same time, presumably buffering content at the same time, is an irresponsible waste of your users' bandwidth. The proper way to do this would be to have a single video element, that you set the source for when each button is clicked.

    Known Participant
    June 18, 2021

    Smart! I think I know what you mean. A bit like how dymanic text works? 

     

    I can figure some things out, but programming is not my forte! 😄 

     

    Any tips on what the code should look like? I'll see if I can figure that out in the meantime.

     

    Thanks for the suggestion! 

    kglad
    Community Expert
    June 18, 2021

    You guys rock! 

     

    Thanks for the speedy support. Have a great day!!


    you're welcome.

    kglad
    Community Expert
    June 17, 2021

    use

     

      $("#English")[0].style.visibility = "hidden";  // or "visible"