-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
10,744 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug main process", | ||
"type": "node", | ||
"request": "launch", | ||
"outputCapture": "std", | ||
"cwd": "${workspaceRoot}", | ||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", | ||
"args" : ["."] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"javascript.validate.enable": false | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "MixCloud-Play", | ||
"version": "0.0.1", | ||
"description": "The desktop client MixCloud", | ||
"author": { | ||
"name": "Codemotion Ltd." | ||
}, | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"start": "electron .", | ||
"build": "rimraf build && webpack-cli --mode=production", | ||
"watch": "rimraf build && webpack-cli --mode=development --watch", | ||
"dist": "yarn build && build -m" | ||
}, | ||
"build": { | ||
"files": [ | ||
"build" | ||
], | ||
"appId": "com.codemotionapps.mixcloud", | ||
"copyright": "Copyright © 2018 Codemotion Ltd.", | ||
"productName": "MixCloud Play", | ||
"mac": { | ||
"icon": "MixCloud.icns", | ||
"target": [ | ||
"dmg" | ||
] | ||
} | ||
}, | ||
"main": "build/main.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0-rc.3", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0-rc.3", | ||
"@babel/plugin-proposal-decorators": "^7.0.0-rc.3", | ||
"@babel/plugin-proposal-function-bind": "^7.0.0-rc.3", | ||
"@babel/preset-env": "^7.0.0-rc.3", | ||
"@babel/preset-react": "^7.0.0-rc.3", | ||
"babel-loader": "^8.0.0-beta.6", | ||
"copy-webpack-plugin": "^4.5.2", | ||
"electron": "2.0.8", | ||
"electron-builder": "20.28.2", | ||
"electron-ipc-log": "^3.0.1", | ||
"mobx": "5.0.5", | ||
"mobx-react": "5.2.5", | ||
"react": "16.4.2", | ||
"react-dom": "16.4.2", | ||
"rimraf": "^2.6.2", | ||
"webpack": "^4.17.1", | ||
"webpack-cli": "^3.1.0" | ||
}, | ||
"dependencies": { | ||
"electron-context-menu": "0.10.0", | ||
"electron-store": "2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const SoundValues = { | ||
HELP_SCOUT: 'hs', | ||
OPERATING_SYSTEM: 'os', | ||
FILE: 'file', | ||
CUSTOM: 'custom', | ||
NO_SOUND: 'noSound' | ||
} | ||
|
||
Object.freeze(SoundValues); | ||
module.exports = SoundValues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const SoundValues = require(`../@enum/SoundValues`); | ||
|
||
module.exports = { | ||
soundValue: SoundValues.HELP_SCOUT, | ||
soundFilename: '', | ||
soundExtension: '', | ||
lastSoundFileId: 0 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = function(){} |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>MixCloud Play</title> | ||
<link rel="stylesheet" type="text/css" media="screen" href="main.css" /> | ||
</head> | ||
<body> | ||
<div id="dragger"></div> | ||
<webview | ||
id="webview" | ||
disablewebsecurity | ||
preload="./preload.js" | ||
src="https://www.mixcloud.com" | ||
webpreferences="experimentalFeatures" | ||
></webview> | ||
<script src="renderer.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
height: 100%; | ||
} | ||
|
||
webview { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#dragger { | ||
height: 54px; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
-webkit-app-region: drag; | ||
pointer-events: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
const path = require(`path`); | ||
|
||
const { | ||
app, | ||
BrowserWindow, | ||
globalShortcut, | ||
ipcMain, | ||
Menu, | ||
Notification, | ||
Tray, | ||
} = require(`electron`); | ||
const contextMenu = require('electron-context-menu'); | ||
const ConfigStore = require(`electron-store`); | ||
|
||
const SoundValues = require(`./@enum/SoundValues`); | ||
|
||
const configStoreDefaults = require(`./@util/configStoreDefaults`); | ||
|
||
const menuTemplate = require(`./menu`); | ||
|
||
let preferencesWindow; | ||
function openPreferences(){ | ||
preferencesWindow = new BrowserWindow({ | ||
width: 400, | ||
height: 400, | ||
}); | ||
contextMenu({window: preferencesWindow}) | ||
preferencesWindow.webContents.loadFile(path.join(__dirname, 'preferences', 'index.html')) | ||
|
||
preferencesWindow.on('close', () => { | ||
preferencesWindow = undefined; | ||
}) | ||
} | ||
|
||
let mainWindow; | ||
let tray | ||
|
||
const toggleWindow = () => { | ||
if (mainWindow.isVisible()) { | ||
mainWindow.hide(); | ||
} else { | ||
mainWindow.show(); | ||
mainWindow.focus(); | ||
} | ||
}; | ||
|
||
const createTray = () => { | ||
tray = new Tray(path.join(__dirname, './img/logoTemplate.png')); | ||
tray.on('right-click', toggleWindow); | ||
tray.on('double-click', toggleWindow); | ||
tray.on('click', (event) => { | ||
toggleWindow(); | ||
}); | ||
}; | ||
|
||
menuTemplate.setPreferencesClickHandler(openPreferences); | ||
menuTemplate.setDashboardClickHandler(() => { | ||
mainWindow.webContents.send('goToDashboard'); | ||
}) | ||
const menu = Menu.buildFromTemplate(menuTemplate) | ||
|
||
function closeHandler(event){ | ||
event.preventDefault(); | ||
|
||
mainWindow.hide(); | ||
} | ||
|
||
app.on('ready', () => { | ||
createTray(); | ||
Menu.setApplicationMenu(menu); | ||
|
||
mainWindow = new BrowserWindow({ | ||
titleBarStyle: 'hiddenInset', | ||
width: 1100, | ||
minWidth: 768, | ||
height: 800, | ||
minHeight: 400, | ||
}); | ||
|
||
mainWindow.webContents.loadFile(path.join(__dirname, 'index.html')) | ||
|
||
// mainWindow.webContents.openDevTools(); | ||
|
||
mainWindow.on('focus', () => { | ||
// app.dock.setBadge(""); | ||
}); | ||
|
||
mainWindow.on('close', closeHandler) | ||
|
||
// Load our media keys | ||
// Copied from https://gist.github.com/twolfson/0a03820e27583cc9ad6e | ||
var registered = globalShortcut.register('medianexttrack', function () { | ||
console.log('medianexttrack pressed'); | ||
mainWindow.webContents.send('next'); | ||
}); | ||
if (!registered) { | ||
console.log('medianexttrack registration failed'); | ||
} else { | ||
console.log('medianexttrack registration bound!'); | ||
} | ||
|
||
var registered = globalShortcut.register('mediaplaypause', function () { | ||
console.log('mediaplaypause pressed'); | ||
mainWindow.webContents.send('playPause'); | ||
}); | ||
if (!registered) { | ||
console.log('mediaplaypause registration failed'); | ||
} else { | ||
console.log('mediaplaypause registration bound!'); | ||
} | ||
|
||
var registered = globalShortcut.register('mediaprevioustrack', function () { | ||
console.log('mediaprevioustrack pressed'); | ||
}); | ||
if (!registered) { | ||
console.log('mediaprevioustrack registration failed'); | ||
} else { | ||
console.log('mediaprevioustrack registration bound!'); | ||
} | ||
|
||
var registered = globalShortcut.register('mediastop', function () { | ||
console.log('mediastop pressed'); | ||
}); | ||
if (!registered) { | ||
console.log('mediastop registration failed'); | ||
} else { | ||
console.log('mediastop registration bound!'); | ||
} | ||
}); | ||
|
||
app.on('activate', () => { | ||
!preferencesWindow && mainWindow && mainWindow.show(); | ||
}); | ||
|
||
app.on('before-quit', () => { | ||
mainWindow && mainWindow.removeListener('close', closeHandler); | ||
}); | ||
|
||
const configStore = new ConfigStore({defaults: configStoreDefaults}); | ||
ipcMain.on('notification', (_event, notificationIndex, subtitle) => { | ||
if(mainWindow.isFocused()) return; | ||
|
||
// app.dock.setBadge("!"); | ||
|
||
const notification = new Notification({ | ||
title: 'MixCloud Play', | ||
subtitle, | ||
silent: configStore.get('soundValue') !== SoundValues.OPERATING_SYSTEM | ||
}); | ||
notification.on('click', () => { | ||
mainWindow.webContents.send('notificationClicked', notificationIndex); | ||
mainWindow.show(); | ||
}); | ||
notification.show(); | ||
setTimeout(() => { | ||
notification.close(); | ||
}, 7000); | ||
}); | ||
|
||
ipcMain.on('handlePause', (_,track) => { | ||
// app.dock.setBadge("!"); | ||
|
||
tray.setTitle(track + ' (paused)') | ||
const notification = new Notification({ | ||
title: 'Mix Paused', | ||
subtitle: track, | ||
silent: configStore.get('soundValue') !== SoundValues.OPERATING_SYSTEM | ||
}); | ||
notification.on('click', () => { | ||
mainWindow.webContents.send('notificationClicked', notificationIndex); | ||
mainWindow.show(); | ||
}); | ||
notification.show(); | ||
setTimeout(() => { | ||
notification.close(); | ||
}, 7000); | ||
}); | ||
|
||
ipcMain.on('nowPlaying', (_,nowPlaying) =>{ | ||
console.log(nowPlaying) | ||
tray.setTitle(nowPlaying); | ||
}) | ||
|
||
ipcMain.on('handlePlay', (_,track) => { | ||
// app.dock.setBadge("!"); | ||
|
||
tray.setTitle(track) | ||
const notification = new Notification({ | ||
title: 'Playing...', | ||
subtitle: track, | ||
silent: configStore.get('soundValue') !== SoundValues.OPERATING_SYSTEM | ||
}); | ||
notification.on('click', () => { | ||
mainWindow.webContents.send('notificationClicked', notificationIndex); | ||
mainWindow.show(); | ||
}); | ||
notification.show(); | ||
setTimeout(() => { | ||
notification.close(); | ||
}, 7000); | ||
}); | ||
|
||
ipcMain.on('updatedSound', () => { | ||
mainWindow.webContents.send('updatedSound'); | ||
}) |
Oops, something went wrong.