bidgadget
asked on
HTML Audio speed control works on windows but not on MAC
I have written a site that plays mp3 audio files. I have three buttons that allows the listener to change the speed of the audio. It works perfect when playing on any windows computer, however when it is play on MAC it does not work at all. Here is my code.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<style>
button {
display: inline-block;
margin: 5px; /* space between buttons */
background: #000000; /* background color */
color: #ffffff; /* text color */
font-size: 1em;
font-family: ‘Georgia’, serif;
font-style: normal;
border-radius: 50px; /* rounded corners */
padding: 8px 16px; /* space around text */
-moz-transition: all 0.2s;
-webkit-transition: all 0.2s;
transition: all 0.2s;
float: unset;
}
</style>
<video id="myVideo" width="320" height="176" controls>
<source src="audio/audio/cio.mp3" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<div class="buttons">
<div class="action_btn">
<button name="SpeedX 1.5" class="action_btn submit" type="submit" value="Save" onclick="setPlaySpeed()">x1.2</button>
<button name="SpeedX 1" class="action_btn cancel" type="submit" value="Cancel" onclick="setPlaySpeed3()">x1.5</button>
<button name="SpeedX 1" class="action_btn cancel" type="submit" value="Cancel" onclick="setPlaySpeed4()">x1</button>
<p id="saved"></p>
</div>
</div>
<script>
var vid = document.getElementById("myVideo");
function getPlaySpeed() {
alert(vid.playbackRate);
}
function setPlaySpeed() {
vid.playbackRate = 1.2;
}
function setPlaySpeed3() {
vid.playbackRate = 1.5;
}
function setPlaySpeed4() {
vid.playbackRate = 1;
}
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.