A tiny, dependency-free library to let you play inline video on mobile devices like iPhone without opening the native player.
<script type="text/javascript" src="mobile-inline-video.js"></script>
var vid = MIV.new({src: 'http://www.w3schools.com/html/mov_bbb.mp4', id: 'test'});
A new MIV object can have the following parameters:
- src - URL to the video
- id (optional) - ID name to give the object if you want to reference it with MIV.get() later
- width (optional) - Force a width on the video
- height (optional) - Force a height on the video
//Append to body of page (default)
vid.appendTo();
//Append to an element with the "video" id
vid.appendTo(document.getElementById('video'));
Please note, for iOS devices, this needs to be initiated from a click event.
document.getElementById('playButton').onclick = function() {
vid.play();
// or...
// vid.start();
};
//Play
document.getElementById('playButton').onclick = function() {
vid.play();
};
//Pause
document.getElementById('pauseButton').onclick = function() {
vid.pause();
};
//Seek to 4 seconds in
document.getElementById('seekButton').onclick = function() {
vid.seek(4);
};
This library was adapted and expanded from a solution by Kyle. ๐