Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Commit

Permalink
added electron-music-player
Browse files Browse the repository at this point in the history
  • Loading branch information
aptinstaller committed Oct 1, 2020
1 parent 24b0aae commit 99608eb
Show file tree
Hide file tree
Showing 14 changed files with 12,537 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Electron Music Player/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Readme
## Enounce is a free music player for desktop - electron based and has an integrated youtube link player



### Installation
```bash
npm install
```

### Run & Pack

```bash
npm start .


npm run dist
```

Binary file added Electron Music Player/enounce.ico
Binary file not shown.
55 changes: 55 additions & 0 deletions Electron Music Player/enounce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const electron = require('electron');
const url = require('url');
const path = require('path');
const $ = require('jquery');
const { app, BrowserWindow } = electron;


app.on('ready', () => {

var tinyWindow = new BrowserWindow({
width: 300,
height: 400,
frame:false,
autoHideMenuBar: true,
webPreferences: {nodeIntegration :true}
});

var mainWindow = new BrowserWindow({
autoHideMenuBar: true,
width:300,
height:400,
frame:true,
resizable: true,
webPreferences: { nodeIntegration: true }
});

setTimeout(() => {
tinyWindow.close();

//Garbage Collection Do not Remove

tinyWindow = null;

//Garabage Collection Ends Here
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'html/index.html'),
protocol: 'file:',
slashes: true
}));

}, 1000);

tinyWindow.loadURL(url.format({
pathname: path.join(__dirname, 'html/enounce.html'),
protocol: 'file:',
slashes: true
}));

//Quit App When Main Closed

mainWindow.on('closed', () => {
app.quit();
});

});
23 changes: 23 additions & 0 deletions Electron Music Player/html/enounce.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="styles/basic.css">
<title>Enounce</title>
</head>

<body class="maingif">
<div class="container">
<div class="container" style="margin-top: 20%;">
<h1 class="condensed mx-auto text-center maincolor"> Enounce </h1>
<h5 class='text-center condensed maincolor'> - the music scraper - </h5>
<h6 class="text-center condensed maincolor">with ❤ DCIX</h6>
</div>

</div>
</body>

</html>
Binary file added Electron Music Player/html/gif/main.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Electron Music Player/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="styles/basic.css">
<title>Enounce</title>
</head>

<body class="maingif">
<div class="container-fluid d-block mx-auto mt-5">
<h1 class="condensed text-center maincolor"> Music Player </h1>
</div>
<div>
<a onclick="getMusic()" class="btn mainback text-white d-block border border-white">Scan Music</a>
<a id="switch-to-youtube" class="btn mainback text-white d-block border border-white">Switch</a>
</div>
<div class="container">
<ul class="list-unstyled" id='music_list'></ul>
</div>
<div class="container d-block" id="music_player">
</div>
<script src="scripts/player.js"></script>
</body>

</html>
62 changes: 62 additions & 0 deletions Electron Music Player/html/scripts/player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const fs = require('fs');
const $ = require('jquery');
const url = require('url');
const electron = require('electron');
const BrowserWindow = electron.remote.BrowserWindow;
const path = require('path');

function getMusic() {
$("#music_list").children().remove();
fs.readdir(__dirname + '../../../../music_goes_here', (error, file_names) => {
if (error) {
fs.mkdir(__dirname + '../../../../music_goes_here', (error) => {
if (error) {
alert(error);
}
});
alert('Place your music in the created folder');
} else {

if (file_names.length == 0) {
alert('Empty Music Folder Detected');
} else {
var temp_id = 0;
file_names.forEach(file_name => {

var file_name_extension_temp = file_name.split('.')[1];
if (file_name_extension_temp == 'mp3') {

$("#music_list").append('<li><a class="btn badge-pill mainback" id="mp3_id_' + temp_id + '"onclick=playMusic("mp3_id_' + temp_id + '")>' + file_name + '</a></li>')
temp_id++;
} else {
console.log(file_name + ' is not an mp3 file');
}
});
}
}
});
}

function playMusic(song_id) {
$('#music_player').children().remove();
var name = $("#" + song_id).text();
$('#music_player').append('<audio controls><source src="' + __dirname + '../../../../music_goes_here/' + name + '" type="audio/mpeg"></source></audio>')
}


$("#switch-to-youtube").on('click', () => {



$("#switch-to-youtube").removeClass('d-block');
$("#switch-to-youtube").addClass('d-none');

var currentWindow = electron.remote.getCurrentWindow();

currentWindow.loadURL(url.format({
pathname: path.join(__dirname, 'youtube.html'),
protocol: 'file:',
slashes: true
}));

});
48 changes: 48 additions & 0 deletions Electron Music Player/html/scripts/youtube.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const electron = require('electron');
const $ = require('jquery');
const url = require('url');
const path = require('path');
const { BrowserWindow } = electron;

function playYoutubeFromLink() {
var url = $("#link_holder").val();
console.log(url);
if(url != ''){
var videoID = url.split("=")[1];
$.getJSON('http://www.youtube.com/oembed?url=' + url + '&format=json', function(data, status) {
if (status == 'success') {
$("#link_paster").hide();
$("#title").text(data.title);
$("#author").text(data.author_name);
$("#music_art").attr('src', data.thumbnail_url);
$("#secondary_holder").append('<button class="btn mainback text-white d-inline" onclick="stopMusic()" role="button">Stop Music</button>')
$("#invisible_player").attr('src', 'https://www.youtube.com/embed/' + videoID + '?autoplay=1');
}
});
}else{
alert('Empty URL');
}

}


function stopMusic() {
$("#invisible_player").attr('src', '');
$("#music_art").attr('src', '');
$("#title").hide();
$("#author").hide();
$("#secondary_holder").children('button').remove();
$("#link_paster").show();
}


function closeYoutube() {

var currentWindow = electron.remote.getCurrentWindow();

currentWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
}
25 changes: 25 additions & 0 deletions Electron Music Player/html/styles/basic.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.condensed {
font-family: 'Open Sans Condensed', sans-serif;
}

.maincolor {
color: #333333;
}

.mainback {
background-color: #333333;
}

.subcolor {
color: #ecf2f5;
}

.subback {
background-color: #ecf2f5;
}

.maingif {
background-image: url('../gif/main.gif');
/* background-size: 300px !important; */
background-position-y: 100px;
}
Loading

0 comments on commit 99608eb

Please sign in to comment.