Added windows support for libmpv
This commit is contained in:
parent
55bedf7aa3
commit
220f1e8779
3 changed files with 16 additions and 12 deletions
|
@ -285,8 +285,6 @@ class Client:
|
|||
f"Playing: {entry.artist} - {entry.title} [{entry.album}] "
|
||||
f"({entry.source}) for {entry.performer}"
|
||||
)
|
||||
print(entry)
|
||||
print(self.skipped)
|
||||
if entry.uuid not in self.skipped:
|
||||
try:
|
||||
if self.state.config["preview_duration"] > 0:
|
||||
|
@ -317,7 +315,6 @@ class Client:
|
|||
:type data: dict[str, Any]
|
||||
:rtype: None
|
||||
"""
|
||||
print(f"Searching for: {data['query']}")
|
||||
query = data["query"]
|
||||
sid = data["sid"]
|
||||
results_list = await asyncio.gather(
|
||||
|
@ -441,6 +438,7 @@ class Client:
|
|||
self.player.mpv.terminate()
|
||||
|
||||
def quit_callback(self) -> None:
|
||||
self.player.close()
|
||||
if self.loop is not None:
|
||||
asyncio.run_coroutine_threadsafe(self.sio.disconnect(), self.loop)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ try:
|
|||
if not TYPE_CHECKING:
|
||||
from ctypes import windll
|
||||
|
||||
appid = "rocks.syng.Syng.2.0.7"
|
||||
appid = "rocks.syng.Syng.2.1"
|
||||
windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid)
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
@ -6,15 +6,16 @@ from qrcode.main import QRCode
|
|||
import mpv
|
||||
import os
|
||||
|
||||
|
||||
from .entry import Entry
|
||||
|
||||
__dirname__ = os.path.dirname(__file__)
|
||||
|
||||
|
||||
class Player:
|
||||
def __init__(self, qr_string: str, quit_callback: Callable[[], None]) -> None:
|
||||
locale.setlocale(locale.LC_ALL, "C")
|
||||
|
||||
self.base_dir = f"{os.path.dirname(__file__)}/static"
|
||||
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
||||
self.base_dir = getattr(sys, "_MEIPASS")
|
||||
self.closing = False
|
||||
self.mpv = mpv.MPV(ytdl=True, input_default_bindings=True, input_vo_keyboard=True, osc=True)
|
||||
self.mpv.title = "Syng - Player"
|
||||
self.mpv.keep_open = "yes"
|
||||
|
@ -24,7 +25,7 @@ class Player:
|
|||
)
|
||||
|
||||
self.mpv.play(
|
||||
f"{__dirname__}/static/background.png",
|
||||
f"{self.base_dir}/background.png",
|
||||
)
|
||||
|
||||
self.default_options = {
|
||||
|
@ -39,8 +40,13 @@ class Player:
|
|||
def event_callback(self, event: mpv.MpvEvent) -> None:
|
||||
e = event.as_dict()
|
||||
if e["event"] == b"shutdown":
|
||||
self.closing = True
|
||||
self.quit_callback()
|
||||
|
||||
def close(self):
|
||||
if not self.closing:
|
||||
self.mpv.terminate()
|
||||
|
||||
def update_qr(self, qr_string: str) -> None:
|
||||
qr = QRCode(box_size=5, border=1)
|
||||
qr.add_data(qr_string)
|
||||
|
@ -76,7 +82,7 @@ class Player:
|
|||
|
||||
self.mpv.sub_pos = 50
|
||||
self.play_image(
|
||||
f"{__dirname__}/static/background20perc.png", 3, sub_file=f"python://{stream_name}"
|
||||
f"{self.base_dir}/background20perc.png", 3, sub_file=f"python://{stream_name}"
|
||||
)
|
||||
|
||||
try:
|
||||
|
@ -119,13 +125,13 @@ class Player:
|
|||
try:
|
||||
await loop.run_in_executor(None, self.mpv.wait_for_property, "eof-reached")
|
||||
self.mpv.image_display_duration = 0
|
||||
self.mpv.play(f"{__dirname__}/static/background.png")
|
||||
self.mpv.play(f"{self.base_dir}/background.png")
|
||||
except mpv.ShutdownError:
|
||||
self.quit_callback()
|
||||
|
||||
def skip_current(self) -> None:
|
||||
self.mpv.image_display_duration = 0
|
||||
self.mpv.play(
|
||||
f"{__dirname__}/static/background.png",
|
||||
f"{self.base_dir}/background.png",
|
||||
)
|
||||
# self.mpv.playlist_next()
|
||||
|
|
Loading…
Add table
Reference in a new issue