Skip to content

movielala/video-player-auto-embedder

Repository files navigation

MovieLaLa Video Player Auto Embedder (MLLEmbed)

Code Climate

What is MLLEmbed (mll.embed)

MLLEmbed, or by it's module name mll.embed, is a script that turns YouTube embeds into MovieLaLa embeds. It looks for IFRAMEs and changes their URLs.

For example, this url:

http://www.youtube.com/embed/bo36MrBfTk4?autoplay=1

will become:

http://embed.movielala.com/embed/bo36MrBfTk4?autoplay=1&clientId=YourCompany

Details on Usage Methods

You have four options:

For Advanced RequireJS

Compatibilty with Youtube IFrame

Synchronous Loading

//Configuration Cloudflare powered CDN with 50+ POPs
<script src="https://assets-embed.movielala.com/mllembed.min.js"></script>
<script>
//Configuration
mllembed.config('clientId', 'YourCompany');
</script>

Asynchronous Loading

<script>
!function(e, t, n, s) {
    'use strict';
    var c, m = t.createElement(n), a = t.getElementsByTagName(n), r = a[0];
    m.async = !0, m.src = s, r.parentNode.insertBefore(m, r), c = function() {
        c.stack.push(arguments);
    }, c.stack = [], e.mllembed = c;
}(window, document, 'script', 'https://assets-embed.movielala.com/mllembed.min.js');

//Configuration
mllembed('config', 'clientId', 'YourCompany');
</script>

Handling Insertations after DOMContentReady

MLLEmbed automatically runs on DOMContentReady and load. If you are add iframes after, you can handle them like this:

//Append iframe
$('#mycontainer').append('<iframe src="http://www.youtube.com/embed/bo36MrBfTk4"></iframe>');

//Run MLLEmbed
mllembed.run();

With YouTube IFrame API

If you already have a YouTube IFrame API implementation, all you have to do is replace the URL of IFrame API with "https://assets-embed.movielala.com/iframe_api". There is no need to use MLLEmbed.

This is the original youtube loader code:

<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
</script>

All you have to do is change the URL:

<script>
var tag = document.createElement('script');
tag.src = "https://assets-embed.movielala.com/iframe_api"; //Changed
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
</script>

Please make sure you follow the documentation exactly if you decide not to use recommended techniques.

How to Build

  • Be sure you have Node.js installed.
  • Checkout the repository.
  • npm install.
  • gulp

How to Test

No tests yet.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published