Permalink
Browse files

videoanno current - onNewPlayer is now an event firer

  • Loading branch information...
jgsmith committed May 16, 2012
1 parent 5c1d88f commit 74cce569e7ff2ee92ce4ab891d344fc841718ea5
Showing with 21 additions and 38 deletions.
  1. +13 −15 demo.html
  2. +7 −22 dist/videoanno.js
  3. +1 −1 dist/videoanno.min.js
View
@@ -21,21 +21,19 @@ <h3 class="demo-box-title active">Open Annotation Code</h3>
</div>
<script type="text/javascript">//<!--
-$(document).ready(function() {
- OAC.Client.StreamingVideo.Player.onNewPlayer(function(playerobj) {
- /*
- * We begin by creating an instance of the Video Annotator application.
- * This requires the player object passed in by the onNewPlayer function above.
- */
- var app = OAC.Client.StreamingVideo.Demo.Application.initInstance({
- player: playerobj
- });
-
- /*
- * Running the application causes all of the DOM elements, presentations, and other components to be
- * instantiated.
- */
- app.run();
+OAC.Client.StreamingVideo.Player.onNewPlayer.addListener(function(playerobj) {
+ /*
+ * We begin by creating an instance of the Video Annotator application.
+ * This requires the player object passed in by the onNewPlayer function above.
+ */
+ var app = OAC.Client.StreamingVideo.Demo.Application.initInstance({
+ player: playerobj
});
+
+ /*
+ * Running the application causes all of the DOM elements, presentations, and other components to be
+ * instantiated.
+ */
+ app.run();
});
// --></script>
View
@@ -231,47 +231,32 @@
});
});
OAC.Client.StreamingVideo.namespace("Player", function(exports) {
- var callbacks, driverCallbacks, players;
+ var driverCallbacks, players;
players = [];
- callbacks = [];
exports.player = function(playerId) {
if (!(playerId != null)) playerId = 0;
return players[playerId];
};
- exports.onNewPlayer = function(callback) {
- var player, _i, _len;
- for (_i = 0, _len = players.length; _i < _len; _i++) {
- player = players[_i];
- callback(player);
- }
- return callbacks.push(callback);
- };
+ exports.onNewPlayer = MITHGrid.initEventFirer(false, false, true);
driverCallbacks = [];
+ exports.onNewPlayer.addListener(function(p) {
+ return players.push(p);
+ });
exports.register = function(driverObjectCB) {
return driverCallbacks.push(driverObjectCB);
};
$(document).ready(function() {
var cb, _i, _len, _results;
exports.register = function(driverObjectCB) {
- var cb, driverObject, p, player, ps, _i, _len, _results;
+ var driverObject, player, ps, _i, _len, _results;
driverObject = {};
driverObjectCB(driverObject);
ps = driverObject.getAvailablePlayers();
_results = [];
for (_i = 0, _len = ps.length; _i < _len; _i++) {
player = ps[_i];
$(player).data('driver', driverObject);
- p = driverObject.bindPlayer(player);
- players.push(p);
- _results.push((function() {
- var _j, _len2, _results2;
- _results2 = [];
- for (_j = 0, _len2 = callbacks.length; _j < _len2; _j++) {
- cb = callbacks[_j];
- _results2.push(cb.call({}, p));
- }
- return _results2;
- })());
+ _results.push(exports.onNewPlayer.fire(driverObject.bindPlayer(player)));
}
return _results;
};
Oops, something went wrong.

0 comments on commit 74cce56

Please sign in to comment.