More Butter Hacking

It's been difficult to be very productive over the past few days thanks to the network trouble we're experiencing at CDOT.  When I left on Friday I couldn't pull or push changes to GitHub and I was only able to get a stable connection to Moznet using Mibbit.

I did some work on a ticket for butter that was related to the scrubber.  "Scrubber" - an odd term, but for those who are as confused as I was initially, the scrubber in butter.js is the thin red line overlaying the butter time line that is used to visualize the target media's "currentTime" value.

The problem was that if the media element was playing, and the scrubber was grabbed using the mouse by the user, the media would continue to play.  For example, if I clicked the scrubber and held it in one position, the media would continue playback but the scrubber's position would remain the same.

The solution to this was simple, and one line:

!$ && $;
This would pause the video only if the left side evaluates to true.  This was all cool, but It didn't feel right to have the video stay paused after the scrubber is released if the video was playing to begin with. My expected behaviour would be that it should continue playback after you release the scrubber (ONLY if the video was originally playing when the scrubber is picked up) this is what the solution looked like:

(function() {

  //original playing state of the video
var wasPaused = false;

axis: "x",
containment: "#ui-track-editting",
grid: [ increment / 8, 0 ],
start: function() {
TrackEditor.isScrubbing = true;

      //added this if block
if ( !$ ) {
wasPaused = true;
stop: function() {
TrackEditor.isScrubbing = false;

      //added this if block
      if (wasPaused) {
wasPaused = false;
drag: function( event, ui ) {

      //if dragging and the video is playing for some reason, pause it.
      !$ && $;
var scrubPosition = ui.position.left - $tracktimecanvas.position().left,
updateTo = $ / $tracktimecanvas.innerWidth() * scrubPosition,
quarterTime = _( updateTo ).fourth();

$ = quarterTime;

This is up for SR now on lighthouse.

I'm gonna work on Popcorn today while I wait for Scott's new track management library.