Working on a Cross-Platform Ionic app for Android and iOS.
My requirement is to detect if some other app is running in PiP (Picture-in-Picture) mode within a floating window in front of my app screen.
I tried to use the visibilitychange event listener of the document expecting that it will return hidden if any floating window app is running in front of my app but that’s not the case.
It is only detecting when the app goes to the background or foreground with hidden or visible values respectively.
This is the code which I tried but I know that it’s wrong as it’s not detecting any PiP floating window of other app above my app:
<code>document.addEventListener('visibilitychange', function() {
if (document.visibilityState === 'hidden') {
stopTimer();
}
else {
startTimer();
}
});
</code>
<code>document.addEventListener('visibilitychange', function() {
if (document.visibilityState === 'hidden') {
stopTimer();
}
else {
startTimer();
}
});
</code>
document.addEventListener('visibilitychange', function() {
if (document.visibilityState === 'hidden') {
stopTimer();
}
else {
startTimer();
}
});