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 var config = { |
|
5 gui:{ |
|
6 width:650, |
|
7 height:480, |
|
8 container:'LdtPlayer', |
|
9 css:'../../src/css/LdtPlayer.css', |
|
10 widgets: [ |
|
11 {type: "IriSP.PlayerWidget", // please note that type refers directly to the constructor of the widget. |
|
12 metadata:{ |
|
13 format:'cinelab', |
|
14 src:'test.json', |
|
15 load:'json'} |
|
16 }, |
|
17 {type: "IriSP.SegmentsWidget", |
|
18 metadata:{ |
|
19 format:'cinelab', |
|
20 src:'test.json', |
|
21 load:'json'} |
|
22 }, |
|
23 {type: "IriSP.AnnotationsWidget", |
|
24 metadata:{ |
|
25 format:'cinelab', |
|
26 src:'test.json', |
|
27 load:'json'} |
|
28 }, |
|
29 ] |
|
30 player:{ |
|
31 type:'jwplayer', // player type |
|
32 container: '#PopcornContainer' |
|
33 // the rest is player-dependent configuration options. |
|
34 file : "video/franceculture/franceculture_retourdudimanche20100620.flv", |
|
35 streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", |
|
36 flashplayer : '../libs/player.swf', |
|
37 live: true, |
|
38 "controlbar.position" : "none", |
|
39 height: 300, |
|
40 width: 200, |
|
41 provider: "rtmp" |
|
42 } |
|
43 }; |
|
44 */ |
4 */ |
45 |
5 |
46 IriSP.configurePopcorn = function (options) { |
6 IriSP.configurePopcorn = function (options) { |
47 var pop; |
7 var pop; |
48 |
8 |
50 /* |
10 /* |
51 todo : dynamically create the div/video tag which |
11 todo : dynamically create the div/video tag which |
52 will contain the video. |
12 will contain the video. |
53 */ |
13 */ |
54 case "html5": |
14 case "html5": |
55 pop = Popcorn(options.container); |
15 pop = Popcorn("#" + options.container); |
56 break; |
16 break; |
57 |
17 |
58 case "jwplayer": |
18 case "jwplayer": |
59 var opts = IriSP.jQuery.extend({}, options); |
19 var opts = IriSP.jQuery.extend({}, options); |
60 delete opts.container; |
20 delete opts.container; |
61 pop = Popcorn.jwplayer(options.container, "", opts); |
21 pop = Popcorn.jwplayer("#" + options.container, "", opts); |
62 break; |
22 break; |
63 |
23 |
64 default: |
24 default: |
65 pop = undefined; |
25 pop = undefined; |
66 }; |
26 }; |
76 var params = {width: guiOptions.width, height: guiOptions.height}; |
36 var params = {width: guiOptions.width, height: guiOptions.height}; |
77 var lay = new IriSP.LayoutManager(params); |
37 var lay = new IriSP.LayoutManager(params); |
78 lay.setPopcornInstance(popcornInstance); |
38 lay.setPopcornInstance(popcornInstance); |
79 |
39 |
80 var ret_widgets = []; |
40 var ret_widgets = []; |
|
41 var index; |
81 |
42 |
82 for (index in guiOptions.widgets) { |
43 for (index = 0; index < guiOptions.widgets.length; index++) { |
83 var widget = guiOptions.widgets[index]; |
44 var widget = guiOptions.widgets[index]; |
84 var container = lay.createDiv(); |
45 var container = lay.createDiv(); |
85 |
46 |
86 var arr = IriSP.jQuery.extend({}, widget); |
47 var arr = IriSP.jQuery.extend({}, widget); |
87 arr.container = container; |
48 arr.container = container; |
|
49 |
|
50 var serializer = serialFactory.getSerializer(widget.metadata); |
|
51 |
|
52 // instantiate the object passed as a string |
|
53 var widget = new IriSP[widget.type](popcornInstance, arr, serializer); |
88 |
54 |
89 var serializer = serialFactory.getSerializer(widget.metadata); |
55 serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
90 |
|
91 // instantiate the object passed as a string |
|
92 var widget = new IriSP[widget.type](popcornInstance, arr, serializer); |
|
93 serializer.sync(function() { widget.draw() }); |
|
94 ret_widgets.push(widget); |
56 ret_widgets.push(widget); |
|
57 |
95 }; |
58 }; |
96 |
59 |
97 return ret_widgets; |
60 return ret_widgets; |
98 }; |
61 }; |