1 /* init.js - initialization and configuration of Popcorn and the widgets |
1 /* init.js - initialization and configuration of Popcorn and the widgets |
2 exemple json configuration: |
2 exemple json configuration: |
3 |
3 |
4 */ |
4 */ |
5 |
5 |
6 IriSP.configurePopcorn = function (options) { |
6 IriSP.configurePopcorn = function (layoutManager, options) { |
7 var pop; |
7 var pop; |
|
8 var containerDiv = layoutManager.createDiv(); |
8 |
9 |
9 switch(options.type) { |
10 switch(options.type) { |
10 /* |
11 /* |
11 todo : dynamically create the div/video tag which |
12 todo : dynamically create the div/video tag which |
12 will contain the video. |
13 will contain the video. |
13 */ |
14 */ |
14 case "html5": |
15 case "html5": |
15 pop = Popcorn("#" + options.container); |
16 var tmpId = Popcorn.guid("video"); |
|
17 IriSP.jQuery("#" + containerDiv).append("<video src='" + options.file + "' id='" + tmpId + "'></video>"); |
|
18 pop = Popcorn("#" + tmpId); |
16 break; |
19 break; |
17 |
20 |
18 case "jwplayer": |
21 case "jwplayer": |
19 var opts = IriSP.jQuery.extend({}, options); |
22 var opts = IriSP.jQuery.extend({}, options); |
20 delete opts.container; |
23 delete opts.container; |
21 pop = Popcorn.jwplayer("#" + options.container, "", opts); |
24 pop = Popcorn.jwplayer("#" + containerDiv, "", opts); |
22 break; |
25 break; |
23 |
26 |
24 default: |
27 default: |
25 pop = undefined; |
28 pop = undefined; |
26 }; |
29 }; |
27 |
30 |
28 return pop; |
31 return pop; |
29 }; |
32 }; |
30 |
33 |
31 IriSP.configureWidgets = function (popcornInstance, guiOptions) { |
34 IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) { |
32 |
35 |
33 var dt = new IriSP.DataLoader(); |
36 var dt = new IriSP.DataLoader(); |
34 var serialFactory = new IriSP.SerializerFactory(dt); |
37 var serialFactory = new IriSP.SerializerFactory(dt); |
35 |
38 |
36 var params = {width: guiOptions.width, height: guiOptions.height}; |
39 var params = {width: guiOptions.width, height: guiOptions.height}; |
37 var lay = new IriSP.LayoutManager(params); |
40 |
38 lay.setPopcornInstance(popcornInstance); |
|
39 |
|
40 var ret_widgets = []; |
41 var ret_widgets = []; |
41 var index; |
42 var index; |
42 |
43 |
43 for (index = 0; index < guiOptions.widgets.length; index++) { |
44 for (index = 0; index < guiOptions.widgets.length; index++) { |
44 var widget = guiOptions.widgets[index]; |
45 var widget = guiOptions.widgets[index]; |
45 var container = lay.createDiv(); |
46 var container = layoutManager.createDiv(); |
46 |
47 |
47 var arr = IriSP.jQuery.extend({}, widget); |
48 var arr = IriSP.jQuery.extend({}, widget); |
48 arr.container = container; |
49 arr.container = container; |
49 |
50 |
50 var serializer = serialFactory.getSerializer(widget.metadata); |
51 var serializer = serialFactory.getSerializer(widget.metadata); |