-
Notifications
You must be signed in to change notification settings - Fork 0
/
async-with-loader.html
61 lines (48 loc) · 2.53 KB
/
async-with-loader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MLLEmbedder - Example</title>
<script src="lib/jquery-2.1.3.min.js"></script>
<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", "../mllembed.min.js");</script>
<!--
The previous and the next script blocks can be joined without any problems.
They are not joined in this example because how our build environment works.
-->
<script>
/*
This example is different than sync and async-with-requirejs because it uses mllembed-loader and it's lazycaller.
All calls made here (like "mllembed('config', ...);" and "mllembed('ready', ...);") are not actually run
and are pushed to lazycaller's stack. When mllembed is loaded, it looks for the "lazycaller.stack" array
and executes every call stored in it.
By doing this, we can fake these calls and make them look sync.
*/
//Configuration
mllembed('config', 'clientId', 'SomeCompany');
mllembed('config', 'something', 'else');
//Calling the API
mllembed('ready', function (mllembed) {
//Add a new iframe
$('<iframe width="640" height="360" src="https://www.youtube.com/embed/zf_cb_Nw5zY?rel=0&controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>')
.appendTo('body');
//Run the automatic converter manually so it finds the iframe above
mllembed.run();
//Add another iframe
var iframe = $('<iframe width="640" height="360" src="https://www.youtube-nocookie.com/embed/_cLvpJY2deo?showinfo=0" frameborder="0" allowfullscreen></iframe>')
.appendTo('body');
//Ask mllembed to convert the inserted iframe
mllembed.run(iframe[0]);
});
</script>
</head>
<body>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ga99hMi7wfY" frameborder="0" allowfullscreen></iframe>
<iframe width="560" height="315" src="http://www.youtube.com/embed/bo36MrBfTk4?autoplay=1" frameborder="0" allowfullscreen></iframe>
</body>
</html>