-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(showcase): add multi-player showcase
Resolves #3 by introducing a new showcase that displays multiple players on the same page. A button has been added to allow the user to toggle the mute state for both players. Note: only one player can have active tracking at a time, an issue has been created to provide documentation for this limitation, see: SRGSSR/pillarbox-web#208.
- Loading branch information
Showing
5 changed files
with
161 additions
and
34 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/layout/content/showcase/examples/multi-player-example.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pillarbox from '@srgssr/pillarbox-web'; | ||
|
||
// Initialize the Main Player | ||
const mainPlayer = pillarbox('main-player', { fill: true, debug: true }); | ||
mainPlayer.src({ src: 'urn:rts:video:6820736', type: 'srgssr/urn' }); | ||
|
||
// Initialize the Second Player | ||
const secondPlayer = pillarbox('second-player', { fill: true, muted: true, debug: true }); | ||
// Tracking is disabled for this source, only one source can be tracked at a time. | ||
secondPlayer.src({ src: 'urn:rts:video:6735513', type: 'srgssr/urn', disableTrackers: true }); | ||
|
||
// Add an event listener to a button with the id 'toggle-player' | ||
document.querySelector('#toggle-player').addEventListener('click', () => { | ||
// Toggle the mute state for both mainPlayer and secondPlayer | ||
pillarbox.getAllPlayers().forEach(player => { | ||
player.muted(!player.muted()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>Pillarbox Demo - Multi Player Showcase</title> | ||
<link rel="icon" type="image/x-icon" href="../../img/favicon.ico"> | ||
<link rel="stylesheet" href="./static-showcase.scss"/> | ||
</head> | ||
|
||
<body> | ||
<div class="showcase-content"> | ||
<h2>Multiple players</h2> | ||
|
||
<div class="video-container"> | ||
<video-js id="main-player" class="pillarbox-js" controls crossorigin="anonymous"></video-js> | ||
</div> | ||
|
||
<button class="showcase-btn" id="toggle-player">Toggle main player</button> | ||
|
||
<div class="video-container"> | ||
<video-js id="second-player" class="pillarbox-js" controls crossorigin="anonymous"></video-js> | ||
</div> | ||
|
||
<button class="showcase-btn" id="close-btn">Close this window</button> | ||
</div> | ||
<script type="module"> | ||
import pillarbox from '@srgssr/pillarbox-web'; | ||
|
||
// Initialize the Main Player | ||
const mainPlayer = pillarbox('main-player', { fill: true, debug: true }); | ||
mainPlayer.src({ src: 'urn:rts:video:6820736', type: 'srgssr/urn' }); | ||
|
||
// Initialize the Second Player | ||
const secondPlayer = pillarbox('second-player', { fill: true, muted: true, debug: true }); | ||
// Tracking is disabled for this source, only one source can be tracked at a time. | ||
secondPlayer.src({ src: 'urn:rts:video:6735513', type: 'srgssr/urn', disableTrackers: true }); | ||
|
||
// Add an event listener to a button with the id 'toggle-player' | ||
document.querySelector('#toggle-player').addEventListener('click', () => { | ||
// Toggle the mute state for both mainPlayer and secondPlayer | ||
pillarbox.getAllPlayers().forEach(player => { | ||
player.muted(!player.muted()); | ||
}); | ||
}); | ||
</script> | ||
|
||
<script type="module"> | ||
import pillarbox from '@srgssr/pillarbox-web'; | ||
|
||
document.querySelector('#close-btn').addEventListener('click', () => { | ||
window.close(); | ||
}); | ||
|
||
window.pillarbox = pillarbox; | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@import '../../scss/index'; | ||
|
||
body { | ||
max-width: var(--size-sm); | ||
} | ||
|
||
.showcase-content { | ||
margin-top: var(--size-8); | ||
padding: 0; | ||
border: 1px solid var(--color-7); | ||
border-radius: var(--radius-3); | ||
} | ||
|
||
.video-container { | ||
width: 100%; | ||
height: auto; | ||
aspect-ratio: var(--ratio-widescreen); | ||
padding: 0; | ||
} | ||
|
||
h2 { | ||
padding-left: var(--size-2); | ||
font-size: var(--size-4); | ||
} | ||
|
||
.showcase-btn { | ||
width: 100%; | ||
padding: var(--size-4) var(--size-3); | ||
color: var(--color-0); | ||
font-weight: var(--font-weight-6); | ||
font-size: var(--size-3); | ||
text-align: center; | ||
text-decoration: none; | ||
background-color: var(--color-9); | ||
border: 0; | ||
cursor: pointer; | ||
transition: background-color 0.4s, border-color 0.4s; | ||
} | ||
|
||
.showcase-btn:hover { | ||
background-color: var(--color-8); | ||
border-color: var(--color-9); | ||
} | ||
|
||
.showcase-btn:last-child { | ||
border-radius: 0 0 var(--radius-3) var(--radius-3); | ||
} |