jetgrizzly/jetgrizzly — pull request #100 by jjmerino (2014-10-27 01:08:02+00:00)
Title: Merge server logic and refactor client logic 

The client logic for the youtube player is now separated into three parts:

- The youtube directive which reads data, does not know anything about firebase, it communicates with the playerState service to get the expected state of the player.
- The playerState factory, which connects to firebase and keeps the playback logic.
- The youtube API service. Which wraps the youtube API so that the rest of the app doesn't have to deal with its initialisation. Now you can just inject the service and start using it (it;s a promise). The fact that it returns a promise means that you can add it to the resolve of a Ui-route very easily.

The server logic now assumes that he is the only one with write access to the currentVideo ref.
The server will use timeouts and the video duration to determine when to check if a new video must be loaded into the currentVideoref.

As soon as the currentVideo ref is updated by the server, the clients will be notified and act accordingly.