Index: openacs-4/packages/proctoring-support/www/resources/proctoring.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/proctoring-support/www/resources/proctoring.js,v diff -u -r1.1.2.19 -r1.1.2.20 --- openacs-4/packages/proctoring-support/www/resources/proctoring.js 2 Jan 2023 15:26:01 -0000 1.1.2.19 +++ openacs-4/packages/proctoring-support/www/resources/proctoring.js 5 May 2023 09:26:11 -0000 1.1.2.20 @@ -587,6 +587,30 @@ } } + requestPictureInPicture(video) { + // + // Browser versions released 2022-2023 onward may decide to + // kill our video when the browser is put out of focus. Such a + // use case is quite common for exams that take place on tools + // different than the browser itself, e.g. written assignments + // on a word processor. To avoid this, we put the camera + // preview into a separate foregroung Picture-in-Picture. + // + // Mac OS was the first introducing this behavior, but now + // this seems to apply to other OSes as well. + // + video.addEventListener('loadeddata', function(e) { + const self = this; + this.requestPictureInPicture() + .then((pictureInPictureWindow) => { + console.log('Picture-in-Picture successfull', self); + }) + .catch(function (err) { + console.error('Picture-in-Picture failed', self, err); + }); + }); + } + createVideo(stream) { const video = document.createElement('video'); video.muted = true; @@ -602,6 +626,7 @@ video.addEventListener('pause', function(e) { this.play(); }); + this.requestPictureInPicture(video); return video; }