|
123
|
1 |
/* init.js - initialization and configuration of Popcorn and the widgets |
|
|
2 |
exemple json configuration: |
|
|
3 |
|
|
|
4 |
var config = { |
|
|
5 |
gui:{ |
|
|
6 |
width:650, |
|
|
7 |
height:480, |
|
|
8 |
container:'LdtPlayer', |
|
|
9 |
css:'../../src/css/LdtPlayer.css', |
|
|
10 |
widgets: [ |
|
127
|
11 |
{type: "IriSP.PlayerWidget", // please note that type refers directly to the constructor of the widget. |
|
123
|
12 |
metadata:{ |
|
|
13 |
format:'cinelab', |
|
|
14 |
src:'test.json', |
|
|
15 |
load:'json'} |
|
|
16 |
}, |
|
127
|
17 |
{type: "IriSP.SegmentsWidget", |
|
123
|
18 |
metadata:{ |
|
|
19 |
format:'cinelab', |
|
|
20 |
src:'test.json', |
|
|
21 |
load:'json'} |
|
|
22 |
}, |
|
127
|
23 |
{type: "IriSP.AnnotationsWidget", |
|
123
|
24 |
metadata:{ |
|
|
25 |
format:'cinelab', |
|
|
26 |
src:'test.json', |
|
|
27 |
load:'json'} |
|
|
28 |
}, |
|
|
29 |
] |
|
|
30 |
player:{ |
|
|
31 |
type:'jwplayer', // player type |
|
127
|
32 |
container: '#PopcornContainer' |
|
123
|
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 |
*/ |
|
|
45 |
|
|
|
46 |
IriSP.configurePopcorn = function (options) { |
|
|
47 |
var pop; |
|
|
48 |
|
|
127
|
49 |
switch(options.type) { |
|
123
|
50 |
/* |
|
|
51 |
todo : dynamically create the div/video tag which |
|
|
52 |
will contain the video. |
|
|
53 |
*/ |
|
|
54 |
case "html5": |
|
127
|
55 |
pop = Popcorn(options.container); |
|
123
|
56 |
break; |
|
127
|
57 |
|
|
|
58 |
case "jwplayer": |
|
|
59 |
var opts = IriSP.jQuery.extend({}, options); |
|
|
60 |
delete opts.container; |
|
|
61 |
pop = Popcorn.jwplayer(options.container, "", opts); |
|
|
62 |
break; |
|
|
63 |
|
|
|
64 |
default: |
|
|
65 |
pop = undefined; |
|
123
|
66 |
}; |
|
|
67 |
|
|
127
|
68 |
return pop; |
|
123
|
69 |
}; |
|
|
70 |
|
|
127
|
71 |
IriSP.configureWidgets = function (popcornInstance, guiOptions) { |
|
123
|
72 |
|
|
127
|
73 |
var dt = new IriSP.DataLoader(); |
|
|
74 |
var serialFactory = new IriSP.SerializerFactory(dt); |
|
|
75 |
|
|
|
76 |
var params = {width: guiOptions.width, height: guiOptions.height}; |
|
|
77 |
var lay = new IriSP.LayoutManager(params); |
|
|
78 |
|
|
|
79 |
var ret_widgets = []; |
|
|
80 |
|
|
|
81 |
for (index in guiOptions.widgets) { |
|
|
82 |
var widget = guiOptions.widgets[index]; |
|
|
83 |
var container = lay.createDiv(); |
|
|
84 |
|
|
|
85 |
var arr = IriSP.jQuery.extend({}, widget); |
|
|
86 |
arr.container = container; |
|
123
|
87 |
|
|
127
|
88 |
var serializer = serialFactory.getSerializer(widget.metadata); |
|
|
89 |
|
|
|
90 |
// instantiate the object passed as a string |
|
|
91 |
var widget = new IriSP[widget.type](popcornInstance, widget, serializer); |
|
|
92 |
serializer.sync(function() { widget.draw() }); |
|
|
93 |
ret_widgets.push(widget); |
|
|
94 |
}; |
|
|
95 |
|
|
|
96 |
return ret_widgets; |
|
123
|
97 |
}; |