feat: video fills entire window, compact control bar, single-tap play/pause

This commit is contained in:
yumoqing 2026-06-21 23:27:17 +08:00
parent af71d46c63
commit 2a5e3b8ad7
3 changed files with 14 additions and 51 deletions

View File

@ -8,7 +8,7 @@ struct MiniPlayerApp: App {
var body: some Scene {
WindowGroup {
ContentView(bridge: bridge)
.frame(minWidth: 640, minHeight: 480)
.frame(minWidth: 900, minHeight: 600)
.onAppear { bridge.setup() }
}
#if os(macOS)

View File

@ -6,14 +6,11 @@
{
"widgettype": "VideoPlayer",
"id": "video_player",
"options": { "width": "100%", "bgcolor": "#000000" },
"binds": [
{ "wid": "self", "event": "click", "actiontype": "event", "target": "player.toggle" }
]
"options": { "width": "100%", "height": "100%", "bgcolor": "#000000" }
},
{
"widgettype": "VBox",
"options": { "width": "100%", "css": "card", "padding": "8px", "spacing": 4 },
"options": { "width": "100%", "bgcolor": "#1a1a1a", "padding": "6px", "spacing": 4 },
"subwidgets": [
{
"widgettype": "HBox",
@ -28,6 +25,11 @@
"widgettype": "HBox",
"options": { "width": "100%", "spacing": 4, "alignItems": "center" },
"subwidgets": [
{
"widgettype": "Button", "id": "btn_open_file",
"options": { "label": "📂 打开", "css": "text" },
"binds": [{ "wid": "self", "event": "click", "actiontype": "event", "target": "player.open_file" }]
},
{
"widgettype": "Button", "id": "btn_prev",
"options": { "label": "⏮", "css": "text" },
@ -44,13 +46,9 @@
"binds": [{ "wid": "self", "event": "click", "actiontype": "event", "target": "player.next" }]
},
{ "widgettype": "Filler" },
{
"widgettype": "Text", "id": "track_label",
"options": { "text": "🎵 Track 1", "i18n": false }
},
{
"widgettype": "Button", "id": "btn_track",
"options": { "label": "音轨", "css": "text" },
"options": { "label": "🎵 音轨", "css": "text" },
"binds": [{ "wid": "self", "event": "click", "actiontype": "event", "target": "player.show_tracks" }]
},
{
@ -66,44 +64,6 @@
]
}
]
},
{
"widgettype": "HBox",
"options": { "width": "100%", "padding": "4px", "spacing": 6, "alignItems": "center" },
"subwidgets": [
{
"widgettype": "InlineForm",
"id": "add_form",
"options": {
"show_label": false,
"submit_label": "添加URL",
"fields": [
{ "name": "url", "placeholder": "M3U8 / 视频URL", "uitype": "str", "cwidth": 30 }
]
},
"binds": [{ "wid": "self", "event": "submit", "actiontype": "event", "target": "player.add_url" }]
},
{
"widgettype": "Button", "id": "btn_open_file",
"options": { "label": "📂 打开文件", "css": "text" },
"binds": [{ "wid": "self", "event": "click", "actiontype": "event", "target": "player.open_file" }]
}
]
},
{
"widgettype": "VScrollPanel",
"id": "playlist_panel",
"options": { "width": "100%", "css": "filler" },
"subwidgets": [
{
"widgettype": "Title5",
"options": { "text": "播放列表", "i18n": true }
},
{
"widgettype": "Text", "id": "playlist_empty",
"options": { "text": "暂无媒体请添加文件或URL", "i18n": true, "color": "#888888" }
}
]
}
]
}

View File

@ -11,8 +11,11 @@ struct VideoPlayerWidget: View {
var body: some View {
VideoPlayerRepresentable(player: bridge.player)
.background(Color.black)
.frame(maxWidth: .infinity)
.aspectRatio(16/9, contentMode: .fit)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.contentShape(Rectangle())
.onTapGesture {
bridge.togglePlayPause()
}
.onTapGesture(count: 2) {
bridge.toggleFullscreen()
}