Skip to content

Commit b117bad

Browse files
Daniel Warecarles-vancast
authored andcommitted
fix: do not override player when start offset is not defined
When start offset option is not defined, call original currentTime and duration methods. closes #40
1 parent e628786 commit b117bad

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/plugin.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,29 @@ const offset = function(options) {
8484
};
8585

8686
Player.prototype.duration = function() {
87-
if (this._offsetEnd > 0) {
88-
return this._offsetEnd - this._offsetStart;
87+
if (this._offsetEnd !== undefined && this._offsetStart !== undefined) {
88+
if (this._offsetEnd > 0) {
89+
return this._offsetEnd - this._offsetStart;
90+
}
91+
return Player.__super__.duration.apply(this, arguments) - this._offsetStart;
8992
}
90-
return Player.__super__.duration.apply(this, arguments) - this._offsetStart;
93+
return Player.__super__.duration.apply(this, arguments);
9194
};
9295

9396
Player.prototype.currentTime = function(seconds) {
9497
if (seconds !== undefined) {
95-
return Player.__super__.currentTime
96-
.call(this, seconds + this._offsetStart);
98+
if (this._offsetStart !== undefined) {
99+
return Player.__super__.currentTime
100+
.call(this, seconds + this._offsetStart);
101+
}
102+
return Player.__super__.currentTime.call(this, seconds);
97103
}
98104

99-
return Player.__super__.currentTime
100-
.apply(this) - this._offsetStart;
105+
if (this._offsetStart !== undefined) {
106+
return Player.__super__.currentTime
107+
.apply(this) - this._offsetStart;
108+
}
109+
return Player.__super__.currentTime.apply(this);
101110
};
102111

103112
Player.prototype.remainingTime = function() {

0 commit comments

Comments
 (0)