1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Stop the sound playing when video player closes

Discussion in 'jQuery' started by Alex Duncan, Oct 10, 2019.

  1. #1
    I have a video player on a popup box, when I close the popup the sound continues to play in the background,how do I stop the audio one the popup is closed?

    <div id="animatedModal" class="popup-modal">
    <!--THIS IS IMPORTANT! to close the modal, the class name has to match the name given on the ID -->
    <div id="btn-close-modal" class="close-animatedModal close-popup-modal"> <i class="ion-close-round"></i> </div>
    <div class="clearfix"></div>
    <div class="modal-content">
    <div class="container">
    <div class="portfolio-padding">
    <div class="col-md-8 col-md-offset-2">
    <h2>Simple Glitter Application<br /> By Creative Services</h2>
    <div class="h-50"></div>
    <p>A quick and simple demonstration to show how to apply a fine glitter, this should only be completed at the designated glitter station, remember to tidy up afterwards.</p>
    <p>If you require glue pens ask the Mocking-up Team in creative support</p>
    <br />
    <br />

    <div align="center";>
    <video controls width="640" width="480" data-type="video" data-offsetY="2400" data-speed="1.5">

    <source src="Mov/SimpleGlitter.mp4" type="video/mp4" />


    <br />
    <br />
    Glue pen, chosen glitter, a brush and a sheet of A3 paper not card.</p>
    <br />
    <br /> </div>
    <!-- jQuery -->
    <script src="js/jquery.js"></script>
    <!-- plugins -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/plugins.js"></script>
    <script src="js/aos.js"></script>
    <script src="js/jquery.form.js"></script>
    <script src="js/jquery.validate.min.js"></script>

    <!-- main script -->
    <script src="js/custom.js"></script>

    Alex Duncan, Oct 10, 2019 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    What do you have that's closing the modal? Is it some sort of outdated outmoded jQuery nonsense instead of letting CSS do the work for you?

    Wherever your code is closing the modal, add a hook there to send the VIDEO tag the pause command.

    So if your video were id="modalVideo", you'd:


    That said... jQuery's bad enough without the bootcrap or whatever framework you're using there. <p> doing a numbered heading's job, double breaks doing margin or padding's job, double breaks don't P's job, clearfix like it's still 2003, attributes like "align" that have zero business in any HTML written after 1998, etc, etc...

    There's a reason I say the only thing you can learn from these frameworks is how NOT to write HTML, CSS, or JavaScript.

    I'd have to see it live, but chances are that other than the pause on close (do you have play on open?) there's no reason for this to even be using JavaScript, much less the train wreck laundry list of how NOT to use JavaScript that is jQuery.
    deathshadow, Oct 11, 2019 IP