문제

So basically I have Stratus2 media player running on a parallax website. There are other media files accessible within the website as well (youtube videos that play in prettyPhoto lightbox). Is there a function that can pause the Stratus player, whenever the user clicks on these media files?

$('.video').click(function() {

 $.stratus.stop()

}
)
도움이 되었습니까?

해결책

Include the above mentioned library along with jQuery in your page. Now suppose each of the media elements on your page have a class "media" applied to them. Now the following code will publish an event on click of any of these items..

 $(".media").click(function() { 
    jQuery.pubsub.publish('media.clicked', {});
 });

and the following code will be required to subscribe to this event published above and stop the previous media from playing.

jQuery.pubsub.subscribe('media.clicked', function(topic, msg){
    $.stratus.stop();
});

다른 팁

You can use the pub-sub (publish and subscribe) pattern to solve your problem. So the basics of the solution will be as follows: Raise an event on click of each of your media files.. a common jQuery selector might come in handy to raise this event from a common piece of code.

Now there is a listener method that gets triggered as soon as the desired event described above gets raised. Within this listener you can put in your function to stop the video being played.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top