Skip to content

Commit

Permalink
timer update
Browse files Browse the repository at this point in the history
  • Loading branch information
thijstriemstra committed Mar 18, 2014
1 parent e5a7395 commit 5d07ae0
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions videojs.wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
});
}

// hide fullscreen control until it's supported by
// hide fullscreen control until it's easier to implement with
// wavesurfer.js
this.player().controlBar.fullscreenToggle.hide();
this.player().controlBar.volumeControl.el().style.marginRight = '15px';
Expand All @@ -63,6 +63,7 @@
this.surfer = Object.create(WaveSurfer);
this.surfer.on('ready', this.onWaveReady.bind(this));
this.surfer.on('error', this.onWaveError.bind(this));
this.surfer.on('finish', this.onWaveFinish.bind(this));
this.surfer.on('progress', this.onWaveProgress.bind(this));
this.surfer.on('seek', this.onWaveSeek.bind(this));

Expand All @@ -71,7 +72,6 @@
this.player().on('play', this.onPlay.bind(this));
this.player().on('pause', this.onPause.bind(this));
this.player().on('volumechange', this.onVolumeChange.bind(this));
this.player().on('timeupdate', this.onTimeUpdate.bind(this));
},

/**
Expand Down Expand Up @@ -143,7 +143,7 @@
},

/**
* Updates the current time.
* Updates the player's current time.
*/
setCurrentTime: function()
{
Expand Down Expand Up @@ -196,38 +196,38 @@
},

/**
* Fires continuously during audio playback.
*
* @param percent: Percentage played so far.
*/
onWaveProgress: function(percent)
onWaveFinish: function()
{
// completed playback
if (percent >= 1)
// check if player isn't paused already
if (!this.player().paused())
{
// check if player isn't paused already
if (!this.player().paused())
// check if loop is enabled
if (this.player().options().loop)
{
// check if loop is enabled
if (this.player().options().loop)
{
// stop and play
this.surfer.stop();
this.play();
}
else
{
// pause player
this.player().pause();
}
// reset waveform
this.surfer.stop();
this.play();
}
else
{
// pause player
this.player().pause();
}
}
else
{
this.setCurrentTime();
}
},

/**
* Fires continuously during audio playback.
*
* @param percent: Percentage played so far.
*/
onWaveProgress: function(percent)
{
this.setCurrentTime();
},

/**
* Fires during seeking of the waveform.
*/
Expand Down Expand Up @@ -288,14 +288,6 @@
this.setVolume(volume);
},

/**
* Fired when the current playback position has changed.
*/
onTimeUpdate: function()
{
this.setCurrentTime();
},

/**
* Waveform error.
*/
Expand Down

0 comments on commit 5d07ae0

Please sign in to comment.