Skip to content

Instantly share code, notes, and snippets.

@bobdenotter
Last active August 22, 2017 21:55
Show Gist options
  • Save bobdenotter/5578624 to your computer and use it in GitHub Desktop.
Save bobdenotter/5578624 to your computer and use it in GitHub Desktop.
Short example on how to use a MediaElement.js player with Bolt's 'video' field. First, just add a video in Bolt, like this: http://i.imgur.com/EnxqnW3.png . Then, use it in your template, like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mediaelement example</title>
<script src="{{ paths.theme }}javascripts/jquery-1.9.1.min.js"></script>
<script src="http://mediaelementjs.com/js/mejs-2.11.2/mediaelement-and-player.min.js"></script>
<link rel="stylesheet" href="http://mediaelementjs.com/js/mejs-2.11.2/mediaelementplayer.min.css" />
<link rel="stylesheet" href="http://mediaelementjs.com/js/mejs-2.11.2/mejs-skins.css" />
</head>
<body id="home">
<h1>Mediaelement example.</h1>
{# print out the contents of Bolt's video object. Not needed, but helps to see what's in it. #}
{{ print(record.video) }}
{# Insert the video HTML-tag. #}
{% if record.video.url != "" %}
<video width="640" height="360" id="player1" preload="none">
<source type="video/youtube" src="{{ record.video.url }}" />
</video>
{% else %}
<p>No video entered in backend.</p>
{% endif %}
{# Initialize mediaelementplayer #}
<script>
jQuery(document).ready(function($) {
$('#player1').mediaelementplayer();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment