Skip to content

Instantly share code, notes, and snippets.

@apeschar
Created August 15, 2011 07:44
Show Gist options
  • Save apeschar/1145866 to your computer and use it in GitHub Desktop.
Save apeschar/1145866 to your computer and use it in GitHub Desktop.
Patch for Flowplayer controls r1673
Index: src/actionscript/org/flowplayer/controls/config/Config.as
===================================================================
--- src/actionscript/org/flowplayer/controls/config/Config.as (revision 1673)
+++ src/actionscript/org/flowplayer/controls/config/Config.as (working copy)
@@ -177,6 +177,8 @@
config.setHeightRatio(_style['timeBgHeightRatio']);
config.setSeparator(_style['timeSeparator'] || "/");
config.setTimeColor(_style['timeColor']);
+ config.setShowDuration(_style['showDuration'] === undefined ? true : _style['showDuration']);
+ config.setShowRemainingTime(_style['showRemainingTime'] || false);
return config;
}
Index: src/actionscript/org/flowplayer/controls/time/TimeViewController.as
===================================================================
--- src/actionscript/org/flowplayer/controls/time/TimeViewController.as (revision 1673)
+++ src/actionscript/org/flowplayer/controls/time/TimeViewController.as (working copy)
@@ -65,7 +65,11 @@
var duration:Number = status.clip ? status.clip.duration : 0;
(_widget as TimeView).duration = status.clip.live && duration == 0 ? -1 : duration;
- (_widget as TimeView).time = _durationReached ? duration : status.time;
+
+ if((_config as TimeViewConfig).showRemainingTime)
+ (_widget as TimeView).time = _durationReached ? 0 : 0-(duration-status.time);
+ else
+ (_widget as TimeView).time = _durationReached ? duration : status.time;
}
override protected function addPlayerListeners():void {
Index: src/actionscript/org/flowplayer/controls/time/TimeViewConfig.as
===================================================================
--- src/actionscript/org/flowplayer/controls/time/TimeViewConfig.as (revision 1673)
+++ src/actionscript/org/flowplayer/controls/time/TimeViewConfig.as (working copy)
@@ -19,6 +19,8 @@
private var _fontSize:Number = 14;
private var _separator:String = "/";
private var _timeColor:String;
+ private var _showDuration:Boolean = true;
+ private var _showRemainingTime:Boolean = false;
/*
@@ -78,5 +80,29 @@
_timeColor = color;
}
+ /*
+ * Duration Display
+ */
+
+ public function get showDuration():Boolean {
+ return _showDuration;
+ }
+
+ public function setShowDuration(value:Boolean):void {
+ _showDuration = value;
+ }
+
+ /*
+ * Remaining Time Display
+ */
+
+ public function get showRemainingTime():Boolean {
+ return _showRemainingTime;
+ }
+
+ public function setShowRemainingTime(value:Boolean):void {
+ _showRemainingTime = value;
+ }
+
}
}
\ No newline at end of file
Index: src/actionscript/org/flowplayer/controls/time/TimeView.as
===================================================================
--- src/actionscript/org/flowplayer/controls/time/TimeView.as (revision 1673)
+++ src/actionscript/org/flowplayer/controls/time/TimeView.as (working copy)
@@ -42,7 +42,9 @@
_config = config;
_player = player;
createTimeText();
- createDurationText();
+ if(_config.showDuration) {
+ createDurationText();
+ }
duration = 0;
@@ -73,7 +75,14 @@
override public function set enabled(value:Boolean):void { };
public function set time(value:Number):void {
- _timeText.text = TimeUtil.formatSeconds(value);
+ // TimeUtil.formatSeconds doesn't handle negative input
+ var negative:Number = value < 0 ? -1 : 1;
+ var text:String = (negative == -1 ? '-' : '') + TimeUtil.formatSeconds(negative * value);
+ if(_config.showRemainingTime && text == '00:00') {
+ text = '-00:00';
+ }
+ _timeText.text = text;
+
if (_durationText) {
_timeText.appendText(_config.separator);
}
@@ -92,7 +101,7 @@
onResize();
dispatchEvent(new Event(EVENT_REARRANGE));
return;
- } else if (value > 0 && ! _durationText) {
+ } else if (value > 0 && ! _durationText && _config.showDuration) {
createDurationText();
onResize();
dispatchEvent(new Event(EVENT_REARRANGE));
@@ -111,7 +120,9 @@
fontSize = _config.fontSize ? _config.fontSize : fontSize;
- initField(_durationText, _config.durationColor, _config.durationAlpha, fontSize);
+ if(_durationText) {
+ initField(_durationText, _config.durationColor, _config.durationAlpha, fontSize);
+ }
initField(_timeText, _config.timeColor, _config.timeAlpha, fontSize);
onResize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment