Question

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()

}
)
Was it helpful?

Solution

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();
});

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top