-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcuack.js
73 lines (59 loc) · 1.49 KB
/
cuack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const {app, BrowserWindow, TouchBar} = require('electron')
const player = require('play-sound')(opts = {})
const {TouchBarLabel, TouchBarButton} = TouchBar
let window
function musicPlayer() {
return player.play('sounds/quack.mp3', {afplay: ['-v', 1 ]}, function(err){
if (err) throw err
})
}
function musicPlayeronFire() {
return player.play('sounds/quackYell02.mp3', {afplay: ['-v', 1 ]}, function(err){
if (err) throw err
})
}
const duckTouchBarButton = new TouchBarButton ({
label:'',
backgroundColor: '#000000',
icon: 'images/duck/duck1.png',
click: musicPlayer,
})
const duckOnFireTouchBarButton = new TouchBarButton ({
label:'',
backgroundColor: '#6aacbd',
icon: 'images/duck/duck1.png',
click: musicPlayeronFire,
})
const touchBar = new TouchBar({
items: [duckTouchBarButton,duckOnFireTouchBarButton],
})
let frame = 0;
const updateFrames = () => {
if (frame === 2) {
frame = 1;
} else {
frame += 1;
}
const duckPath = `images/duck/duck${frame}.png`;
duckTouchBarButton.icon = duckOnFireTouchBarButton.icon = duckPath;
}
const animateFrames = () => {
setInterval(updateFrames, 100)
};
app.once('ready', () => {
window = new BrowserWindow({
frame: false,
titleBarStyle: 'hiddenInset',
width: 80,
height: 30,
backgroundColor: '#0000',
minimizable: false,
maximizable: false,
})
window.loadURL('about:blank')
window.setTouchBar(touchBar)
animateFrames()
})
app.on('window-all-closed', () => {
app.quit()
})