added moss

This commit is contained in:
2026-09-11 09:14:51 +08:00
parent 2b663d50ad
commit 07261d092b
8 changed files with 669 additions and 9 deletions

View File

@@ -10,6 +10,7 @@
常用快捷键:
Space 播放 / 暂停
← / → 后退 / 前进 10 秒
双击画面 进入 / 退出全屏
Shift+← / → 后退 / 前进 60 秒
↑ / ↓ 音量 +5 / -5
Ctrl+↑ / ↓ 快进步长 +1 / -1 秒(macOS 亦支持 Command+↑ / ↓)
@@ -991,6 +992,7 @@ class MediaPlayerApp(tk.Tk):
toolbar = ttk.Frame(self, padding=(8, 8))
toolbar.pack(fill="x")
self.toolbar = toolbar
ttk.Button(toolbar, text="打开文件…", command=self.open_files, takefocus=0).pack(side="left", padx=(0, 4))
ttk.Button(toolbar, text="打开文件夹…", command=self.open_folder, takefocus=0).pack(side="left", padx=(0, 8))
@@ -1027,6 +1029,7 @@ class MediaPlayerApp(tk.Tk):
main.pack(fill="both", expand=True)
main.columnconfigure(0, weight=1)
main.rowconfigure(0, weight=1)
self.main = main
self.video_frame = tk.Frame(main, bg="#101010")
self.video_frame.grid(row=0, column=0, sticky="nsew", padx=(0, 8))
@@ -1038,6 +1041,7 @@ class MediaPlayerApp(tk.Tk):
hint_text = "打开文件开始播放\n(视频将在独立窗口中显示)"
self.video_hint = tk.Label(self.video_frame, text=hint_text, bg="#101010", fg="#8a8a8a")
self.video_hint.place(relx=0.5, rely=0.5, anchor="center")
self.video_frame.bind("<Double-Button-1>", self._on_video_double_click)
side = ttk.Frame(main, width=260)
side.grid(row=0, column=1, sticky="ns")
@@ -1057,6 +1061,7 @@ class MediaPlayerApp(tk.Tk):
scrollbar = ttk.Scrollbar(side, orient="vertical", command=self.listbox.yview)
scrollbar.grid(row=0, column=1, sticky="ns")
self.listbox.configure(yscrollcommand=scrollbar.set)
self.side = side
self._playlist_menu = tk.Menu(self, tearoff=0)
self._playlist_menu.add_command(label="播放选中曲目", command=self.play_selected)
self._playlist_menu.add_separator()
@@ -1071,6 +1076,7 @@ class MediaPlayerApp(tk.Tk):
bottom = ttk.Frame(self, padding=(8, 6))
bottom.pack(fill="x")
self.bottom = bottom
self.seekbar = SeekBar(bottom, command=self._on_seek_command)
self.seekbar.pack(fill="x")
@@ -2124,18 +2130,42 @@ class MediaPlayerApp(tk.Tk):
self._update_status()
def toggle_fullscreen(self):
self._fullscreen = not self._fullscreen
if isinstance(self.engine, AvEngine):
self.attributes("-fullscreen", self._fullscreen)
if self.engine.EMBEDDABLE:
self._set_app_fullscreen(not self._fullscreen)
else:
self.engine.set_fullscreen(self._fullscreen)
self.engine.set_fullscreen(not self._fullscreen)
self._fullscreen = not self._fullscreen
def leave_fullscreen(self):
self._fullscreen = False
if isinstance(self.engine, AvEngine):
self.attributes("-fullscreen", False)
if self.engine.EMBEDDABLE:
self._set_app_fullscreen(False)
else:
self.engine.set_fullscreen(False)
self._fullscreen = False
def _on_video_double_click(self, _event=None):
if self.engine.EMBEDDABLE:
self.toggle_fullscreen()
return "break"
def _set_app_fullscreen(self, on):
on = bool(on)
if on == self._fullscreen:
return
if on:
self.toolbar.pack_forget()
self.bottom.pack_forget()
self.side.grid_remove()
self.video_frame.grid_configure(padx=0)
self.attributes("-fullscreen", True)
self.lift()
else:
self.attributes("-fullscreen", False)
self.side.grid()
self.video_frame.grid_configure(padx=(0, 8))
self.toolbar.pack(before=self.main, side="top", fill="x")
self.bottom.pack(after=self.main, side="bottom", fill="x")
self._fullscreen = on
def play_selected(self):
selection = self.listbox.curselection()