Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable CSS PiP, when native PiP is active already #122

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion player/picture-in-picture/scrollListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ function adjustPlayer() {
const lowerEdge = container.offset().top + container.height();
const switchToMinPlayerPos = lowerEdge - (window.innerHeight / 3);
const currentScrollPos = document.body.scrollTop || document.documentElement.scrollTop;
const nativePipEnabled = player.getViewMode() === bitmovin.player.ViewMode.PictureInPicture;

/* Disable CSS PiP, if native PiP is already in use */
if (nativePipEnabled) {
document.querySelector('.player-switch').classList.remove('fixed-player');
return;
}

/* toggle the css-class responsible for the player moving to the lower right corner */
if (currentScrollPos > switchToMinPlayerPos) {
if (currentScrollPos > switchToMinPlayerPos && !nativePipEnabled) {
$('.player-switch').addClass('fixed-player');
} else {
$('.player-switch').removeClass('fixed-player');
Expand Down
7 changes: 5 additions & 2 deletions player/picture-in-picture/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var conf = {
)
;
}
}
},
viewmodechanged: function() {
adjustPlayer();
},
}
};

Expand All @@ -44,4 +47,4 @@ player.load(source).then(function () {
if (container.height() <= playerHeight) {
container.height(playerHeight);
}
});
});