Skip to content

Commit

Permalink
Predictive caching does not assume mp3 is an available format. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
peichins committed May 1, 2018
1 parent 8969fc0 commit 52eb00b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/predictiveCacheDefaultProfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ angular.module("bawApp.predictiveCacheDefaultProfiles", [])
"predictiveCacheDefaultProfiles", {
"Media cache ahead": function bind($location, paths) {
const imageFormat = "png";
const audioFormat = "mp3";
// Not all audio formats are always available. We cache the format that is most
// likely to be used by the browser, which should be in the following order
const audioFormatPriority = ["mp3","webm","ogg", "flac", "wav"];
// request additional bits of media based the duration of the original request
// do not make requests that would exceed the end of the recording
function mediaProgressor(previous, data) {
Expand Down Expand Up @@ -45,8 +47,10 @@ angular.module("bawApp.predictiveCacheDefaultProfiles", [])
function (counters, data) {
return formatMediaUrl(data.responseData.data.available.image[imageFormat].url, counters);
},
// mp3
// audio, e.g. mp3
function (counters, data) {
// audio format will be the first item in audioFormatPriority that appears in the data's available audio
var audioFormat = audioFormatPriority.find(format => data.responseData.data.available.audio.hasOwnProperty(format));
return formatMediaUrl(data.responseData.data.available.audio[audioFormat].url, counters);
}
],
Expand Down

0 comments on commit 52eb00b

Please sign in to comment.