Faced such a situation: on the page there is some kind of control on the click on which the block pops up (jquery- show method) with youtub code with the player. You press the "close" button in the block and this block disappears (jquery-method .hide ). But the video does not stop :) More precisely in all browsers, everything seems to be ok, but in chrome, even with a hidden block, you can hear that the video is “somewhere out there” still playing ...

It would be logical when you click the "close" button, first pause the movie, and then hide the unit with the player. Is it possible Or is there another way?

    1 answer 1

    There is a way to simply delete the block with the player (jquery-method .remove).

    • one
      those. the user closes the block, the block is deleted, and then the user again presses the button to open the block with the video, but there is no block anymore :) Not a very good option. - xhr
    • one
      The user presses the button - the block is formed. - ling
    • And youtube videos are cached, so if the user "closes" the video - it will not load, if it opens - everything that has already been loaded will be restored. @xhr - When I read "I don’t have a block anymore," I doubted a little about your competence =) - Zowie
    • @AlexWindHope, you can doubt a lot. I have something to do with it. remove api.jquery.com/remove removes elements from the DOM. Therefore, if you remove a hide (hide) block and make remove for it, then it will no longer physically be on the page. Now the user (without reloading the page) again causes (show) this overlay ... and what should it seem to him? - there is no block already - no :) - xhr
    • @ling can form the contents of the block "ajax'om", but it is formed by the server when creating the page. And I don’t want to alter this moment at all - for sure there is an easier way. So deleting a block is a bad idea. - xhr