an image to player, first ideas to make a playback
This commit is contained in:
parent
fd255bad0a
commit
2a4dce3616
10 changed files with 192 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
var counter = 0;
|
||||
var Subscribable = require("../utils/subscribable");
|
||||
var Controller = require("./controller");
|
||||
|
||||
var LocalModel = Subscribable.inherit({
|
||||
"className": "LocalModel",
|
||||
|
@ -9,6 +10,7 @@ var LocalModel = Subscribable.inherit({
|
|||
|
||||
this.properties = [];
|
||||
this._controllers = [];
|
||||
this._foreignControllers = [];
|
||||
|
||||
if (properties) {
|
||||
for (var key in properties) {
|
||||
|
@ -25,6 +27,14 @@ var LocalModel = Subscribable.inherit({
|
|||
}
|
||||
},
|
||||
"destructor": function() {
|
||||
for (i = 0; i < this._foreignControllers.length; ++i) {
|
||||
var pair = this._foreignControllers[i];
|
||||
global.unsubscribeForeignController(pair.n, pair.c);
|
||||
global.registerForeignController(pair.n, pair.c);
|
||||
|
||||
pair.c.destructor();
|
||||
}
|
||||
|
||||
for (var i = 0; i < this._controllers.length; ++i) {
|
||||
this._controllers[i].destructor();
|
||||
}
|
||||
|
@ -34,6 +44,40 @@ var LocalModel = Subscribable.inherit({
|
|||
"addController": function(ctrl) {
|
||||
this._controllers.push(ctrl);
|
||||
},
|
||||
"addForeignController": function(nodeName, ctrl) {
|
||||
if (!(ctrl instanceof Controller)) {
|
||||
throw new Error("An attempt to add not a controller into " + this.className);
|
||||
}
|
||||
|
||||
this._foreignControllers.push({n: nodeName, c: ctrl});
|
||||
ctrl.on("serviceMessage", this._onControllerServiceMessage, this);
|
||||
|
||||
global.registerForeignController(nodeName, ctrl);
|
||||
global.subscribeForeignController(nodeName, ctrl);
|
||||
},
|
||||
"_onControllerServiceMessage": Controller.fn._onControllerServiceMessage,
|
||||
"removeForeignController": function(ctrl) {
|
||||
if (!(ctrl instanceof Controller)) {
|
||||
throw new Error("An attempt to remove not a controller from " + this.className);
|
||||
}
|
||||
for (var i = 0; i < this._foreignControllers.length; ++i) {
|
||||
if (this._foreignControllers[i].c === ctrl) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i === this._foreignControllers.length) {
|
||||
throw new Error("An attempt to remove not not existing controller from " + this.className);
|
||||
} else {
|
||||
var pair = this._foreignControllers[i];
|
||||
global.unsubscribeForeignController(pair.n, pair.c);
|
||||
global.registerForeignController(pair.n, pair.c);
|
||||
|
||||
pair.c.off("serviceMessage", this._onControllerServiceMessage, this);
|
||||
|
||||
this._foreignControllers.splice(i, 1);
|
||||
}
|
||||
},
|
||||
"setData": function(data) {
|
||||
this.data = data;
|
||||
this.initialized = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue