Skip to content

Commit

Permalink
updates for v1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Fraser committed Jan 11, 2019
1 parent 97a460e commit 08b635f
Show file tree
Hide file tree
Showing 18 changed files with 1,038 additions and 3,842 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated
- /
## [1.7.0] - 2018-01-11
### Added
- New Tray icons
### Changed
- Removed the splash screen
- Removed the about screen
### Removed
- Old individual tray icons for playing & paused

## [1.6.1] - 2018-09-09
### Added
Expand Down
52 changes: 0 additions & 52 deletions about.html

This file was deleted.

Binary file removed assets/icons/menu-standard-dark-paused.png
Binary file not shown.
Binary file removed assets/icons/menu-standard-dark-paused@2x.png
Binary file not shown.
Binary file removed assets/icons/menu-standard-dark-playing.png
Binary file not shown.
Binary file removed assets/icons/menu-standard-dark-playing@2x.png
Binary file not shown.
Binary file modified assets/icons/menu-standard-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/menu-standard-dark@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/icons/menu-standard-light-paused.png
Binary file not shown.
Binary file removed assets/icons/menu-standard-light-paused@2x.png
Binary file not shown.
Binary file removed assets/icons/menu-standard-light-playing.png
Binary file not shown.
Binary file removed assets/icons/menu-standard-light-playing@2x.png
Binary file not shown.
Binary file modified assets/icons/menu-standard-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/menu-standard-light@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 12 additions & 73 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
const { app, BrowserWindow, globalShortcut, ipcMain, Menu, Tray } = require('electron')
const { app, BrowserWindow, globalShortcut, ipcMain, systemPreferences, Tray } = require('electron')
const notifier = require('node-notifier')
const path = require('path')
const windowStateKeeper = require('electron-window-state')

require('electron-debug')({ enabled: false })

// variables
let winWidth = 440
let winHeight = 620
let loadingScreen
let mainWindow
let aboutScreen
let tray
let trayTheme
let status
Expand All @@ -23,32 +20,6 @@ let windowParams = {
const isMac = process.platform === 'darwin'
const isWindows = process.platform === 'win32'

function createAboutWindow () {
aboutScreen = new BrowserWindow({
backgroundColor: '#131313',
frame: true,
icon: path.join(__dirname, 'assets/musictube.ico'),
title: 'About MusicTube Player',
height: 400,
width: 320
})
aboutScreen.loadURL(`file://${__dirname}/about.html`)
}

function createLoadingWindow () {
loadingScreen = new BrowserWindow(Object.assign(windowParams, {
frame: false,
parent: mainWindow,
width: winWidth,
height: winWidth
}))
loadingScreen.loadURL(`file://${__dirname}/loading.html`)
loadingScreen.on('closed', () => { loadingScreen = null })
loadingScreen.webContents.on('did-finish-load', () => {
loadingScreen.show()
})
}

function createWindow () {
let mainWindowState = windowStateKeeper({
defaultWidth: winWidth,
Expand All @@ -57,19 +28,11 @@ function createWindow () {
mainWindow = new BrowserWindow(Object.assign(windowParams, {
frame: true,
height: mainWindowState.height,
show: false,
width: mainWindowState.width,
x: mainWindowState.x,
y: mainWindowState.y
}))
mainWindow.loadURL(`https://music.youtube.com/`)
mainWindow.hide()
// Show main window and hide loader
mainWindow.webContents.on('did-finish-load', () => {
mainWindowState.manage(mainWindow)
mainWindow.show()
if (loadingScreen !== null) loadingScreen.close()
})
// Close behaviour
mainWindow.on('close', (e) => {
mainWindowState.saveState(mainWindow)
Expand All @@ -85,6 +48,7 @@ function createWindow () {
function globalShortcuts () {
// Play,Pause
globalShortcut.register('MediaPlayPause', () => {
console.log('play/pause')
mainWindow.webContents.executeJavaScript(`document.querySelector('.play-pause-button').click()`)
})
// Next
Expand All @@ -104,35 +68,6 @@ function trayIcon () {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.show()
})

trayContextMenu()
}

function trayContextMenu () {
const contextMenu = Menu.buildFromTemplate([
{
label: app.getName()
},
{
type: 'separator'
},
{
label: 'About',
click: () => {
createAboutWindow()
}
},
{
label: 'Quit',
click: () => {
app.quit()
}
}
])
tray.setContextMenu(contextMenu)
tray.on('right-click', () => {
tray.popUpContextMenu(contextMenu)
})
}

function playStatus () {
Expand All @@ -151,7 +86,7 @@ function playStatus () {
ipcRenderer.send('player', object)
`)
}
}, 250)
}, 500)
}

function skipOver () {
Expand All @@ -163,7 +98,7 @@ function skipOver () {
if (skip) { skip.click() }
`)
}
}, 250)
}, 1000)
// You Still There popup notice
setInterval(() => {
if (mainWindow) {
Expand All @@ -172,15 +107,20 @@ function skipOver () {
if (stillThere) { stillThere.click() }
`)
}
}, 250)
}, 1000)
}

// Application ready to run
app.on('ready', () => {
trayTheme = (isMac) ? 'dark' : 'light'
trayTheme = 'light'
if (isMac) {
trayTheme = 'dark'
if (systemPreferences.isDarkMode()) {
trayTheme = 'light'
}
}
app.setName('MusicTube Player')

createLoadingWindow()
createWindow()
globalShortcuts()
trayIcon()
Expand Down Expand Up @@ -216,5 +156,4 @@ ipcMain.on('player', (event, object) => {
}
}
status = JSON.stringify(object)
tray.setImage(path.join(__dirname, `assets/icons/menu-standard-${trayTheme}-${object.status.toLowerCase()}.png`))
})
32 changes: 0 additions & 32 deletions loading.html

This file was deleted.

Loading

0 comments on commit 08b635f

Please sign in to comment.