Externalised audio playing
This commit is contained in:
parent
de95e194f3
commit
fa720d3b28
5 changed files with 47 additions and 15 deletions
|
@ -14,4 +14,5 @@ echo ">> Building Main JS..."
|
|||
uglifyjs src/main.js --compress --screw-ie8 --define --stats --keep-fnames -o build/main.js
|
||||
|
||||
echo ">> Building Audio Controller..."
|
||||
uglifyjs src/js/audio.js --compress --screw-ie8 --define --stats --keep-fnames -o build/js/audio.js
|
||||
uglifyjs src/js/audio-controller.js --compress --screw-ie8 --define --stats --keep-fnames -o build/js/audio-controller.js
|
||||
uglifyjs src/js/audio-player.js --compress --screw-ie8 --define --stats --keep-fnames -o build/js/audio-player.js
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
<title>Audio Controller Window</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="js/audio.js"></script>
|
||||
<script src="js/audio-player.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
40
src/js/audio-controller.js
Normal file
40
src/js/audio-controller.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
var BrowserWindow = require('browser-window');
|
||||
var ipc = require('ipc');
|
||||
|
||||
var playerWindow;
|
||||
|
||||
function startWindow() {
|
||||
playerWindow = new BrowserWindow({
|
||||
width: 0,
|
||||
height: 0,
|
||||
show: false,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
'skip-taskbar': true
|
||||
});
|
||||
playerWindow.loadUrl('file://' + __dirname + '/audio.html');
|
||||
buildEvents();
|
||||
return playerWindow;
|
||||
}
|
||||
|
||||
function buildEvents() {
|
||||
playerWindow.on('closed', function () { delete playerWindow; });
|
||||
}
|
||||
|
||||
function getWindow() {
|
||||
return playerWindow;
|
||||
}
|
||||
|
||||
function play() {
|
||||
console.log("CLICK!");
|
||||
}
|
||||
|
||||
ipc.on('play', function () {
|
||||
play();
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
getWindow: getWindow,
|
||||
startWindow: startWindow,
|
||||
play: play
|
||||
};
|
17
src/main.js
17
src/main.js
|
@ -6,13 +6,14 @@ var fs = require('fs');
|
|||
var Tray = require('tray');
|
||||
var ipc = require('ipc');
|
||||
|
||||
var AudioController = require('./js/audio-controller');
|
||||
|
||||
require('crash-reporter').start(); // Start crash reporter
|
||||
|
||||
// Creating menu
|
||||
var menu = new Menu();
|
||||
Menu.setApplicationMenu(menu);
|
||||
var mainWindow = null;
|
||||
var audioController = null;
|
||||
var icon = null;
|
||||
const INDEX_PAGE = 'file://' + __dirname + '/index.html';
|
||||
|
||||
|
@ -41,20 +42,10 @@ app.on('ready', function () {
|
|||
mainWindow.toggleDevTools();
|
||||
mainWindow.on('closed', function() {
|
||||
delete mainWindow;
|
||||
audioController.close();
|
||||
AudioController.getWindow().close();
|
||||
});
|
||||
|
||||
audioController = new BrowserWindow({
|
||||
width: 0,
|
||||
height: 0,
|
||||
show: false,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
'skip-taskbar': true,
|
||||
|
||||
});
|
||||
audioController.loadUrl('file://' + __dirname + '/audio.html');
|
||||
audioController.on('closed', function () { delete audioController; });
|
||||
AudioController.startWindow();
|
||||
});
|
||||
|
||||
ipc.on('hide', function () {
|
||||
|
|
Reference in a new issue