2

I have a site where I'm using a JavaScript to add or remove a css class. Using this method I hide a div or show a div, as I need it. It works great.

The problem is one div opens a Video with a JWplayer, when I hide the "window" or better say, the div. The sound is still playing, so I need a code to put stop on the video when someone clicks the "hide" button or close button.

How do you do that? I have no idea.

Thanks

HTML

 <div class="videoquon">
         <div class='my-video-close'></div>
<div id='my-video'></div>
<script type='text/javascript'>
    jwplayer('my-video').setup({
        file: 'qvideo.f4v',
        width: '600',
        height: '337'
    });
</script>
</div>

JavaScript

  $('div.vidreveal a').click(
                function(event) {
                    event.stopPropagation();
                    $('div.videoquon').slideToggle(300);
                }
            );

   $('div.my-video-close').click(
                function(event) {
                    event.stopPropagation();
                    $('div.videoquon').slideToggle(300);
                }
            );
Phil Miller
  • 36,389
  • 13
  • 67
  • 90

1 Answers1

6

I don't know JW Player, but judging by their docs, I'm going to go with

$( 'div.my-video-close' ).click( function( event ) {
    event.stopPropagation();
    jwplayer( 'my-video' ).stop();
    $( 'div.videoquon' ).slideToggle( 300 );
});

...or jwplayer( 'my-video' ).pause(); depending on the desired effect.

isotrope
  • 1,847
  • 12
  • 10
  • 1
    I will give you correct answer , for the interest, but i just found this Ok the API info is here http://www.longtailvideo.com/support/jw-player/28850/using-the-javascript-api And to do that is as simple to add onclick='jwplayer().stop()' On the href or link. :D hope this helps some one. – DreaminMedia Queretaro Apr 09 '13 at 18:04
  • 1
    ...personally, IMHO, I hate to see inline JS. Especially when you're actually binding events somewhere else in your code. – isotrope Apr 09 '13 at 18:19
  • 1
    You can point me , how to add it, i would love to.. Also this is not working when the player is inside an iframe on a galery with "tabs", each tab has an iframe with video.. ¿any ideas? – DreaminMedia Queretaro Apr 09 '13 at 18:34
  • 1
    Targeting iFrame content with jQuery is a whole other subject matter. Example: http://stackoverflow.com/a/1639342/636709 – isotrope Apr 09 '13 at 18:40