Reputation: 11
Following code does not have any effect (audio continues to play in the same manner before pressing the PlayFast button iPad. It works beautifully on Safari on windows box
function playFast()
{
var myVideo = document.getElementsByTagName('audio')[0];
myVideo.playbackRate = myVideo.playbackRate + 1;
alert(myVideo.playbackRate);
}
Initially the playbackRate
is set to 1
Can any one please help.
Upvotes: 1
Views: 3744
Reputation: 681
You can set the audio or video playbackRate property to nonzero values to play media in slow motion (values >0 and <1) or fast forward (values >1) in Safari on the desktop and iOS 6+.
Upvotes: 1
Reputation: 7002
To give an updated answer with the official statement from Apple on iOS:
You can set the audio or video playbackRate property to nonzero values to play media in slow motion (values >0 and <1) or fast forward (values >1) in Safari on the desktop. Setting playbackRate is not currently supported on iOS.
Having said that I have managed to change the playbackRate on iPad/iOS7 with the following code. It seems you need to pause the video before the playbackRate can be set. I am just wondering now if the Apple document is up to date (?)
<video controls id="videoTag" width="640" height="360" preload="none">
<source src="media/360p.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' id="mp4Source">
</video>
<div id="change">change rate to x2</div>
<div id="change2">change rate to x0.5</div>
<script type="text/javascript">
var video = document.getElementById('videoTag');
video.addEventListener('canplay',function(){
document.getElementById('change').addEventListener('click',function(){
video.pause();
video.playbackRate = 2.0;
video.play();
},false);
document.getElementById('change2').addEventListener('click',function(){
video.pause();
video.playbackRate = 0.5;
video.play();
},false);
},false);
</script>
Upvotes: 3
Reputation: 236458
Playback Rate in JavaScript
You can set the audio or video playbackRate property to nonzero values to play media in slow motion (values >0 and <1) or fast forward (values >1) in Safari on the desktop. Setting playbackRate is not currently supported on iOS.
Upvotes: 1