fix filters
This commit is contained in:
parent
fabe38c0a6
commit
a83f72bdb3
1 changed files with 21 additions and 1 deletions
|
@ -42,9 +42,15 @@ const FilterList = {
|
||||||
get length() {
|
get length() {
|
||||||
return Object.keys(this).length;
|
return Object.keys(this).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return `${Object.values(this).join(',')}`;
|
return `${Object.values(this).join(',')}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates single string of audio filters
|
||||||
|
* @param filter Array of AudioFilters name
|
||||||
|
*/
|
||||||
create(filter?: FiltersName[]) {
|
create(filter?: FiltersName[]) {
|
||||||
if (!filter || !Array.isArray(filter)) return this.toString();
|
if (!filter || !Array.isArray(filter)) return this.toString();
|
||||||
return filter
|
return filter
|
||||||
|
@ -52,13 +58,27 @@ const FilterList = {
|
||||||
.map((m) => this[m])
|
.map((m) => this[m])
|
||||||
.join(',');
|
.join(',');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines custom filter
|
||||||
|
* @param filterName The filter name
|
||||||
|
* @param value FFmpeg args to use with -af
|
||||||
|
* @example Player.AudioFilters.define("3D", "apulsator=hz=0.125")
|
||||||
|
*
|
||||||
|
* player.setFilters(message, { "3D": true })
|
||||||
|
*/
|
||||||
define(filterName: string, value: string) {
|
define(filterName: string, value: string) {
|
||||||
/* @ts-ignore */
|
/* @ts-ignore */
|
||||||
if (typeof this[filterName] !== 'string') return;
|
if (typeof this[filterName] && typeof this[filterName] === "function") return;
|
||||||
|
|
||||||
/* @ts-ignore */
|
/* @ts-ignore */
|
||||||
this[filterName] = value;
|
this[filterName] = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines filters in bulk
|
||||||
|
* @param filterArray Array of filters containing object with `name` and `value` prop
|
||||||
|
*/
|
||||||
defineBulk(filterArray: { name: string; value: string }[]) {
|
defineBulk(filterArray: { name: string; value: string }[]) {
|
||||||
filterArray.forEach((arr) => this.define(arr.name, arr.value));
|
filterArray.forEach((arr) => this.define(arr.name, arr.value));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue