Skip to content

Commit

Permalink
uploading project files
Browse files Browse the repository at this point in the history
  • Loading branch information
bshohug committed Apr 15, 2023
1 parent 4eecb56 commit 76671ce
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
Binary file added favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Picture in Picture</title>
<link rel="icon" type="image/png" href="favicon.png" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css"
/>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<!-- Video -->
<video id="video" controls height="360" width="640" hidden></video>
<!-- Button -->
<div class="button-container">
<button id="button">START</button>
</div>
<!-- Script -->
<script src="script.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const videoElement = document.getElementById('video');
const button = document.getElementById('button');

async function selectMediaStream() {
try {
const mediaStream = await navigator.mediaDevices.getDisplayMedia();
videoElement.srcObject = mediaStream;
videoElement.onloadedmetadata = () => {
videoElement.play();
};
} catch (error) {
// Catch Error Here
// console.log('whoops, error here:', error);
}
}

button.addEventListener('click', async () => {
// Disable Button
button.disabled = true;
// Start Picture in Picture
await videoElement.requestPictureInPicture();
// Reset Button
button.disabled = false;
});

// On Load
selectMediaStream();
64 changes: 64 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@import url('https://fonts.googleapis.com/css2?family=Barlow&display=swap');

html {
box-sizing: border-box;
}

body {
margin: 0;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Barlow', sans-serif;
background: rgb(255, 255, 255);
}

/* Button */
#button {
align-items: center;
appearance: none;
background-color: #fcfcfd;
border-radius: 4px;
border-width: 0;
box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px,
rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #d6d6e7 0 -3px 0 inset;
box-sizing: border-box;
color: #36395a;
cursor: pointer;
display: inline-flex;
font-family: 'JetBrains Mono', monospace;
height: 48px;
justify-content: center;
line-height: 1;
list-style: none;
overflow: hidden;
padding-left: 16px;
padding-right: 16px;
position: relative;
text-align: left;
text-decoration: none;
transition: box-shadow 0.15s, transform 0.15s;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
white-space: nowrap;
will-change: box-shadow, transform;
font-size: 18px;
}

#button:focus {
box-shadow: #d6d6e7 0 0 0 1.5px inset, rgba(45, 35, 66, 0.4) 0 2px 4px,
rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #d6d6e7 0 -3px 0 inset;
}

#button:hover {
box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px,
rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #d6d6e7 0 -3px 0 inset;
transform: translateY(-2px);
}

#button:active {
box-shadow: #d6d6e7 0 3px 7px inset;
transform: translateY(2px);
}

0 comments on commit 76671ce

Please sign in to comment.