Skip to content

Commit

Permalink
plugins: add duration parameter handling to timeline plugin (katspaug…
Browse files Browse the repository at this point in the history
…h#1491)

* Add duration parameter handling to renderCanvases

* Add documentation for duration parameter

* Duration is optional parameter to override getDuration function
  • Loading branch information
mgoldsteinla authored and thijstriemstra committed Oct 16, 2018
1 parent 05d9cca commit b6e333c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/plugin/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* performance for large files
* @property {string} fontFamily='Arial'
* @property {number} fontSize=10 Font size of labels in pixels
* @property {?number} duration Length of the track in seconds. Overrides
* getDuration() for setting length of timeline
* @property {function} formatTimeCallback (sec, pxPerSec) -> label
* @property {function} timeInterval (pxPerSec) -> seconds between notches
* @property {function} primaryLabelInterval (pxPerSec) -> cadence between
Expand Down Expand Up @@ -139,6 +141,7 @@ export default class TimelinePlugin {
secondaryFontColor: '#000',
fontFamily: 'Arial',
fontSize: 10,
duration: null,
zoomDebounce: false,
formatTimeCallback: this.defaultFormatTimeCallback,
timeInterval: this.defaultTimeInterval,
Expand Down Expand Up @@ -321,7 +324,10 @@ export default class TimelinePlugin {
* @private
*/
renderCanvases() {
const duration = this.wavesurfer.backend.getDuration();
const duration =
this.wavesurfer.timeline.params.duration ||
this.wavesurfer.backend.getDuration();

if (duration <= 0) {
return;
}
Expand Down

0 comments on commit b6e333c

Please sign in to comment.