Skip to content

Commit

Permalink
Added HTML Variable Preload Attribute (katspaugh#847)
Browse files Browse the repository at this point in the history
* Added HTML Variable Preload Attribute

Added a way to define the the preload attribute of the HTML5 audio markup.
'Metadata' and 'None' saves bandwidth, especially if there is multiple players on the page.
'Metadata' allows to have track length.
Default is left to 'auto' to avoid unexpected change for wavesurfer users.
Note that this attribute interpretation may be different on different browsers.

* Media Element Preload Compact syntax

* Added param doc
  • Loading branch information
X-Raym authored and katspaugh committed Oct 30, 2016
1 parent e752b18 commit b19bdd5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/mediaelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ WaveSurfer.util.extend(WaveSurfer.MediaElement, {
* @param {String} url path to media file
* @param {HTMLElement} container HTML element
* @param {Array} peaks array of peak data
* @param {String} preload HTML 5 preload attribute value
*/
load: function (url, container, peaks) {
load: function (url, container, peaks, preload) {
var my = this;

var media = document.createElement(this.mediaType);
media.controls = this.params.mediaControls;
media.autoplay = this.params.autoplay || false;
media.preload = 'auto';
media.preload = preload == null ? 'auto' : preload;
media.src = url;
media.style.width = '100%';

Expand Down

0 comments on commit b19bdd5

Please sign in to comment.