Merge branch 'master' of dev.sys.reslate.xyz:ydeng/AudioShowKit

This commit is contained in:
Harrison Deng 2022-04-18 16:03:42 -05:00
commit 3ba9868751
5 changed files with 124 additions and 17086 deletions

17086
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,78 @@
import PlaylistSong from "./PlaylistSong";
/**
* A playlist that holds a multitude of songs.
*/
export default class SongPlaylist {
/**
* Instantiates a playlist for songs.
*
* @param {string} name The name of the playlist.
*/
constructor(name) {
this._list = [];
this._name = name;
this._current = 0;
}
/**
*
* @returns {string} the name of the string.
*/
getName() {
return this._name;
}
/**
*
* @param {number} index the index of the song to retrieve.
* @returns {PlaylistSong} the song at the given index.
*/
songAtIndex(index) {
if (index >= this._list.length) {
return null;
}
return this.list[index];
}
songsWithName(name) {
return this._list.filter((item) => item.getDisplayName() == name);
}
add(url, name, author) {
this._list.push(new PlaylistSong(url, name, author, this, this._list.length));
}
remove(index) {
if (index >= this._list.length) {
return null;
}
let removed = this._list.splice(index, 1);
if (removed.length > 0) {
return removed[0];
}
}
findSongIndex(name) {
// TODO: Could probably be optimized.
return this._list.findIndex((item) => item.getDisplayName() == name);
}
/**
*
* @returns {number} total number of songs in this playlist.
*/
total() {
return this._list.length;
}
/**
* Unloads the audio data of all songs in this playlist.
*/
unloadAllAudio() {
this._list.forEach(playlistSong => {
playlistSong.unloadAudio();
});
}
}

21
webpack.common.js Normal file
View File

@ -0,0 +1,21 @@
export default {
entry: {
audioshowkit: "./src/audioshowkit.js"
},
module: {
rules: [
{
test: /\.html$/i,
loader: "html-loader",
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
}
]
},
output: {
filename: "[name].js",
path: "./dist"
}
};

13
webpack.dev.js Normal file
View File

@ -0,0 +1,13 @@
import merge from "webpack-merge";
import webpackCommon from "./webpack.common";
devConfig = {
mode: "development",
devtools: "inline-source-map",
devServer: {
static: "./dist"
}
}
export default merge(webpackCommon, devConfig);

12
webpack.prod.js Normal file
View File

@ -0,0 +1,12 @@
import merge from "webpack-merge"
import webpackCommon from "./webpack.common"
prodConfig = {
mode: "production",
output: {
filename: "[name].js",
path: "./public"
}
}
export default merge(webpackCommon, prodConfig);