Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Youtube videos continue to play after swiping to a new article

Avatar

Level 3

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

2 Replies

Avatar

Level 2

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

Avatar

Level 2

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