-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.html
108 lines (107 loc) · 3.37 KB
/
renderer.html
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="ko-KR">
<head>
<meta charset="utf8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1,
user-scalable=no"
/>
<link rel="stylesheet" href="./assets/all.css" />
<script src="./assets/main.js"></script>
<script src="https://cdn.jsdelivr.net/combine/npm/[email protected],npm/@magenta/[email protected]/es6/core.js,npm/focus-visible@5,npm/[email protected]"></script>
<script>
require('electron').ipcRenderer.on('playToggle', (event, message) => {
if (!message) {
stop()
} else {
play(document.getElementsByTagName('textarea')[0].value)
}
})
require('electron').ipcRenderer.on('save2midi', () => {
save2midi(document.getElementsByTagName('textarea')[0].value)
})
</script>
</head>
<body>
<article>
<form target="_blank" onsubmit="return false">
<textarea
name="data"
style="resize: none; height: 500px; flex: auto"
spellcheck="false"
></textarea>
<div class="menu">
<button
type="button"
name="playButton"
onclick="play(document.getElementsByTagName('textarea')[0].value)"
>
<i class="icon fa-fw fas fa-play"></i> 재생
</button>
<button
type="button"
onclick="save2midi(document.getElementsByTagName('textarea')[0].value)"
>
<i class="icon fa-fw fas fa-file-download"> </i> MID로 저장
</button>
</div>
</form>
<div class="help"></div>
</article>
<div style="background-color: aliceblue; margin: 3px">
<div class="slidecontainer" style="display: flex; margin: 5px">
<p id="timeDisplay">00:00/00:00</p>
<input
id="sliderDisplay"
type="range"
min="0"
max="0"
value="0"
style="width: 100%"
/>
</div>
<midi-visualizer id="srgVisualizer" type="staff"></midi-visualizer>
<midi-player
style="display: none"
id="srgPlayer"
sound-font
visualizer="midi-visualizer"
>
</midi-player>
</div>
<script>
const player = document.getElementById('srgPlayer')
player.addEventListener('stop', () => stop())
player.addEventListener('load', () => {
player.start()
})
require('electron').ipcRenderer.on('timeChange', (event, value) => {
player.currentTime = value / 100
})
document
.getElementById('sliderDisplay')
.addEventListener('input', function (event) {
player.currentTime = event.target.value
})
setInterval(async () => {
if (!player.playing) return
const timeLabel = document.getElementById('timeDisplay')
const slider = document.getElementById('sliderDisplay')
slider.max = player.duration
slider.value = player.currentTime
timeLabel.innerText = `${new Date(
Math.floor(player.currentTime || 0) * 1000
)
.toISOString()
.slice(14, 19)}/${new Date(Math.floor(player.duration || 0) * 1000)
.toISOString()
.slice(14, 19)}`
ipcRenderer.send('update', {
duration: player.duration,
current: player.currentTime,
})
}, 1000)
</script>
</body>
</html>