-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
84 lines (71 loc) · 2.18 KB
/
main.py
File metadata and controls
84 lines (71 loc) · 2.18 KB
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
import webview
import os
import sys
from core.media_control import MediaController
from core.pin_logic import PinHandler
mc = MediaController()
ph = PinHandler()
window = None
# -------------------------------
# JS <-> Python API Bridge
# -------------------------------
class Api:
def control(self, action):
"""Play, Pause, Next, Prev controls"""
mc.call(action)
def get_music_data(self):
"""Sends metadata and progress to JS"""
return mc.fetch_data()
def seek_music(self, percent):
"""Updates playback position"""
mc.seek_to(percent)
# ================= VOLUME API (ADDED) =================
def set_volume(self, percent):
"""Sets system volume (0-100)"""
mc.set_volume(percent)
def get_volume(self):
"""Gets current system volume"""
return mc.get_volume()
# ======================================================
def resize_window(self, w, h):
"""🚀 Physically resizes the OS window for the capsule effect"""
if window:
window.resize(w, h)
def toggle_pin(self):
"""Always on top logic"""
if window:
return ph.toggle(window)
return False
def close_app(self):
"""Terminates the application cleanly"""
if window:
window.destroy()
sys.exit(0)
# -------------------------------
# App Launcher
# -------------------------------
def start_app():
global window
# Absolute path logic for reliability
base_path = os.path.dirname(os.path.abspath(__file__))
html_path = os.path.join(base_path, 'web', 'index.html')
# 🚀 NATIVE WIDGET CONFIGURATION
window = webview.create_window(
title='Neon Liquid Player',
url=html_path,
js_api=Api(),
# Dimensions
width=310,
height=220,
min_size=(310, 80),
frameless=True,
transparent=True,
background_color='#000000',
easy_drag=True,
on_top=False,
text_select=False
)
webview.start(gui='edgehtml', debug=False)
# -------------------------------
if __name__ == '__main__':
start_app()