This is my current code in which it takes link from google drive which i use in my wordpress for playing mp3.
This code works fine in compiler and even playbackspeed works fine but when i put this code in wordpress post it does not work
It will not increase playback speed even after clicking on it.
Help!
<!DOCTYPE html>
<html>
<body>
<style>
body {
display: grid;
justify-items: center;
grid-row-gap: 10px;
}
#actions {
background: white;
}
#actions button {
outline: none;
background-color: #555555;
border-radius: 12px;
border: none;
color: white;
padding: 10px 14px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 4px 2px;
cursor: pointer;
}
</style>
<button onclick="getPlaySpeed()" type="button">What is the playback speed?</button>
<audio id="audio" controls="controls">
<source src="https://drive.google.com/uc?export=download&id=1bDkkNlMt2TIrwBLtgjFoL5odO7rbGS06">
</audio>
<p>Audiobook Speed</p>
<div id="actions">
<button onclick="setPlaySpeed(1.00)" type="button">1.00x</button>
<button onclick="setPlaySpeed(1.25)" type="button">1.25x</button>
<button onclick="setPlaySpeed(1.50)" type="button">1.50x</button>
<button onclick="setPlaySpeed(1.75)" type="button">1.75x</button>
<button onclick="setPlaySpeed(2.0)" type="button">2.0x</button>
</div>
<script>
var audio = document.getElementById("audio");
function setPlaySpeed(speed) {
audio.playbackRate = speed;
}
</script>
</body>
</html>
2
Answers
Your HTML5 media element has an attribut
playbackRate
, you could modify that integer to the speed you want.(reference)
I think this should do the job!
(ref)