| 217 | |
| 218 | // togglePip toggles Picture-in-Picture mode on the video |
| 219 | async function togglePip() { |
| 220 | try { |
| 221 | if (video !== document.pictureInPictureElement) { |
| 222 | pipButton.disabled = true; |
| 223 | await video.requestPictureInPicture(); |
| 224 | } else { |
| 225 | await document.exitPictureInPicture(); |
| 226 | } |
| 227 | } catch (error) { |
| 228 | console.error(error); |
| 229 | } finally { |
| 230 | pipButton.disabled = false; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | // hideControls hides the video controls when not in use |
| 235 | // if the video is paused, the controls must remain visible |