Youtube videos continue to play after swiping to a new article

royh70849153

28-01-2016

I've embedded some Youtube videos in some of my content, which seem to work well.  However, when you swipe horizontally, the video does not stop playing and can be heard while reading the next article.

is there something in the API that will tell me when the users are leaving the article so i can fire the js to stop the video?

thank you for your time!

r

Accepted Solutions (0)

Answers (2)

Answers (2)

jerwarren

28-01-2016

One workaround you could do:

Using the gesture API, you can disable all gestures, and listen for the swipe yourself.  Then stop the video, then hand it back to DPS to let the article change happen.

Last time i tried using the gesture api like this for swiping, though, it introduced some weird content refresh behavior.  If you want to try it, you can do it like this:

            adobeDPS.Gesture.disableNavigation();

            $('.content').on('swipe',function() {

               [code to stop the media playing]

                adobeDPS.Gesture.relinquishCurrentGesture();

            });


You'll need to include the gesture api found here: 20150706 Adobe DPS 2015 HTML Gesture API - Examples.zip

jerwarren

28-01-2016

I used to use document.hasFocus() in the past to do this.  However, this no longer works.  Not only that, but it's broken differently on each platform.

Here's a post from a few days ago where I'm asking about it:

document.hasFocus() behavior inconsistencies