File tree Expand file tree Collapse file tree 2 files changed +22
-18
lines changed
Expand file tree Collapse file tree 2 files changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -94,22 +94,13 @@ const offset = function(options) {
9494 return Player . __super__ . currentTime
9595 . call ( this , seconds + this . _offsetStart ) ;
9696 }
97- const curr = Player . __super__ . currentTime
98- . apply ( this ) ;
9997
100- if ( curr > this . _offsetStart ) {
101- return curr - this . _offsetStart ;
102- }
103- return 0 ;
98+ return Player . __super__ . currentTime
99+ . apply ( this ) - this . _offsetStart ;
104100 } ;
105101
106102 Player . prototype . remainingTime = function ( ) {
107- let curr = this . currentTime ( ) ;
108-
109- if ( curr < this . _offsetStart ) {
110- curr = 0 ;
111- }
112- return this . duration ( ) - curr ;
103+ return this . duration ( ) - this . currentTime ( ) ;
113104 } ;
114105
115106 Player . prototype . startOffset = function ( ) {
Original file line number Diff line number Diff line change @@ -60,14 +60,27 @@ QUnit.test('registers itself with video.js', function(assert) {
6060 ) ;
6161} ) ;
6262
63- QUnit . test ( 'configure start and end as as strings ' , function ( assert ) {
64- assert . expect ( 2 ) ;
63+ QUnit . test ( 'remaining time ' , function ( assert ) {
64+ assert . expect ( 1 ) ;
6565
66- assert . strictEqual (
67- typeof Player . prototype . offset ,
68- 'function' ,
69- 'videojs-offset plugin was registered'
66+ this . player . offset ( {
67+ start : 10 ,
68+ end : 300
69+ } ) ;
70+
71+ // Tick the clock forward enough to trigger the player to be "ready".
72+ this . clock . tick ( 1 ) ;
73+
74+ this . player . currentTime ( 2 ) ;
75+
76+ assert . ok (
77+ this . player . remainingTime ( ) === 288 ,
78+ 'the plugin alters remaining time'
7079 ) ;
80+ } ) ;
81+
82+ QUnit . test ( 'configure start and end as as strings' , function ( assert ) {
83+ assert . expect ( 1 ) ;
7184
7285 this . player . offset ( {
7386 start : '10.5' ,
You can’t perform that action at this time.
0 commit comments