| author | hamidouk |
| Tue, 25 Oct 2011 10:30:33 +0200 | |
| branch | popcorn-port |
| changeset 136 | 9c2e80e4f1b5 |
| parent 129 | 296d9ddf9cc1 |
| child 141 | becd5f52fa24 |
| permissions | -rw-r--r-- |
| 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); |
|
|
136
9c2e80e4f1b5
oneliner to specify the popcorn instance to the layout manager.
hamidouk
parents:
129
diff
changeset
|
78 |
lay.setPopcornInstance(popcornInstance); |
| 127 | 79 |
|
80 |
var ret_widgets = []; |
|
81 |
|
|
82 |
for (index in guiOptions.widgets) { |
|
83 |
var widget = guiOptions.widgets[index]; |
|
84 |
var container = lay.createDiv(); |
|
85 |
|
|
86 |
var arr = IriSP.jQuery.extend({}, widget); |
|
87 |
arr.container = container; |
|
| 123 | 88 |
|
| 129 | 89 |
var serializer = serialFactory.getSerializer(widget.metadata); |
90 |
|
|
| 127 | 91 |
// instantiate the object passed as a string |
| 129 | 92 |
var widget = new IriSP[widget.type](popcornInstance, arr, serializer); |
| 127 | 93 |
serializer.sync(function() { widget.draw() }); |
94 |
ret_widgets.push(widget); |
|
95 |
}; |
|
96 |
|
|
97 |
return ret_widgets; |
|
| 123 | 98 |
}; |