-
Notifications
You must be signed in to change notification settings - Fork 2
/
player_end.js
76 lines (75 loc) · 2.58 KB
/
player_end.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
function loadDanmakuFile(filePath) {
fetch(filePath)
.then(response => response.text())
.then(content => {
loadDanmaku(content);
})
.catch(error => {
console.error('Error loading danmaku file:', error);
});
}
function loadDanmaku(content) {
eval(content);
}
// 监听浏览器窗口的 resize 事件
window.addEventListener('resize', () => {
if (danmaku) {
danmaku.resize(); // 调用 danmaku 的 resize 方法
}
});
function isMacOS() {
return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
}
if (isMacOS()) {
//console.log('mac');
} else {
const closeButton = document.getElementById('close-button');
const miniButton = document.getElementById('minimize-button');
closeButton.classList.add('close-button-other');
closeButton.classList.add('playclose');
closeButton.style.display = 'block';
closeButton.addEventListener('click', () => {
//console.log('nipa');
ipcRenderer.send('close-player-window');
});
miniButton.classList.add('minimize-button-other');
miniButton.style.display = 'block';
miniButton.classList.add('playclose');
miniButton.addEventListener('click', () => {
//console.log('nipa');
ipcRenderer.send('minimize-player-window');
});
}
//var myVideoPlayer = videojs('video-player');
function ShowTopButton() {
const topButtonContainer = document.getElementById('top-button-container');
topButtonContainer.style.zIndex = 90;
if (isMacOS()) {
topButtonContainer.style.right = '1%';
} else {
topButtonContainer.style.left = '1%';
}
}
function hideTopButton() {
const topButtonContainer = document.getElementById('top-button-container');
topButtonContainer.style.zIndex = -5;
}
function toggleAlwaysOnTop(isAlwaysOnTop) {
ipcRenderer.send('toggle-always-on-top', isAlwaysOnTop);
}
document.getElementById('top-button').addEventListener('click', () => {
const topButton = document.getElementById('top-button');
const topButtonOff = document.getElementById('top-button-off');
topButton.style.display = 'none';
topButtonOff.style.display = 'block';
const isAlwaysOnTop = true;
toggleAlwaysOnTop(isAlwaysOnTop);
});
document.getElementById('top-button-off').addEventListener('click', () => {
const topButton = document.getElementById('top-button');
const topButtonOff = document.getElementById('top-button-off');
topButton.style.display = 'block';
topButtonOff.style.display = 'none';
const isAlwaysOnTop = false;
toggleAlwaysOnTop(isAlwaysOnTop);
});