1
Fork 0

Externalised audio playing

This commit is contained in:
Jake Howard 2015-11-05 08:42:52 +00:00
parent de95e194f3
commit fa720d3b28
5 changed files with 47 additions and 15 deletions

View file

@ -14,4 +14,5 @@ echo ">> Building Main JS..."
uglifyjs src/main.js --compress --screw-ie8 --define --stats --keep-fnames -o build/main.js uglifyjs src/main.js --compress --screw-ie8 --define --stats --keep-fnames -o build/main.js
echo ">> Building Audio Controller..." 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

View file

@ -4,6 +4,6 @@
<title>Audio Controller Window</title> <title>Audio Controller Window</title>
</head> </head>
<body> <body>
<script src="js/audio.js"></script> <script src="js/audio-player.js"></script>
</body> </body>
</html> </html>

View 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
};

View file

@ -6,13 +6,14 @@ var fs = require('fs');
var Tray = require('tray'); var Tray = require('tray');
var ipc = require('ipc'); var ipc = require('ipc');
var AudioController = require('./js/audio-controller');
require('crash-reporter').start(); // Start crash reporter require('crash-reporter').start(); // Start crash reporter
// Creating menu // Creating menu
var menu = new Menu(); var menu = new Menu();
Menu.setApplicationMenu(menu); Menu.setApplicationMenu(menu);
var mainWindow = null; var mainWindow = null;
var audioController = null;
var icon = null; var icon = null;
const INDEX_PAGE = 'file://' + __dirname + '/index.html'; const INDEX_PAGE = 'file://' + __dirname + '/index.html';
@ -41,20 +42,10 @@ app.on('ready', function () {
mainWindow.toggleDevTools(); mainWindow.toggleDevTools();
mainWindow.on('closed', function() { mainWindow.on('closed', function() {
delete mainWindow; delete mainWindow;
audioController.close(); AudioController.getWindow().close();
}); });
audioController = new BrowserWindow({ AudioController.startWindow();
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; });
}); });
ipc.on('hide', function () { ipc.on('hide', function () {