Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Stopping my embedded Youtube Videos on click

I've been struggling with this for a while now and I've tried a number of solutions but I'm totally stuck on this: I have a number of embedded videos from YouTube on my Site and I have navigation buttons. I want the videos to be paused as soon as any of the buttons are clicked, no matter how many of them are playing at that time. I embedded them the classic way by using the iframe code that YouTube gives you when clicking "embed" and gave them the ".yt" class.

My function currently looks like this:

$(function () {
    
    $('#shadingleft').on('click', function () {
        rotateLeft();
        reset();
        selector = selector - 1;
        if (selector <= -1) {
            selector = 9;
        }
        $('.clicked').toggleClass('clicked');
    })
    
    $('#shadingright').on('click', function () {
        rotateRight();
        reset();
        selector = selector + 1;
        if (selector >= 10) {
            selector = 0;
        }
        $('.clicked').toggleClass('clicked');
    })
    
    $('#shadingtop').on('click', function () {
        rotateUp();
        $('.clicked').toggleClass('clicked');
    })
    
    $('#shadingbottom').on('click', function () {
        rotateDown();
        $('.clicked').toggleClass('clicked');
    })
    
    $('.art').on('click', function () {
        $(this).toggleClass('clicked');
    })
    
});

As you can see I already managed to toggle the highlighted ".art" elements in my gallery using toggleClass. Unfortunately it doesn't seem to work for playing and pausing videos. Whenever one of the four "shading..." elements is clicked I want my ".yt" elements to stop playing the embedded video.

Thanks for helping!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is a actually a big limitation with iframes. Most browsers won't allow a page's scripts to interact with the content of its iframes for security reasons. So chances are that there is no way at all to do that.

One way you could stop videos would be to reload the youtube iframe entierly, but that would put it back to 00:00 as if it was never played.

Another would be to try and fetch the video stream from youtube on your server and then displaying it in a player of your own on your page. (Which is obviously way more complicated than using an iframe)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!