mirror of
https://github.com/janishutz/MusicPlayerV2.git
synced 2025-11-25 04:54:23 +00:00
add some more stuff
This commit is contained in:
20
app.js
20
app.js
@@ -1,20 +0,0 @@
|
|||||||
const express = require( 'express' );
|
|
||||||
let app = express();
|
|
||||||
const path = require( 'path' );
|
|
||||||
const fs = require( 'fs' );
|
|
||||||
const bodyParser = require( 'body-parser' );
|
|
||||||
|
|
||||||
app.use( bodyParser.urlencoded( { extended: false } ) );
|
|
||||||
app.use( bodyParser.json() );
|
|
||||||
|
|
||||||
|
|
||||||
app.get( '/', ( request, response ) => {
|
|
||||||
response.send( 'Hello world' );
|
|
||||||
} );
|
|
||||||
|
|
||||||
|
|
||||||
app.use( ( request, response, next ) => {
|
|
||||||
response.sendFile( path.join( __dirname + '' ) )
|
|
||||||
} );
|
|
||||||
|
|
||||||
app.listen( 8080 );
|
|
||||||
31
backend/app.js
Normal file
31
backend/app.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
const express = require( 'express' );
|
||||||
|
let app = express();
|
||||||
|
const path = require( 'path' );
|
||||||
|
const expressSession = require( 'express-session' );
|
||||||
|
const fs = require( 'fs' );
|
||||||
|
const bodyParser = require( 'body-parser' );
|
||||||
|
const cookieParser = require( 'cookie-parser' )
|
||||||
|
const favicon = require( 'serve-favicon' );
|
||||||
|
|
||||||
|
app.use( expressSession ( {
|
||||||
|
secret: 'akgfsdkgfösdolfgslöodfvolwseifvoiwefö',
|
||||||
|
resave: true,
|
||||||
|
saveUninitialized: true
|
||||||
|
} ) );
|
||||||
|
app.use( bodyParser.urlencoded( { extended: false } ) );
|
||||||
|
app.use( bodyParser.json() );
|
||||||
|
app.use( cookieParser() );
|
||||||
|
app.use( favicon( path.join( __dirname + '' ) ) );
|
||||||
|
|
||||||
|
app.use( ( request, response, next ) => {
|
||||||
|
response.sendFile( path.join( __dirname + '' ) )
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
app.get( '/', ( request, response ) => {
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
const PORT = process.env.PORT || 8080;
|
||||||
|
http.createServer( app ).listen( PORT );
|
||||||
@@ -33,6 +33,7 @@ let currentDetails = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let connectedMain = {};
|
let connectedMain = {};
|
||||||
|
// TODO: Add backend integration
|
||||||
|
|
||||||
|
|
||||||
app.get( '/', ( request, response ) => {
|
app.get( '/', ( request, response ) => {
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ createApp( {
|
|||||||
clearInterval( this.micAnalyzer );
|
clearInterval( this.micAnalyzer );
|
||||||
} catch ( err ) {}
|
} catch ( err ) {}
|
||||||
} else if ( this.visualizationSettings === 'mic' ) {
|
} else if ( this.visualizationSettings === 'mic' ) {
|
||||||
$( '.beat' ).hide();
|
$( '.beat-manual' ).hide();
|
||||||
try {
|
try {
|
||||||
clearInterval( this.micAnalyzer );
|
clearInterval( this.micAnalyzer );
|
||||||
} catch ( err ) {}
|
} catch ( err ) {}
|
||||||
@@ -233,10 +233,11 @@ createApp( {
|
|||||||
navigator.mediaDevices.getUserMedia( { audio: true } ).then( ( stream ) => {
|
navigator.mediaDevices.getUserMedia( { audio: true } ).then( ( stream ) => {
|
||||||
const mic = audioContext.createMediaStreamSource( stream );
|
const mic = audioContext.createMediaStreamSource( stream );
|
||||||
mic.connect( analyser );
|
mic.connect( analyser );
|
||||||
analyser.connect( audioContext.destination );
|
|
||||||
analyser.getByteFrequencyData( dataArray );
|
analyser.getByteFrequencyData( dataArray );
|
||||||
let prevSpectrum = null;
|
let prevSpectrum = null;
|
||||||
let threshold = 10; // Adjust as needed
|
let threshold = 10; // Adjust as needed
|
||||||
|
// TODO: Make sure it works as it should
|
||||||
|
// TODO: Make pos update also occur on 10 sec time jump
|
||||||
this.beatDetected = false;
|
this.beatDetected = false;
|
||||||
this.micAnalyzer = setInterval( () => {
|
this.micAnalyzer = setInterval( () => {
|
||||||
analyser.getByteFrequencyData( dataArray );
|
analyser.getByteFrequencyData( dataArray );
|
||||||
|
|||||||
12
index.html
12
index.html
@@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
HELLO WORLD
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
23
main.js
23
main.js
@@ -1,23 +0,0 @@
|
|||||||
const { app, BrowserWindow } = require( 'electron' )
|
|
||||||
require( './app.js' );
|
|
||||||
|
|
||||||
const createWindow = () => {
|
|
||||||
const win = new BrowserWindow( {
|
|
||||||
width: 800,
|
|
||||||
height: 600,
|
|
||||||
})
|
|
||||||
|
|
||||||
win.loadFile( './frontend/dist/index.html' );
|
|
||||||
};
|
|
||||||
|
|
||||||
app.whenReady().then( () => {
|
|
||||||
createWindow();
|
|
||||||
|
|
||||||
app.on( 'activate', () => {
|
|
||||||
if ( BrowserWindow.getAllWindows().length === 0 ) { createWindow() };
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
app.on( 'window-all-closed', () => {
|
|
||||||
if ( process.platform !== 'darwin' ) { app.quit() };
|
|
||||||
} );
|
|
||||||
1106
package-lock.json
generated
1106
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "musicplayerv2",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "A new iteration of my music player, now written in JavaScript as an electron app",
|
|
||||||
"main": "main.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
|
||||||
"start": "electron ."
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/simplePCBuilding/MusicPlayerV2.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"music",
|
|
||||||
"player",
|
|
||||||
"electron",
|
|
||||||
"javascript",
|
|
||||||
"nodejs"
|
|
||||||
],
|
|
||||||
"author": "Janis Hutz",
|
|
||||||
"license": "GPL-3.0-or-later",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/simplePCBuilding/MusicPlayerV2/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/simplePCBuilding/MusicPlayerV2#readme",
|
|
||||||
"dependencies": {
|
|
||||||
"body-parser": "^1.20.2",
|
|
||||||
"express": "^4.18.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user