Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Youtube videos continue to play after swiping to a new article

royh70849153
Level 3
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
jerwarren
Level 2
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

jerwarren
Level 2
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