diff --git a/src/music/Mseq_-_Journey.mp3 b/src/music/Mseq_-_Journey.mp3 new file mode 100644 index 0000000..234ea1a Binary files /dev/null and b/src/music/Mseq_-_Journey.mp3 differ diff --git a/src/music/music.js b/src/music/music.js new file mode 100644 index 0000000..46d6515 --- /dev/null +++ b/src/music/music.js @@ -0,0 +1,7 @@ +import "bootstrap"; +import "./music.scss"; +import music from "./Mseq_-_Journey.mp3"; + +import Player from "./player/index.js"; + +window.player = new Player(music); diff --git a/src/music/music.pug b/src/music/music.pug new file mode 100644 index 0000000..5c11cd7 --- /dev/null +++ b/src/music/music.pug @@ -0,0 +1,4 @@ +extends ../lib/pug/base + +block content + #playerUI diff --git a/src/music/music.scss b/src/music/music.scss new file mode 100644 index 0000000..967f4e7 --- /dev/null +++ b/src/music/music.scss @@ -0,0 +1,7 @@ +@import "../lib/scss/main"; +@import "~bootstrap/scss/bootstrap"; + +#playerUI { + width: 100%; + height: 100%; +} diff --git a/src/music/player/index.js b/src/music/player/index.js new file mode 100644 index 0000000..815dd43 --- /dev/null +++ b/src/music/player/index.js @@ -0,0 +1,29 @@ +class AudioManager { + constructor(src) { + this._context = new AudioContext(); + this.audio = new Audio(src); + + let audio = this.audio; + let context = this._context; + + // Create audio graph + let volume = context.createGain(); + let source = context.createMediaElementSource(audio); + + source.connect(volume); + volume.connect(context.destination); + } +} + +class Player { + constructor(src="https://tlater.net/assets/Mseq_-_Journey.mp3") { + this._ui = $("#playerUI"); + this._audioManager = new AudioManager(src); + + let audioManager = this._audioManager; + + audioManager.oncanplay = () => audioManager.audio.play(); + } +} + +export default Player; diff --git a/src/pages/music.json b/src/pages/music.json new file mode 100644 index 0000000..069e517 --- /dev/null +++ b/src/pages/music.json @@ -0,0 +1,7 @@ +{ + "hash": true, + "title": "tlater.net music", + "filename": "../music.html", + "template": "./src/music/music.pug", + "chunks": ["music"] +} diff --git a/webpack.common.js b/webpack.common.js index 77afbb0..9e7a947 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -19,7 +19,8 @@ module.exports = { entry: { index: "./src/index/index.js", mail: "./src/mail/mail.js", - startpage: "./src/startpage/startpage.js" + startpage: "./src/startpage/startpage.js", + music: "./src/music/music.js" }, output: { filename: "[name].bundle.js", @@ -80,6 +81,15 @@ module.exports = { loader: "pug-loader" }] }, + { + test: /\.mp3$/, + use: [{ + loader: "file-loader", + options: { + publicPath: "static/" + } + }] + }, { test: /\.(eot|svg|ttf|woff|woff2)$/, use: [{