Giter VIP home page Giter VIP logo

mobile-inline-video's Introduction

mobile-inline-video ๐Ÿ‘Œ

A tiny, dependency-free library to let you play inline video on mobile devices like iPhone without opening the native player.

Usage

Include the JS:

<script type="text/javascript" src="mobile-inline-video.js"></script>

Make a new MIV (mobile inline video) object:

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 the object to your page:

//Append to body of page (default)
vid.appendTo();

//Append to an element with the "video" id
vid.appendTo(document.getElementById('video'));

Play/start the 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();
};

Controlling the video:

//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);
};

Thanks

This library was adapted and expanded from a solution by Kyle. ๐Ÿ‘

mobile-inline-video's People

Contributors

mikewojo avatar

Watchers

XiaoYang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.