-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added global page playback rate after every video or audio HTML5 element * Added media-playback.{css,js} to control behaviour and style * Added html-after-content for cargo doc command Signed-off-by: Lewis Cowles <[email protected]>
- Loading branch information
1 parent
fbe5ee4
commit 7fa3dea
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
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,12 @@ | ||
.playback-rate-controls ul { | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
text-align: center; | ||
} | ||
.playback-rate-controls li { | ||
display: inline; | ||
} | ||
.playback-rate-controls li:not(:last-of-type)::after { | ||
content: " | "; | ||
} |
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,25 @@ | ||
function setPlaybackSpeed(speed) { | ||
[].slice.call(document.querySelectorAll('audio,video')).map( | ||
function(e, idx) { | ||
e.playbackRate = speed; | ||
} | ||
); | ||
} | ||
(function() { | ||
[].slice.call(document.querySelectorAll('audio,video')).map( | ||
function(e, idx) { | ||
let controls = document.createElement('div'); | ||
controls.className = 'playback-rate-controls'; | ||
let list = document.createElement('ul'); | ||
list.innerHTML += '<li><a href="#" onclick="setPlaybackSpeed(0.5)">0.5⨉</a></li>'; | ||
list.innerHTML += '<li><a href="#" onclick="setPlaybackSpeed(1)">1⨉</a></li>'; | ||
list.innerHTML += '<li><a href="#" onclick="setPlaybackSpeed(1.25)">1.25⨉</a></li>'; | ||
list.innerHTML += '<li><a href="#" onclick="setPlaybackSpeed(1.5)">1.5⨉</a></li>'; | ||
list.innerHTML += '<li><a href="#" onclick="setPlaybackSpeed(1.75)">1.75⨉</a></li>'; | ||
list.innerHTML += '<li><a href="#" onclick="setPlaybackSpeed(2)">2⨉</a></li>'; | ||
controls.appendChild(list); | ||
e.parentNode.insertBefore(controls, e.nextSibling); | ||
} | ||
); | ||
})(); | ||
|
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,3 @@ | ||
<link rel="stylesheet" href="/media-playback.css"> | ||
<script type="text/javascript" src="/media-playback.js" defer></script> | ||
|