Animatron/player — pull request #116 by shamansir (2013-09-16 19:21:04+00:00)
Title: Player START/STOP/PAUSE/... events in addition to band START/STOP events

It is now possible for any Element to subscribe also to all of player-state changing events, such as `C.S_PLAY`, `C.S_PAUSE`, `C.S_STOP` etc.

Example code:

```
function wrapWithLogging(prefix, _elm) {
_elm.whenPlayer(C.S_STOP, function(player) { console.log(prefix, 'STOP', player.state.time, player); })
.whenPlayer(C.S_PLAY, function(player) { console.log(prefix, 'PLAY', player.state.time, player); })
.whenPlayer(C.S_PAUSE, function(player) { console.log(prefix, 'PAUSE', player.state.time, player); })
.whenPlayer(C.S_LOAD, function(player) { console.log(prefix, 'LOAD1', player.state.time, player); })
.whenPlayer(C.S_LOAD, function(player) { console.log(prefix, 'LOAD2', player.state.time, player); })
.whenPlayer(C.S_REPEAT, function(player) { console.log(prefix, 'REPEAT', player.state.time, player); })
.whenPlayer(C.S_ERROR, function(player) { console.log(prefix, 'ERROR', player.state.time, player); })
.onstart(function(t, duration) { console.log(prefix, 'start', t, duration, t/duration); })
.onstop(function(t, duration) { console.log(prefix, 'stop', t, duration, t/duration); })
return _elm;
}

return wrapWithLogging('scene',
b().add(wrapWithLogging('2-10', b().band([2, 10])))
.add(wrapWithLogging('0-10', b().band([0, 10])))
.add(wrapWithLogging('3-7', b().band([3, 7])))
.add(wrapWithLogging('3-Inf', b().band([3, Infinity])))
.add(wrapWithLogging('(-3)-6', b().band([-3, 6])))
.add(wrapWithLogging('(-3)-Inf', b().band([-3, Infinity])))
.add(wrapWithLogging('11-12', b().band([11, 12]))));
```

Also, the single frame will not fire `X_START / X_STOP` (band start/stop) events anymore.

**NB:** `X_STOP` (band stop) event is (for the moment) not guaranteed to be called if the band of an element ends at the same global time as the scene end-time, but it is possible to handle `S_STOP` (player stop) now, in this case.

Not perfectly tested, may fail with complex structures — issues, fixes and improvements to come....