Results 1 to 5 of 5

Thread: Side Push Menu v1.1 - Stop Media playing when menu is closed?

  1. #1
    Join Date
    May 2014
    Posts
    31
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default Side Push Menu v1.1 - Stop Media playing when menu is closed?

    1) Script Title: Side Push Menu v1.1

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/pushmenu.htm

    3) Describe problem: Not so much a problem as a query if something is possible. I am using multiple instances of the side push menu to be able to bring in additional content if wanted at various points on my site... A couple of these include videos. Now the problem is when the pushmenu screen is dismissed the video keeps playing (Unless the user thinks to manually stop it) leaving distracting audio playing.

    What I was hoping to achieve is something that stops or better yet pauses the video when the menu is closed. I have no idea what I'm doing with javascript but I am assuming (Hoping!) there is some way to attach a "stop all media" code to activate when the menu is in the closed position? I don't want autoplay or anything so no need to have a play on open / stop on close function, just something that tells all media within the push section to stop when it is closed... (Or if easier just all media anywhere on the site, there are no videos outside of the content that slides in to be affected, and videos in other pushed content should already be stopped anyway)

    Hope I've explained this well enough, and that a solution is a) possible, and b) hopefully simple to implement!

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,839
    Thanks
    49
    Thanked 247 Times in 239 Posts
    Blog Entries
    56

    Default

    In pushmenu.js there's this line:
    Code:
    .find('.closebutton').on('click', function(e){thismenu.toggle('closed')	})
    Replace it with something like:
    Code:
    .find('.closebutton').on('click', function(e){document.getElementById('myVideo').pause(); thismenu.toggle('closed')	})
    where myVideo is the id for the video tag.

  3. The Following User Says Thank You to molendijk For This Useful Post:

    Neil1 (07-07-2019)

  4. #3
    Join Date
    May 2014
    Posts
    31
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    Awesome! Works perfectly (-ish) thank-you very much!

    There is one little tweak I'd like if you are able and don't mind helping again?

    I was using a modified version of pushmenu that also allows the pushed content to be closed with a swipe on touch screens, is it possible to do the same if it is closed that way?

    http://www.dynamicdrive.com/forums/s...enu&highlight= < This thread has the amended code I am using to add the swipe function, hopefully it is just a simple switching of a line or two as the original one was

    And once again many thanks for the help you've already provided

  5. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,839
    Thanks
    49
    Thanked 247 Times in 239 Posts
    Blog Entries
    56

    Default

    I found these lines in ddadmin's script:
    Code:
    swipeStatus: function(event, phase, direction, distance){
    if (phase == 'end' && direction == 'left')
    thismenu.toggle('closed')
    }
    Replace that part with this:
    Code:
    swipeStatus: function(event, phase, direction, distance){
    if (phase == 'end' && direction == 'left')
    document.getElementById('myVideo').pause(); thismenu.toggle('closed')
    }
    It might work.

  6. The Following User Says Thank You to molendijk For This Useful Post:

    Neil1 (07-07-2019)

  7. #5
    Join Date
    May 2014
    Posts
    31
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    Thanks but no luck I'm afraid, it keeps playing when closed if you swipe it closed... But many thanks for trying, it was appreciated

Similar Threads

  1. Side Push Menu
    By Stevenj in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-14-2016, 03:10 AM
  2. More functionality to Side Push Menu
    By SpikeLee in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 01-17-2015, 07:01 PM
  3. Custom image for 'Toggle Menu' event in Side Push Menu
    By Neil1 in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 05-28-2014, 04:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •