SproutVideo/sproutvideo-player-api — pull request #2 by rk (2014-03-27 20:26:33+00:00)
Title: Added getPlaying() to track playing state, and some refactoring/cleanup

I don't know what your contributor policy or license is, but my employer needed an additional feature for a project. They generously permitted me to implement this on company time. Test it as you usually would, but this is already slated to hit production for us.

The only new functionality is the existence of a new `player.getPlaying()` method that returns true/false. I also updated the `updateStatus` method to track that state.

While I did that I noticed that several things were amiss. According to your [API docs][1] correct usage is to call `new SV.Player()` to create an instance, but the constructor was actually written for use without the `new` keyword. By returning an object from the constructor a weird duplicate would exist, to preserve state, but would never actually be accessible like the returned instance. So I rewrote the constructor to attach all privileged methods to the object.

// This creates 2 objects
function MyClass() {
return { method: function() {} };
}

// This doesn't
function MyClassier() {
this.method = function () {};
}

At the same time I made a few little updates to correct issues like implicit variable assignment, unnecessary use of `==` instead of `===`, and a little performance tweak. All basic things.

The diff makes it look horrendous, but a side-by-side comparison will show that most the code is still the way you wrote it. It's just that a structural change, and SublimeText eating all the trailing whitespace, tends to make diffs look ridiculous.

[1]: http://sproutvideo.com/help/api/javascript_player_api