add picture in picture

This commit is contained in:
ian ramzy 2020-03-29 21:46:29 -04:00
parent ab8e43012e
commit e723a47aaa
2 changed files with 39 additions and 0 deletions

View File

@ -112,6 +112,12 @@
</button>
<div class="HoverState">Open Chat</div>
</div>
<div class="buttonContainer">
<button class="hoverButton" id="pip-button" onclick="{togglePictureInPicture()}">
<i class="fas fa-external-link-alt fa-xs"></i>
</button>
<div class="HoverState" id="pip-text">Enter Picture in Picture</div>
</div>
</div>

View File

@ -590,6 +590,39 @@ socket.on('chat message', function (msg) {
// Chat
//Picture in picture
const pipVideo = document.getElementById('remote-video');
function togglePictureInPicture() {
if ('pictureInPictureEnabled' in document) {
if (document.pictureInPictureElement) {
document.exitPictureInPicture()
.catch(error => {
logIt("Error exiting pip.");
logIt(error);
})
} else {
pipVideo.requestPictureInPicture()
.catch(error => {
logIt("Error entering pip.");
logIt(error);
});
}
} else {
alert("Picture in picture is not supported in your browser. Consider using Chrome.")
}
}
pipVideo.addEventListener('enterpictureinpicture', () => {
$('#pip-text').text("Exit Picture in Picture");
});
pipVideo.addEventListener('leavepictureinpicture', () => {
$('#pip-text').text("Enter Picture in Picture");
});
//Picture in picture
// auto get media
VideoChat.requestMediaStream();