| author | hamidouk |
| Thu, 27 Oct 2011 13:36:49 +0200 | |
| branch | popcorn-port |
| changeset 158 | 1813e6e4f0d6 |
| parent 141 | becd5f52fa24 |
| child 171 | 158f0193ec54 |
| permissions | -rw-r--r-- |
| 123 | 1 |
/* init.js - initialization and configuration of Popcorn and the widgets |
2 |
exemple json configuration: |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
3 |
|
| 123 | 4 |
*/ |
5 |
||
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
6 |
IriSP.configurePopcorn = function (layoutManager, options) { |
| 123 | 7 |
var pop; |
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
8 |
var containerDiv = layoutManager.createDiv(); |
| 123 | 9 |
|
| 127 | 10 |
switch(options.type) { |
| 123 | 11 |
/* |
12 |
todo : dynamically create the div/video tag which |
|
13 |
will contain the video. |
|
14 |
*/ |
|
15 |
case "html5": |
|
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
16 |
var tmpId = Popcorn.guid("video"); |
|
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
17 |
IriSP.jQuery("#" + containerDiv).append("<video src='" + options.file + "' id='" + tmpId + "'></video>"); |
|
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
18 |
pop = Popcorn("#" + tmpId); |
| 123 | 19 |
break; |
| 127 | 20 |
|
21 |
case "jwplayer": |
|
22 |
var opts = IriSP.jQuery.extend({}, options); |
|
23 |
delete opts.container; |
|
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
24 |
pop = Popcorn.jwplayer("#" + containerDiv, "", opts); |
| 127 | 25 |
break; |
26 |
|
|
27 |
default: |
|
28 |
pop = undefined; |
|
| 123 | 29 |
}; |
30 |
|
|
| 127 | 31 |
return pop; |
| 123 | 32 |
}; |
33 |
||
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
34 |
IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) { |
| 123 | 35 |
|
| 127 | 36 |
var dt = new IriSP.DataLoader(); |
37 |
var serialFactory = new IriSP.SerializerFactory(dt); |
|
38 |
|
|
39 |
var params = {width: guiOptions.width, height: guiOptions.height}; |
|
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
40 |
|
| 127 | 41 |
var ret_widgets = []; |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
42 |
var index; |
| 127 | 43 |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
44 |
for (index = 0; index < guiOptions.widgets.length; index++) { |
| 127 | 45 |
var widget = guiOptions.widgets[index]; |
|
158
1813e6e4f0d6
made a small change to the way popcorn is integrated into the page.
hamidouk
parents:
141
diff
changeset
|
46 |
var container = layoutManager.createDiv(); |
| 127 | 47 |
|
48 |
var arr = IriSP.jQuery.extend({}, widget); |
|
49 |
arr.container = container; |
|
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
50 |
|
| 129 | 51 |
var serializer = serialFactory.getSerializer(widget.metadata); |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
52 |
|
| 127 | 53 |
// instantiate the object passed as a string |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
54 |
var widget = new IriSP[widget.type](popcornInstance, arr, serializer); |
|
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
55 |
|
|
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
56 |
serializer.sync(IriSP.wrap(widget, function() { this.draw(); })); |
| 127 | 57 |
ret_widgets.push(widget); |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
58 |
|
| 127 | 59 |
}; |
|
141
becd5f52fa24
this commit fixes an elusive integration bug where the object would get called
hamidouk
parents:
136
diff
changeset
|
60 |
|
| 127 | 61 |
return ret_widgets; |
| 123 | 62 |
}; |