forked from mafintosh/playback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·80 lines (63 loc) · 1.54 KB
/
app.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
74
75
76
77
78
79
80
#!/usr/bin/env atom-shell
var app = require('app')
var BrowserWindow = require('browser-window')
var path = require('path')
var ipc = require('ipc')
var dialog = require('dialog')
var win
var link
var ready = false
var onopen = function (e, lnk) {
e.preventDefault()
if (ready) {
win.send('add-to-playlist', [].concat(lnk))
return
}
link = lnk
}
app.on('open-file', onopen)
app.on('open-url', onopen)
app.on('ready', function () {
win = new BrowserWindow({
title: 'playback',
width: 860,
height: 470,
frame: false,
show: false
})
win.loadUrl('file://' + path.join(__dirname, 'index.html#' + JSON.stringify(process.argv.slice(2))))
ipc.on('close', function () {
app.quit()
})
ipc.on('open-file-dialog', function () {
var files = dialog.showOpenDialog({ properties: [ 'openFile', 'multiSelections' ]})
if (files) win.send('add-to-playlist', files)
})
ipc.on('focus', function () {
win.focus()
})
ipc.on('minimize', function () {
win.minimize()
})
ipc.on('maximize', function () {
win.maximize()
})
ipc.on('resize', function (e, message) {
if (win.isMaximized()) return
var wid = win.getSize()[0]
var hei = (wid / message.ratio) | 0
win.setSize(wid, hei)
})
ipc.on('enter-full-screen', function () {
win.setFullScreen(true)
})
ipc.on('exit-full-screen', function () {
win.setFullScreen(false)
win.show()
})
ipc.on('ready', function () {
ready = true
if (link) win.send('add-to-playlist', [].concat(link))
win.show()
})
})