New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wavesurfer.js

Package Overview
Dependencies
Maintainers
1
Versions
303
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wavesurfer.js - npm Package Compare versions

Comparing version

to
1.0.17

.tern-port

2

bower.json
{
"name" : "wavesurfer.js",
"version" : "1.0.16",
"version" : "1.0.17",
"homepage" : "https://github.com/katspaugh/wavesurfer.js",

@@ -5,0 +5,0 @@ "main" : "build/wavesurfer.min.js",

{
"name": "wavesurfer.js",
"version": "1.0.16",
"version": "1.0.17",
"description": "Interactive navigable audio visualization using Web Audio and Canvas",

@@ -5,0 +5,0 @@ "main": "build/wavesurfer.cjs.js",

@@ -151,3 +151,2 @@ 'use strict';

this.style(regionEl, {
cursor: 'move',
position: 'absolute',

@@ -187,3 +186,3 @@ zIndex: 2,

formatTime: function (start, end) {
return (end ? [ start, end ] : [ start ]).map(function (time) {
return (start == end ? [ start ] : [ start, end ]).map(function (time) {
return [

@@ -201,4 +200,2 @@ Math.floor((time % 3600) / 60), // minutes

var width = fillParentNoScroll ? this.wavesurfer.drawer.getWidth() : this.wrapper.scrollWidth;
var width = this.wrapper.scrollWidth;
var seconds = this.end - this.start;

@@ -216,3 +213,4 @@ if (this.start < 0) {

width: ~~((this.end / dur - this.start / dur) * width) + 'px',
backgroundColor: this.color
backgroundColor: this.color,
cursor: this.drag ? 'move' : 'default'
});

@@ -219,0 +217,0 @@ this.element.title = this.formatTime(this.start, this.end);

@@ -117,2 +117,3 @@ 'use strict';

// we'll limit the "re-center" rate.
// we'll limit the "re-center" rate.
var rate = 5;

@@ -172,4 +173,6 @@ offset = Math.max(-rate, Math.min(rate, offset));

this.unAll();
this.container.removeChild(this.wrapper);
this.wrapper = null;
if (this.wrapper) {
this.container.removeChild(this.wrapper);
this.wrapper = null;
}
},

@@ -176,0 +179,0 @@

@@ -21,3 +21,2 @@ 'use strict';

this.ac = params.audioContext || this.getAudioContext();

@@ -60,2 +59,3 @@ this.elementPosition = params.elementPosition;

this.peaks = peaks;
this.onPlayEnd = null;
this.setPlaybackRate(this.playbackRate);

@@ -96,2 +96,3 @@ },

}
this.clearPlayEnd();
},

@@ -104,6 +105,9 @@

* relative to the beginning of a clip.
* @param {Number} end End offset in seconds,
* relative to the beginning of a clip.
*/
play: function (start) {
play: function (start, end) {
this.seekTo(start);
this.media.play();
end && this.setPlayEnd(end);
},

@@ -116,4 +120,23 @@

this.media.pause();
this.clearPlayEnd();
},
setPlayEnd: function (end) {
var my = this;
this.onPlayEnd = function (time) {
if (time >= end) {
my.pause();
my.seekTo(end);
}
};
this.on('audioprocess', this.onPlayEnd);
},
clearPlayEnd: function () {
if (this.onPlayEnd) {
this.un('audioprocess', this.onPlayEnd);
this.onPlayEnd = null;
}
},
getPeaks: function (length) {

@@ -120,0 +143,0 @@ if (this.buffer) {

@@ -423,131 +423,6 @@ /**

/* Observer */
WaveSurfer.Observer = {
/**
* Attach a handler function for an event.
*/
on: function (event, fn) {
if (!this.handlers) { this.handlers = {}; }
var handlers = this.handlers[event];
if (!handlers) {
handlers = this.handlers[event] = [];
}
handlers.push(fn);
},
/**
* Remove an event handler.
*/
un: function (event, fn) {
if (!this.handlers) { return; }
var handlers = this.handlers[event];
if (handlers) {
if (fn) {
for (var i = handlers.length - 1; i >= 0; i--) {
if (handlers[i] == fn) {
handlers.splice(i, 1);
}
}
} else {
handlers.length = 0;
}
}
},
/**
* Remove all event handlers.
*/
unAll: function () {
this.handlers = null;
},
/**
* Attach a handler to an event. The handler is executed at most once per
* event type.
*/
once: function (event, handler) {
var my = this;
var fn = function () {
handler.apply(this, arguments);
setTimeout(function () {
my.un(event, fn);
}, 0);
};
this.on(event, fn);
},
fireEvent: function (event) {
if (!this.handlers) { return; }
var handlers = this.handlers[event];
var args = Array.prototype.slice.call(arguments, 1);
handlers && handlers.forEach(function (fn) {
fn.apply(null, args);
});
}
WaveSurfer.create = function (params) {
var wavesurfer = Object.create(WaveSurfer);
wavesurfer.init(params);
return wavesurfer;
};
/* Common utilities */
WaveSurfer.util = {
extend: function (dest) {
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function (source) {
Object.keys(source).forEach(function (key) {
dest[key] = source[key];
});
});
return dest;
},
getId: function () {
return 'wavesurfer_' + Math.random().toString(32).substring(2);
},
max: function (values, min) {
var max = -Infinity;
for (var i = 0, len = values.length; i < len; i++) {
var val = values[i];
if (min != null) {
val = Math.abs(val - min);
}
if (val > max) { max = val; }
}
return max;
},
ajax: function (options) {
var ajax = Object.create(WaveSurfer.Observer);
var xhr = new XMLHttpRequest();
var fired100 = false;
xhr.open(options.method || 'GET', options.url, true);
xhr.responseType = options.responseType;
xhr.addEventListener('progress', function (e) {
ajax.fireEvent('progress', e);
if (e.lengthComputable && e.loaded == e.total) {
fired100 = true;
}
});
xhr.addEventListener('load', function (e) {
if (!fired100) {
ajax.fireEvent('progress', e);
}
ajax.fireEvent('load', e);
if (200 == xhr.status || 206 == xhr.status) {
ajax.fireEvent('success', xhr.response, e);
} else {
ajax.fireEvent('error', e);
}
});
xhr.addEventListener('error', function (e) {
ajax.fireEvent('error', e);
});
xhr.send();
ajax.xhr = xhr;
return ajax;
}
};
WaveSurfer.util.extend(WaveSurfer, WaveSurfer.Observer);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet