Skip to content

Latest commit

 

History

History
47 lines (39 loc) · 1.26 KB

usage.md

File metadata and controls

47 lines (39 loc) · 1.26 KB

Usage

You can use this as a standalone library if you wish, or just stick with the full MediaElementPlayer.

Automatic start

You can avoid running any startup scripts by added class="mejs-player" to the <video> or <audio> tag. Options can be added using the data-mejsoptions attribute.

<video src="myvideo.mp4" width="320" height="240" 
		class="mejs-player" 
		data-mejsoptions='{"alwaysShowControls": true}'></video>

Vanilla JavaScript

<script>
var player = new MediaElementPlayer('#player', {success: function(mediaElement, originalNode) {
	// do things
}});
</script>	

jQuery

<script>
$('#mediaplayer').mediaelementplayer({success: function(mediaElement, originalNode) {
	// do things
}});

// To access player after its creation through jQuery use:
var player = $('#mediaplayer')[0].player;

// With iOS (iPhone), since it defaults always to QuickTime, you access the player directly;
// i.e., if you wanna exit fullscreen on iPhone using the player, use this:
var player = $('#mediaplayer')[0];
player.webkitExitFullScreen();
 
</script>

Back to Main