Skip to content

Commit

Permalink
if mp3 doesn't have content length header, make sure player duration …
Browse files Browse the repository at this point in the history
…isn't 'infinity'
  • Loading branch information
sjwilliams committed Apr 11, 2016
1 parent 1659dac commit f2c96f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions jabradoodle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @preserve jabradoodle - v0.0.8 - 2016-04-07
* @preserve jabradoodle - v0.0.9 - 2016-04-11
* jQuery Audio Button + 🐩
* http://sjwilliams.github.io/jabradoodle/
* Copyright (c) 2016 Josh Williams; Licensed MIT
Expand Down Expand Up @@ -231,11 +231,19 @@

_onTimeUpdate: function(){
var player = this;
var duration = player.audio.duration || player.settings.duration; // prefer more accurate duration info from player
var percentComplete;
var displayTime;
var width;

// prefer more accurate duration info from player. Fallback to user input if needed.
var duration = (function(){
var duration = player.audio.duration || player.settings.duration;

// Safari + no content length from server returns infinity intead of a number. Fallback if needd.
return isFinite(duration) ? duration : player.settings.duration;
})();


if (duration && duration >= 1) {

// move progress bar
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jabradoodle",
"version": "0.0.8",
"version": "0.0.9",
"description": "jQuery Audio Button + 🐩 that makes playing MP3s a walk in the dog park.",
"main": "jabradoodle.js",
"scripts": {
Expand Down

0 comments on commit f2c96f3

Please sign in to comment.