made a small change to the way popcorn is integrated into the page.
--- a/src/js/init.js Thu Oct 27 11:22:49 2011 +0200
+++ b/src/js/init.js Thu Oct 27 13:36:49 2011 +0200
@@ -3,8 +3,9 @@
*/
-IriSP.configurePopcorn = function (options) {
+IriSP.configurePopcorn = function (layoutManager, options) {
var pop;
+ var containerDiv = layoutManager.createDiv();
switch(options.type) {
/*
@@ -12,13 +13,15 @@
will contain the video.
*/
case "html5":
- pop = Popcorn("#" + options.container);
+ var tmpId = Popcorn.guid("video");
+ IriSP.jQuery("#" + containerDiv).append("<video src='" + options.file + "' id='" + tmpId + "'></video>");
+ pop = Popcorn("#" + tmpId);
break;
case "jwplayer":
var opts = IriSP.jQuery.extend({}, options);
delete opts.container;
- pop = Popcorn.jwplayer("#" + options.container, "", opts);
+ pop = Popcorn.jwplayer("#" + containerDiv, "", opts);
break;
default:
@@ -28,21 +31,19 @@
return pop;
};
-IriSP.configureWidgets = function (popcornInstance, guiOptions) {
+IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) {
var dt = new IriSP.DataLoader();
var serialFactory = new IriSP.SerializerFactory(dt);
var params = {width: guiOptions.width, height: guiOptions.height};
- var lay = new IriSP.LayoutManager(params);
- lay.setPopcornInstance(popcornInstance);
-
+
var ret_widgets = [];
var index;
for (index = 0; index < guiOptions.widgets.length; index++) {
var widget = guiOptions.widgets[index];
- var container = lay.createDiv();
+ var container = layoutManager.createDiv();
var arr = IriSP.jQuery.extend({}, widget);
arr.container = container;
--- a/test/integration/init-radio.htm Thu Oct 27 11:22:49 2011 +0200
+++ b/test/integration/init-radio.htm Thu Oct 27 13:36:49 2011 +0200
@@ -71,8 +71,11 @@
};
IriSP.loadLibs(IriSP.lib, config.gui.css,
- function() { var pop = IriSP.configurePopcorn(config.player);
- var widgets = IriSP.configureWidgets(pop, config.gui); });
+ function() {
+ var layoutManager = new IriSP.LayoutManager(config.gui.container);
+ var pop = IriSP.configurePopcorn(layoutManager, config.player);
+
+ var widgets = IriSP.configureWidgets(pop, layoutManager, config.gui); });
});
</script>
--- a/unittests/tests/init.js Thu Oct 27 11:22:49 2011 +0200
+++ b/unittests/tests/init.js Thu Oct 27 13:36:49 2011 +0200
@@ -4,7 +4,7 @@
setup: function() {
IriSP.jQuery("#widget-div").append("<div id='LdtPlayer'></div>");
this.popcornOptions = {
- container: "widget-div",
+ container: "LdtPlayer",
type: "jwplayer", file : "video/franceculture/franceculture_retourdudimanche20100620.flv",
streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/",
flashplayer : '../libs/player.swf',
@@ -46,17 +46,35 @@
test("test the creation of a correct popcorn object", function() {
-
- var pop = IriSP.configurePopcorn(this.popcornOptions);
+ var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
+ var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
notDeepEqual(pop, undefined, "returned object is not undefined");
/* FIXME: add more test options ? */
equal(pop.options.type, "jwplayer", "the player is of the correct type.");
});
+ test("test the creation of a video tag", function() {
+
+ var popcornOptions = {
+ type: "html5",
+ file: "demo.mp4"
+ };
+
+ var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
+ var pop = IriSP.configurePopcorn(layoutManager, popcornOptions);
+
+ var elem = IriSP.jQuery("#LdtPlayer").find("video");
+ notDeepEqual(elem, [], "the element is not null");
+ equal(elem.attr("src"), popcornOptions.file, "the src attribute is set correctly");
+ });
+
test("test the instantiation of a bunch of widgets", function() {
- var pop = IriSP.configurePopcorn(this.popcornOptions);
- var widgets = IriSP.configureWidgets(pop, this.widgetOptions);
+
+ var layoutManager = new IriSP.LayoutManager({container: "LdtPlayer", width: 327, height: 542});
+ var pop = IriSP.configurePopcorn(layoutManager, this.popcornOptions);
+
+ var widgets = IriSP.configureWidgets(pop, layoutManager, this.widgetOptions);
ok(widgets[0] instanceof IriSP.PlayerWidget, "first widget is a player widget");
ok(widgets[1] instanceof IriSP.SegmentsWidget, "second widget is a segments widget");