Skip to content

Commit

Permalink
Merge pull request #1 from zen-audio-player/master
Browse files Browse the repository at this point in the history
Merge 'master' from original repository
  • Loading branch information
avalan4e57 authored Jul 28, 2017
2 parents 9c8c9fb + bba3a61 commit bc83d6f
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions js/everything.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,14 @@ var ZenPlayer = {
});

plyrPlayer.addEventListener("playing", function() {
if (that.updated) {
var videoDuration = plyrPlayer.plyr.embed.getDuration();
if (that.updated || videoDuration === 0) {
return;
}

// Start video from where we left off, if it makes sense
if (window.sessionStorage && window.sessionStorage.hasOwnProperty(videoID)) {
var resumeTime = window.sessionStorage[videoID];
var videoDuration = plyrPlayer.plyr.embed.getDuration();
if (videoDuration === 0) {
return;
}
if (!isNaN(resumeTime) && resumeTime < videoDuration - 3) {
plyrPlayer.plyr.embed.seekTo(resumeTime);
}
Expand Down Expand Up @@ -223,13 +220,9 @@ var ZenPlayer = {
plyrPlayer.addEventListener("timeupdate", function() {
// Store the current time of the video.
var resumeTime = 0;
if (window.sessionStorage) {
var videoDuration = plyrPlayer.plyr.embed.getDuration();
if (window.sessionStorage && videoDuration > 0) {
var currentTime = plyrPlayer.plyr.embed.getCurrentTime();
var videoDuration = plyrPlayer.plyr.embed.getDuration();
if (videoDuration === 0) {
return;
}

// Only store the current time if the video isn't done
// playing yet. If the video finished already, then it
// should start off at the beginning next time.
Expand Down Expand Up @@ -618,7 +611,7 @@ $(function() {
$("#form").submit(function(event) {
event.preventDefault();
var formValue = $.trim($("#v").val());
var formValueTime = /&t=(\d*)$/g.exec(formValue);
var formValueTime = /[?&]t=(\d*)/g.exec(formValue);
if (formValueTime && formValueTime.length > 1) {
formValueTime = parseInt(formValueTime[1], 10);
formValue = formValue.replace(/&t=\d*$/g, "");
Expand Down

0 comments on commit bc83d6f

Please sign in to comment.