Created
June 20, 2018 19:29
-
-
Save astrotars/55173d75c39163142dacaeebb0519c62 to your computer and use it in GitHub Desktop.
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
mediaControls = (event, args) => { | |
let next = new TouchBarButton({ | |
icon: `${__dirname}/static/next.png`, | |
click: () => { | |
event.sender.send('media-controls', 'next'); | |
}, | |
}); | |
let previous = new TouchBarButton({ | |
icon: `${__dirname}/static/previous.png`, | |
click: () => { | |
event.sender.send('media-controls', 'previous'); | |
}, | |
}); | |
let playPause = new TouchBarButton({ | |
icon: `${__dirname}/static/pause.png`, | |
click: () => { | |
event.sender.send('media-controls', 'togglePlayPause'); | |
}, | |
}); | |
let info = new TouchBarLabel({ | |
label: | |
args.title && args.title.length > 40 | |
? `${args.title.substr(0, 40) + '...'}` | |
: args.title, | |
textColor: '#FFFFFF', | |
}); | |
if (args.type === 'play') { | |
playPause.icon = `${__dirname}/static/pause.png`; | |
info.label = args.title; | |
} else { | |
playPause.icon = `${__dirname}/static/play.png`; | |
} | |
let touchBar = new TouchBar([ | |
previous, | |
playPause, | |
next, | |
new TouchBarSpacer({ size: 'flexible' }), | |
info, | |
new TouchBarSpacer({ size: 'flexible' }), | |
]); | |
mainWindow.setTouchBar(touchBar); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment