Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b74cacd660 | ||
|
|
1fc0d0458b | ||
|
|
64c0c9979b | ||
|
|
b419ff5507 | ||
|
|
f508013aa5 | ||
|
|
756eb8d6f0 | ||
|
|
83e04b64da | ||
|
|
408bf8577d | ||
|
|
90e8223c74 | ||
|
|
b1377ea4a1 | ||
|
|
348aa69a50 | ||
|
|
1913d49117 | ||
|
|
2bc2c0a0ec | ||
|
|
544fccf82d | ||
|
|
71bfd3ca2f | ||
|
|
f2f7bb3508 | ||
|
|
c98add8065 | ||
|
|
56b7cb842e | ||
|
|
223a5d2219 | ||
|
|
66611b9bc3 | ||
|
|
35f56c8a80 | ||
|
|
653eee1453 | ||
|
|
29f5dc00c4 | ||
|
|
9d04833b3e | ||
|
|
a55b255d05 |
@@ -0,0 +1,19 @@
|
||||
.git
|
||||
build/
|
||||
.dart_tool/
|
||||
.idea/
|
||||
*.tar.gz
|
||||
nul
|
||||
libmpv-prefix/
|
||||
steamfiles/
|
||||
pubspec_overrides.yaml
|
||||
|
||||
# Flutter ephemeral / generated plugin symlinks
|
||||
linux/flutter/ephemeral/
|
||||
windows/flutter/
|
||||
macos/Flutter/
|
||||
ios/Flutter/
|
||||
android/.gradle/
|
||||
android/app/build/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
@@ -0,0 +1,3 @@
|
||||
*.sh text eol=lf
|
||||
*.Dockerfile text eol=lf
|
||||
Dockerfile text eol=lf
|
||||
@@ -429,13 +429,13 @@ jobs:
|
||||
- name: Cache APT packages
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: clang cmake meson ninja-build pkg-config nasm libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
packages: clang cmake meson ninja-build pkg-config nasm libgtk-3-dev libevdev-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
version: 1.1
|
||||
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y clang cmake meson ninja-build pkg-config nasm libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
sudo apt-get install -y clang cmake meson ninja-build pkg-config nasm libgtk-3-dev libevdev-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
|
||||
- name: Cache libmpv build
|
||||
id: libmpv-cache
|
||||
@@ -537,13 +537,13 @@ jobs:
|
||||
- name: Cache APT packages
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: clang cmake meson ninja-build pkg-config nasm libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
packages: clang cmake meson ninja-build pkg-config nasm libgtk-3-dev libevdev-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
version: 1.1
|
||||
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y clang cmake meson ninja-build pkg-config nasm libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
sudo apt-get install -y clang cmake meson ninja-build pkg-config nasm libgtk-3-dev libevdev-dev liblzma-dev libstdc++-12-dev libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev libepoxy-dev libegl-dev libgl-dev libgnutls28-dev libpipewire-0.3-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev libwayland-dev wayland-protocols liblcms2-dev ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
|
||||
- name: Cache libmpv build
|
||||
id: libmpv-cache
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
cask "plezy" do
|
||||
version "1.16.1"
|
||||
sha256 "56a079818bec9d332a2dc9a16d54b20cb477f5d8f104c1870fc1e936acf78d36"
|
||||
version "1.17.0"
|
||||
sha256 "6c113c19f550c01bead3263e9f6afd9e066673a631b665fd94761ed54731b41f"
|
||||
|
||||
url "https://github.com/edde746/plezy/releases/download/#{version}/plezy-macos.dmg"
|
||||
name "Plezy"
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
<string>processing</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Videoversionen",
|
||||
"pipButton": "Bild-in-Bild Modus",
|
||||
"aspectRatioButton": "Seitenverhältnis",
|
||||
"ambientLighting": "Umgebungsbeleuchtung",
|
||||
"ambientLightingOn": "Umgebungsbeleuchtung aktivieren",
|
||||
"ambientLightingOff": "Umgebungsbeleuchtung deaktivieren",
|
||||
"fullscreenButton": "Vollbild aktivieren",
|
||||
"exitFullscreenButton": "Vollbild verlassen",
|
||||
"alwaysOnTopButton": "Immer im Vordergrund",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Video versions",
|
||||
"pipButton": "Picture-in-Picture mode",
|
||||
"aspectRatioButton": "Aspect ratio",
|
||||
"ambientLighting": "Ambient lighting",
|
||||
"ambientLightingOn": "Enable ambient lighting",
|
||||
"ambientLightingOff": "Disable ambient lighting",
|
||||
"fullscreenButton": "Enter fullscreen",
|
||||
"exitFullscreenButton": "Exit fullscreen",
|
||||
"alwaysOnTopButton": "Always on top",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Versiones de video",
|
||||
"pipButton": "Modo PiP (Imagen en Imagen)",
|
||||
"aspectRatioButton": "Relación de aspecto",
|
||||
"ambientLighting": "Iluminación ambiental",
|
||||
"ambientLightingOn": "Activar iluminación ambiental",
|
||||
"ambientLightingOff": "Desactivar iluminación ambiental",
|
||||
"fullscreenButton": "Entrar en pantalla completa",
|
||||
"exitFullscreenButton": "Salir de pantalla completa",
|
||||
"alwaysOnTopButton": "Siempre visible",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Versions vidéo",
|
||||
"pipButton": "Mode PiP (Picture-in-Picture)",
|
||||
"aspectRatioButton": "Format d'image",
|
||||
"ambientLighting": "Éclairage ambiant",
|
||||
"ambientLightingOn": "Activer l'éclairage ambiant",
|
||||
"ambientLightingOff": "Désactiver l'éclairage ambiant",
|
||||
"fullscreenButton": "Passer en mode plein écran",
|
||||
"exitFullscreenButton": "Quitter le mode plein écran",
|
||||
"alwaysOnTopButton": "Always on top",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Versioni video",
|
||||
"pipButton": "Modalità Picture-in-Picture",
|
||||
"aspectRatioButton": "Proporzioni",
|
||||
"ambientLighting": "Illuminazione ambientale",
|
||||
"ambientLightingOn": "Attiva illuminazione ambientale",
|
||||
"ambientLightingOff": "Disattiva illuminazione ambientale",
|
||||
"fullscreenButton": "Attiva schermo intero",
|
||||
"exitFullscreenButton": "Esci da schermo intero",
|
||||
"alwaysOnTopButton": "Sempre in primo piano",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "동영상 버전",
|
||||
"pipButton": "픽처 인 픽처 모드",
|
||||
"aspectRatioButton": "화면비율",
|
||||
"ambientLighting": "주변 조명",
|
||||
"ambientLightingOn": "주변 조명 켜기",
|
||||
"ambientLightingOff": "주변 조명 끄기",
|
||||
"fullscreenButton": "전체화면",
|
||||
"exitFullscreenButton": "전체화면 종료",
|
||||
"alwaysOnTopButton": "창 최상위 고정",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Videoversies",
|
||||
"pipButton": "Beeld-in-beeld modus",
|
||||
"aspectRatioButton": "Beeldverhouding",
|
||||
"ambientLighting": "Omgevingsverlichting",
|
||||
"ambientLightingOn": "Omgevingsverlichting inschakelen",
|
||||
"ambientLightingOff": "Omgevingsverlichting uitschakelen",
|
||||
"fullscreenButton": "Volledig scherm activeren",
|
||||
"exitFullscreenButton": "Volledig scherm verlaten",
|
||||
"alwaysOnTopButton": "Altijd bovenop",
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
/// To regenerate, run: `dart run slang`
|
||||
///
|
||||
/// Locales: 9
|
||||
/// Strings: 6642 (738 per locale)
|
||||
/// Strings: 6669 (741 per locale)
|
||||
///
|
||||
/// Built on 2026-02-16 at 00:20 UTC
|
||||
/// Built on 2026-02-18 at 03:36 UTC
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint, unused_import
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsDe implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => 'Videoversionen';
|
||||
@override String get pipButton => 'Bild-in-Bild Modus';
|
||||
@override String get aspectRatioButton => 'Seitenverhältnis';
|
||||
@override String get ambientLighting => 'Umgebungsbeleuchtung';
|
||||
@override String get ambientLightingOn => 'Umgebungsbeleuchtung aktivieren';
|
||||
@override String get ambientLightingOff => 'Umgebungsbeleuchtung deaktivieren';
|
||||
@override String get fullscreenButton => 'Vollbild aktivieren';
|
||||
@override String get exitFullscreenButton => 'Vollbild verlassen';
|
||||
@override String get alwaysOnTopButton => 'Immer im Vordergrund';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsDe {
|
||||
'videoControls.versionsButton' => 'Videoversionen',
|
||||
'videoControls.pipButton' => 'Bild-in-Bild Modus',
|
||||
'videoControls.aspectRatioButton' => 'Seitenverhältnis',
|
||||
'videoControls.ambientLighting' => 'Umgebungsbeleuchtung',
|
||||
'videoControls.ambientLightingOn' => 'Umgebungsbeleuchtung aktivieren',
|
||||
'videoControls.ambientLightingOff' => 'Umgebungsbeleuchtung deaktivieren',
|
||||
'videoControls.fullscreenButton' => 'Vollbild aktivieren',
|
||||
'videoControls.exitFullscreenButton' => 'Vollbild verlassen',
|
||||
'videoControls.alwaysOnTopButton' => 'Immer im Vordergrund',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsDe {
|
||||
'liveTv.overnight' => 'Nacht',
|
||||
'liveTv.morning' => 'Morgen',
|
||||
'liveTv.daytime' => 'Tagsüber',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Abend',
|
||||
'liveTv.lateNight' => 'Spätnacht',
|
||||
'liveTv.whatsOn' => 'Jetzt im TV',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Kanal ansehen',
|
||||
'downloads.title' => 'Downloads',
|
||||
'downloads.manage' => 'Verwalten',
|
||||
|
||||
@@ -1025,6 +1025,15 @@ class TranslationsVideoControlsEn {
|
||||
/// en: 'Aspect ratio'
|
||||
String get aspectRatioButton => 'Aspect ratio';
|
||||
|
||||
/// en: 'Ambient lighting'
|
||||
String get ambientLighting => 'Ambient lighting';
|
||||
|
||||
/// en: 'Enable ambient lighting'
|
||||
String get ambientLightingOn => 'Enable ambient lighting';
|
||||
|
||||
/// en: 'Disable ambient lighting'
|
||||
String get ambientLightingOff => 'Disable ambient lighting';
|
||||
|
||||
/// en: 'Enter fullscreen'
|
||||
String get fullscreenButton => 'Enter fullscreen';
|
||||
|
||||
@@ -3000,6 +3009,9 @@ extension on Translations {
|
||||
'videoControls.versionsButton' => 'Video versions',
|
||||
'videoControls.pipButton' => 'Picture-in-Picture mode',
|
||||
'videoControls.aspectRatioButton' => 'Aspect ratio',
|
||||
'videoControls.ambientLighting' => 'Ambient lighting',
|
||||
'videoControls.ambientLightingOn' => 'Enable ambient lighting',
|
||||
'videoControls.ambientLightingOff' => 'Disable ambient lighting',
|
||||
'videoControls.fullscreenButton' => 'Enter fullscreen',
|
||||
'videoControls.exitFullscreenButton' => 'Exit fullscreen',
|
||||
'videoControls.alwaysOnTopButton' => 'Always on top',
|
||||
@@ -3217,11 +3229,11 @@ extension on Translations {
|
||||
'liveTv.overnight' => 'Overnight',
|
||||
'liveTv.morning' => 'Morning',
|
||||
'liveTv.daytime' => 'Daytime',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Evening',
|
||||
'liveTv.lateNight' => 'Late Night',
|
||||
'liveTv.whatsOn' => 'What\'s On',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Watch Channel',
|
||||
'collections.title' => 'Collections',
|
||||
'collections.collection' => 'Collection',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsEs implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => 'Versiones de video';
|
||||
@override String get pipButton => 'Modo PiP (Imagen en Imagen)';
|
||||
@override String get aspectRatioButton => 'Relación de aspecto';
|
||||
@override String get ambientLighting => 'Iluminación ambiental';
|
||||
@override String get ambientLightingOn => 'Activar iluminación ambiental';
|
||||
@override String get ambientLightingOff => 'Desactivar iluminación ambiental';
|
||||
@override String get fullscreenButton => 'Entrar en pantalla completa';
|
||||
@override String get exitFullscreenButton => 'Salir de pantalla completa';
|
||||
@override String get alwaysOnTopButton => 'Siempre visible';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsEs {
|
||||
'videoControls.versionsButton' => 'Versiones de video',
|
||||
'videoControls.pipButton' => 'Modo PiP (Imagen en Imagen)',
|
||||
'videoControls.aspectRatioButton' => 'Relación de aspecto',
|
||||
'videoControls.ambientLighting' => 'Iluminación ambiental',
|
||||
'videoControls.ambientLightingOn' => 'Activar iluminación ambiental',
|
||||
'videoControls.ambientLightingOff' => 'Desactivar iluminación ambiental',
|
||||
'videoControls.fullscreenButton' => 'Entrar en pantalla completa',
|
||||
'videoControls.exitFullscreenButton' => 'Salir de pantalla completa',
|
||||
'videoControls.alwaysOnTopButton' => 'Siempre visible',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsEs {
|
||||
'liveTv.overnight' => 'Madrugada',
|
||||
'liveTv.morning' => 'Mañana',
|
||||
'liveTv.daytime' => 'Día',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Noche',
|
||||
'liveTv.lateNight' => 'Trasnoche',
|
||||
'liveTv.whatsOn' => 'En emisión',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Ver canal',
|
||||
'collections.title' => 'Colecciones',
|
||||
'collections.collection' => 'Colección',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsFr implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => 'Versions vidéo';
|
||||
@override String get pipButton => 'Mode PiP (Picture-in-Picture)';
|
||||
@override String get aspectRatioButton => 'Format d\'image';
|
||||
@override String get ambientLighting => 'Éclairage ambiant';
|
||||
@override String get ambientLightingOn => 'Activer l\'éclairage ambiant';
|
||||
@override String get ambientLightingOff => 'Désactiver l\'éclairage ambiant';
|
||||
@override String get fullscreenButton => 'Passer en mode plein écran';
|
||||
@override String get exitFullscreenButton => 'Quitter le mode plein écran';
|
||||
@override String get alwaysOnTopButton => 'Always on top';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsFr {
|
||||
'videoControls.versionsButton' => 'Versions vidéo',
|
||||
'videoControls.pipButton' => 'Mode PiP (Picture-in-Picture)',
|
||||
'videoControls.aspectRatioButton' => 'Format d\'image',
|
||||
'videoControls.ambientLighting' => 'Éclairage ambiant',
|
||||
'videoControls.ambientLightingOn' => 'Activer l\'éclairage ambiant',
|
||||
'videoControls.ambientLightingOff' => 'Désactiver l\'éclairage ambiant',
|
||||
'videoControls.fullscreenButton' => 'Passer en mode plein écran',
|
||||
'videoControls.exitFullscreenButton' => 'Quitter le mode plein écran',
|
||||
'videoControls.alwaysOnTopButton' => 'Always on top',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsFr {
|
||||
'liveTv.overnight' => 'Nuit',
|
||||
'liveTv.morning' => 'Matin',
|
||||
'liveTv.daytime' => 'Journée',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Soirée',
|
||||
'liveTv.lateNight' => 'Nuit tardive',
|
||||
'liveTv.whatsOn' => 'En ce moment',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Regarder la chaîne',
|
||||
'collections.title' => 'Collections',
|
||||
'collections.collection' => 'Collection',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsIt implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => 'Versioni video';
|
||||
@override String get pipButton => 'Modalità Picture-in-Picture';
|
||||
@override String get aspectRatioButton => 'Proporzioni';
|
||||
@override String get ambientLighting => 'Illuminazione ambientale';
|
||||
@override String get ambientLightingOn => 'Attiva illuminazione ambientale';
|
||||
@override String get ambientLightingOff => 'Disattiva illuminazione ambientale';
|
||||
@override String get fullscreenButton => 'Attiva schermo intero';
|
||||
@override String get exitFullscreenButton => 'Esci da schermo intero';
|
||||
@override String get alwaysOnTopButton => 'Sempre in primo piano';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsIt {
|
||||
'videoControls.versionsButton' => 'Versioni video',
|
||||
'videoControls.pipButton' => 'Modalità Picture-in-Picture',
|
||||
'videoControls.aspectRatioButton' => 'Proporzioni',
|
||||
'videoControls.ambientLighting' => 'Illuminazione ambientale',
|
||||
'videoControls.ambientLightingOn' => 'Attiva illuminazione ambientale',
|
||||
'videoControls.ambientLightingOff' => 'Disattiva illuminazione ambientale',
|
||||
'videoControls.fullscreenButton' => 'Attiva schermo intero',
|
||||
'videoControls.exitFullscreenButton' => 'Esci da schermo intero',
|
||||
'videoControls.alwaysOnTopButton' => 'Sempre in primo piano',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsIt {
|
||||
'liveTv.overnight' => 'Notte',
|
||||
'liveTv.morning' => 'Mattina',
|
||||
'liveTv.daytime' => 'Giorno',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Sera',
|
||||
'liveTv.lateNight' => 'Notte tarda',
|
||||
'liveTv.whatsOn' => 'In onda ora',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Guarda canale',
|
||||
'downloads.title' => 'Download',
|
||||
'downloads.manage' => 'Gestisci',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsKo implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => '동영상 버전';
|
||||
@override String get pipButton => '픽처 인 픽처 모드';
|
||||
@override String get aspectRatioButton => '화면비율';
|
||||
@override String get ambientLighting => '주변 조명';
|
||||
@override String get ambientLightingOn => '주변 조명 켜기';
|
||||
@override String get ambientLightingOff => '주변 조명 끄기';
|
||||
@override String get fullscreenButton => '전체화면';
|
||||
@override String get exitFullscreenButton => '전체화면 종료';
|
||||
@override String get alwaysOnTopButton => '창 최상위 고정';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsKo {
|
||||
'videoControls.versionsButton' => '동영상 버전',
|
||||
'videoControls.pipButton' => '픽처 인 픽처 모드',
|
||||
'videoControls.aspectRatioButton' => '화면비율',
|
||||
'videoControls.ambientLighting' => '주변 조명',
|
||||
'videoControls.ambientLightingOn' => '주변 조명 켜기',
|
||||
'videoControls.ambientLightingOff' => '주변 조명 끄기',
|
||||
'videoControls.fullscreenButton' => '전체화면',
|
||||
'videoControls.exitFullscreenButton' => '전체화면 종료',
|
||||
'videoControls.alwaysOnTopButton' => '창 최상위 고정',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsKo {
|
||||
'liveTv.overnight' => '심야',
|
||||
'liveTv.morning' => '아침',
|
||||
'liveTv.daytime' => '낮',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => '저녁',
|
||||
'liveTv.lateNight' => '심야 방송',
|
||||
'liveTv.whatsOn' => '지금 방송 중',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => '채널 시청',
|
||||
'collections.title' => '컬렉션',
|
||||
'collections.collection' => '컬렉션',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsNl implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => 'Videoversies';
|
||||
@override String get pipButton => 'Beeld-in-beeld modus';
|
||||
@override String get aspectRatioButton => 'Beeldverhouding';
|
||||
@override String get ambientLighting => 'Omgevingsverlichting';
|
||||
@override String get ambientLightingOn => 'Omgevingsverlichting inschakelen';
|
||||
@override String get ambientLightingOff => 'Omgevingsverlichting uitschakelen';
|
||||
@override String get fullscreenButton => 'Volledig scherm activeren';
|
||||
@override String get exitFullscreenButton => 'Volledig scherm verlaten';
|
||||
@override String get alwaysOnTopButton => 'Altijd bovenop';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsNl {
|
||||
'videoControls.versionsButton' => 'Videoversies',
|
||||
'videoControls.pipButton' => 'Beeld-in-beeld modus',
|
||||
'videoControls.aspectRatioButton' => 'Beeldverhouding',
|
||||
'videoControls.ambientLighting' => 'Omgevingsverlichting',
|
||||
'videoControls.ambientLightingOn' => 'Omgevingsverlichting inschakelen',
|
||||
'videoControls.ambientLightingOff' => 'Omgevingsverlichting uitschakelen',
|
||||
'videoControls.fullscreenButton' => 'Volledig scherm activeren',
|
||||
'videoControls.exitFullscreenButton' => 'Volledig scherm verlaten',
|
||||
'videoControls.alwaysOnTopButton' => 'Altijd bovenop',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsNl {
|
||||
'liveTv.overnight' => 'Nacht',
|
||||
'liveTv.morning' => 'Ochtend',
|
||||
'liveTv.daytime' => 'Overdag',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Avond',
|
||||
'liveTv.lateNight' => 'Late avond',
|
||||
'liveTv.whatsOn' => 'Nu op TV',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Kanaal bekijken',
|
||||
'downloads.title' => 'Downloads',
|
||||
'downloads.manage' => 'Beheren',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsSv implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => 'Videoversioner';
|
||||
@override String get pipButton => 'Bild-i-bild läge';
|
||||
@override String get aspectRatioButton => 'Bildförhållande';
|
||||
@override String get ambientLighting => 'Ambientbelysning';
|
||||
@override String get ambientLightingOn => 'Aktivera ambientbelysning';
|
||||
@override String get ambientLightingOff => 'Inaktivera ambientbelysning';
|
||||
@override String get fullscreenButton => 'Aktivera helskärm';
|
||||
@override String get exitFullscreenButton => 'Avsluta helskärm';
|
||||
@override String get alwaysOnTopButton => 'Alltid överst';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsSv {
|
||||
'videoControls.versionsButton' => 'Videoversioner',
|
||||
'videoControls.pipButton' => 'Bild-i-bild läge',
|
||||
'videoControls.aspectRatioButton' => 'Bildförhållande',
|
||||
'videoControls.ambientLighting' => 'Ambientbelysning',
|
||||
'videoControls.ambientLightingOn' => 'Aktivera ambientbelysning',
|
||||
'videoControls.ambientLightingOff' => 'Inaktivera ambientbelysning',
|
||||
'videoControls.fullscreenButton' => 'Aktivera helskärm',
|
||||
'videoControls.exitFullscreenButton' => 'Avsluta helskärm',
|
||||
'videoControls.alwaysOnTopButton' => 'Alltid överst',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsSv {
|
||||
'liveTv.overnight' => 'Natt',
|
||||
'liveTv.morning' => 'Morgon',
|
||||
'liveTv.daytime' => 'Dagtid',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Kväll',
|
||||
'liveTv.lateNight' => 'Sen kväll',
|
||||
'liveTv.whatsOn' => 'På TV nu',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => 'Titta på kanal',
|
||||
'downloads.title' => 'Nedladdningar',
|
||||
'downloads.manage' => 'Hantera',
|
||||
|
||||
@@ -474,6 +474,9 @@ class _TranslationsVideoControlsZh implements TranslationsVideoControlsEn {
|
||||
@override String get versionsButton => '视频版本';
|
||||
@override String get pipButton => '画中画模式';
|
||||
@override String get aspectRatioButton => '宽高比';
|
||||
@override String get ambientLighting => '氛围灯光';
|
||||
@override String get ambientLightingOn => '开启氛围灯光';
|
||||
@override String get ambientLightingOff => '关闭氛围灯光';
|
||||
@override String get fullscreenButton => '进入全屏';
|
||||
@override String get exitFullscreenButton => '退出全屏';
|
||||
@override String get alwaysOnTopButton => '置顶窗口';
|
||||
@@ -1517,6 +1520,9 @@ extension on TranslationsZh {
|
||||
'videoControls.versionsButton' => '视频版本',
|
||||
'videoControls.pipButton' => '画中画模式',
|
||||
'videoControls.aspectRatioButton' => '宽高比',
|
||||
'videoControls.ambientLighting' => '氛围灯光',
|
||||
'videoControls.ambientLightingOn' => '开启氛围灯光',
|
||||
'videoControls.ambientLightingOff' => '关闭氛围灯光',
|
||||
'videoControls.fullscreenButton' => '进入全屏',
|
||||
'videoControls.exitFullscreenButton' => '退出全屏',
|
||||
'videoControls.alwaysOnTopButton' => '置顶窗口',
|
||||
@@ -1734,11 +1740,11 @@ extension on TranslationsZh {
|
||||
'liveTv.overnight' => '凌晨',
|
||||
'liveTv.morning' => '上午',
|
||||
'liveTv.daytime' => '白天',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => '晚上',
|
||||
'liveTv.lateNight' => '深夜',
|
||||
'liveTv.whatsOn' => '正在播出',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.watchChannel' => '观看频道',
|
||||
'downloads.title' => '下载',
|
||||
'downloads.manage' => '管理',
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "Videoversioner",
|
||||
"pipButton": "Bild-i-bild läge",
|
||||
"aspectRatioButton": "Bildförhållande",
|
||||
"ambientLighting": "Ambientbelysning",
|
||||
"ambientLightingOn": "Aktivera ambientbelysning",
|
||||
"ambientLightingOff": "Inaktivera ambientbelysning",
|
||||
"fullscreenButton": "Aktivera helskärm",
|
||||
"exitFullscreenButton": "Avsluta helskärm",
|
||||
"alwaysOnTopButton": "Alltid överst",
|
||||
|
||||
@@ -320,6 +320,9 @@
|
||||
"versionsButton": "视频版本",
|
||||
"pipButton": "画中画模式",
|
||||
"aspectRatioButton": "宽高比",
|
||||
"ambientLighting": "氛围灯光",
|
||||
"ambientLightingOn": "开启氛围灯光",
|
||||
"ambientLightingOff": "关闭氛围灯光",
|
||||
"fullscreenButton": "进入全屏",
|
||||
"exitFullscreenButton": "退出全屏",
|
||||
"alwaysOnTopButton": "置顶窗口",
|
||||
|
||||
@@ -382,6 +382,13 @@ class PlexMetadata with MultiServerFields {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Returns true if this item has started but not finished playback
|
||||
/// Only applicable for individual items (movies, episodes)
|
||||
bool get hasActiveProgress {
|
||||
if (duration == null || viewOffset == null) return false;
|
||||
return viewOffset! > 0 && viewOffset! < duration!;
|
||||
}
|
||||
|
||||
// Helper to determine if content is watched
|
||||
bool get isWatched {
|
||||
// For series/seasons, check if all episodes are watched
|
||||
|
||||
@@ -2,11 +2,8 @@ import '../player_native.dart';
|
||||
|
||||
/// Linux implementation of [Player].
|
||||
///
|
||||
/// Uses libmpv with OpenGL rendering via GtkGLArea.
|
||||
/// The mpv video is rendered to a GtkGLArea positioned behind
|
||||
/// the Flutter view using a GtkOverlay, with transparent regions
|
||||
/// in the Flutter UI allowing the video to show through.
|
||||
/// Uses libmpv with FlTextureGL — video is rendered to an offscreen FBO
|
||||
/// and composited GPU-side via Flutter's Texture widget.
|
||||
class PlayerLinux extends PlayerNative {
|
||||
@override
|
||||
int? get textureId => null; // Uses GtkGLArea, not Flutter texture
|
||||
// textureId is set during initialize() via PlayerNative
|
||||
}
|
||||
|
||||
@@ -142,6 +142,12 @@ abstract class Player {
|
||||
/// Get an MPV property value by name.
|
||||
Future<String?> getProperty(String name);
|
||||
|
||||
/// Set the native MPV log message level (e.g., "warn", "v", "debug").
|
||||
///
|
||||
/// This controls the volume of log messages sent from the native player
|
||||
/// over the event channel. Use "warn" in production and "v" for debugging.
|
||||
Future<void> setLogLevel(String level);
|
||||
|
||||
/// Execute a raw MPV command.
|
||||
///
|
||||
/// [args] - Command and arguments as a list of strings.
|
||||
|
||||
@@ -109,7 +109,7 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
|
||||
void _handleEvent(dynamic event) {
|
||||
if (event is List && event.length == 2) {
|
||||
final name = _propIdToName[event[0]];
|
||||
final name = _propIdToName[event[0] as int];
|
||||
if (name != null) {
|
||||
handlePropertyChange(name, event[1]);
|
||||
}
|
||||
@@ -217,6 +217,41 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
case 'sid':
|
||||
updateSelectedSubtitleTrack(value);
|
||||
break;
|
||||
|
||||
case 'audio-device-list':
|
||||
List? deviceList;
|
||||
if (value is List) {
|
||||
deviceList = value;
|
||||
} else if (value is String && value.isNotEmpty) {
|
||||
try {
|
||||
final parsed = jsonDecode(value);
|
||||
if (parsed is List) deviceList = parsed;
|
||||
} catch (_) {}
|
||||
}
|
||||
if (deviceList != null) {
|
||||
final devices = deviceList
|
||||
.whereType<Map>()
|
||||
.map((d) => AudioDevice(
|
||||
name: d['name'] as String? ?? '',
|
||||
description: d['description'] as String? ?? '',
|
||||
))
|
||||
.toList();
|
||||
_state = _state.copyWith(audioDevices: devices);
|
||||
audioDevicesController.add(devices);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'audio-device':
|
||||
if (value is String && value.isNotEmpty) {
|
||||
final device = _state.audioDevices.cast<AudioDevice?>().firstWhere(
|
||||
(d) => d?.name == value,
|
||||
orElse: () => AudioDevice(name: value),
|
||||
) ??
|
||||
AudioDevice(name: value);
|
||||
_state = _state.copyWith(audioDevice: device);
|
||||
audioDeviceController.add(device);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,6 +436,10 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
// ignore: no-empty-block - base no-op, overridden by platform subclasses
|
||||
Future<void> setAudioPassthrough(bool enabled) async {}
|
||||
|
||||
@override
|
||||
// ignore: no-empty-block - base no-op, overridden by platform subclasses
|
||||
Future<void> setLogLevel(String level) async {}
|
||||
|
||||
// ============================================
|
||||
// Lifecycle
|
||||
// ============================================
|
||||
|
||||
@@ -6,9 +6,15 @@ import '../font_loader.dart';
|
||||
import '../models.dart';
|
||||
import 'player_base.dart';
|
||||
|
||||
/// Shared native implementation of [Player] for iOS, macOS, and Android (MPV fallback).
|
||||
/// Uses MPVKit via platform channels with Metal rendering (Apple) or native window (Android).
|
||||
/// Shared native implementation of [Player] for iOS, macOS, Android (MPV fallback), and Linux.
|
||||
/// Uses MPVKit via platform channels with Metal rendering (Apple), native window (Android),
|
||||
/// or FlTextureGL (Linux).
|
||||
class PlayerNative extends PlayerBase {
|
||||
int? _textureIdValue;
|
||||
|
||||
@override
|
||||
int? get textureId => _textureIdValue;
|
||||
|
||||
static const _methodChannel = MethodChannel('com.plezy/mpv_player');
|
||||
static const _eventChannel = EventChannel('com.plezy/mpv_player/events');
|
||||
|
||||
@@ -32,8 +38,14 @@ class PlayerNative extends PlayerBase {
|
||||
if (initialized) return;
|
||||
|
||||
try {
|
||||
final result = await methodChannel.invokeMethod<bool>('initialize');
|
||||
initialized = result == true;
|
||||
final result = await methodChannel.invokeMethod<Object>('initialize');
|
||||
if (result is int) {
|
||||
// Linux: initialize returns the texture ID
|
||||
_textureIdValue = result;
|
||||
initialized = true;
|
||||
} else {
|
||||
initialized = result == true;
|
||||
}
|
||||
if (!initialized) {
|
||||
throw Exception('Failed to initialize player');
|
||||
}
|
||||
@@ -52,6 +64,8 @@ class PlayerNative extends PlayerBase {
|
||||
await observeProperty('speed', 'double');
|
||||
await observeProperty('aid', 'string');
|
||||
await observeProperty('sid', 'string');
|
||||
await observeProperty('audio-device-list', (Platform.isAndroid || Platform.isWindows) ? 'string' : 'node');
|
||||
await observeProperty('audio-device', 'string');
|
||||
} catch (e) {
|
||||
errorController.add('Initialization failed: $e');
|
||||
rethrow;
|
||||
@@ -228,6 +242,17 @@ class PlayerNative extends PlayerBase {
|
||||
await methodChannel.invokeMethod('command', {'args': args});
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Log Level
|
||||
// ============================================
|
||||
|
||||
@override
|
||||
Future<void> setLogLevel(String level) async {
|
||||
checkDisposed();
|
||||
await _ensureInitialized();
|
||||
await methodChannel.invokeMethod('setLogLevel', {'level': level});
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Passthrough
|
||||
// ============================================
|
||||
|
||||
+8
-1
@@ -74,7 +74,14 @@ class _VideoState extends State<Video> {
|
||||
}
|
||||
|
||||
Widget _buildVideoSurface() {
|
||||
// For players that support video rect positioning (Windows, Linux),
|
||||
// For players that use Flutter's texture pipeline (Linux FlTextureGL),
|
||||
// render directly via the Texture widget.
|
||||
final textureId = widget.player.textureId;
|
||||
if (textureId != null) {
|
||||
return Texture(textureId: textureId);
|
||||
}
|
||||
|
||||
// For players that support video rect positioning (Windows),
|
||||
// communicate layout changes to the native side.
|
||||
if (widget.player is VideoRectSupport) {
|
||||
return LayoutBuilder(
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../focus/dpad_navigator.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../../models/livetv_channel.dart';
|
||||
import '../../models/livetv_dvr.dart';
|
||||
import '../../mixins/refreshable.dart';
|
||||
import '../../mixins/tab_navigation_mixin.dart';
|
||||
import '../../providers/multi_server_provider.dart';
|
||||
import '../../utils/app_logger.dart';
|
||||
@@ -23,7 +24,9 @@ class LiveTvScreen extends StatefulWidget {
|
||||
State<LiveTvScreen> createState() => _LiveTvScreenState();
|
||||
}
|
||||
|
||||
class _LiveTvScreenState extends State<LiveTvScreen> with SingleTickerProviderStateMixin, TabNavigationMixin {
|
||||
class _LiveTvScreenState extends State<LiveTvScreen>
|
||||
with SingleTickerProviderStateMixin, TabNavigationMixin
|
||||
implements FocusableTab {
|
||||
final _guideTabFocusNode = FocusNode(debugLabel: 'tab_chip_guide');
|
||||
final _whatsOnTabFocusNode = FocusNode(debugLabel: 'tab_chip_whats_on');
|
||||
final _guideTabKey = GlobalKey<GuideTabState>();
|
||||
@@ -216,6 +219,9 @@ class _LiveTvScreenState extends State<LiveTvScreen> with SingleTickerProviderSt
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void focusActiveTabIfReady() => _focusCurrentTab();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Action button key handlers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -375,15 +375,21 @@ class GuideTabState extends State<GuideTab> {
|
||||
});
|
||||
_scrollToProgramTime(program);
|
||||
}
|
||||
} else {
|
||||
// Already in program column — move to next program
|
||||
_navigateToAdjacentProgram(_gridChannelIndex, forward: true);
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (key.isLeftKey) {
|
||||
if (_gridColumn == 1) {
|
||||
setState(() {
|
||||
_gridColumn = 0;
|
||||
_focusedProgram = null;
|
||||
});
|
||||
// Try moving to previous program; if at first program, go back to channel column
|
||||
if (!_navigateToAdjacentProgram(_gridChannelIndex, forward: false)) {
|
||||
setState(() {
|
||||
_gridColumn = 0;
|
||||
_focusedProgram = null;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
widget.onBack?.call();
|
||||
}
|
||||
@@ -424,6 +430,27 @@ class GuideTabState extends State<GuideTab> {
|
||||
return programs.firstOrNull;
|
||||
}
|
||||
|
||||
/// Navigate to the next or previous program on the same channel.
|
||||
/// Returns true if navigation succeeded, false if at the boundary.
|
||||
bool _navigateToAdjacentProgram(int channelIndex, {required bool forward}) {
|
||||
if (channelIndex < 0 || channelIndex >= widget.channels.length) return false;
|
||||
final channel = widget.channels[channelIndex];
|
||||
final programs = _getProgramsForChannel(channel);
|
||||
if (programs.isEmpty || _focusedProgram == null) return false;
|
||||
|
||||
final currentIndex = programs.indexWhere((p) => identical(p, _focusedProgram));
|
||||
if (currentIndex < 0) return false;
|
||||
|
||||
final nextIndex = forward ? currentIndex + 1 : currentIndex - 1;
|
||||
if (nextIndex < 0 || nextIndex >= programs.length) return false;
|
||||
|
||||
setState(() {
|
||||
_focusedProgram = programs[nextIndex];
|
||||
});
|
||||
_scrollToProgramTime(_focusedProgram);
|
||||
return true;
|
||||
}
|
||||
|
||||
void _scrollToChannel(int index) {
|
||||
if (!_gridVerticalController.hasClients) return;
|
||||
final targetTop = index * _rowHeight;
|
||||
@@ -440,9 +467,13 @@ class GuideTabState extends State<GuideTab> {
|
||||
|
||||
if (newOffset != null) {
|
||||
final clamped = newOffset.clamp(0.0, _gridVerticalController.position.maxScrollExtent);
|
||||
_gridVerticalController.jumpTo(clamped);
|
||||
_gridVerticalController.animateTo(clamped, duration: const Duration(milliseconds: 150), curve: Curves.easeOut);
|
||||
if (_channelVerticalController.hasClients) {
|
||||
_channelVerticalController.jumpTo(clamped.clamp(0.0, _channelVerticalController.position.maxScrollExtent));
|
||||
_channelVerticalController.animateTo(
|
||||
clamped.clamp(0.0, _channelVerticalController.position.maxScrollExtent),
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,6 +671,15 @@ class _MainScreenState extends State<MainScreen> with RouteAware, WindowListener
|
||||
}
|
||||
});
|
||||
}
|
||||
// When content regains focus while on Live TV, focus the active guide/whats-on tab
|
||||
final liveTvIndex = NavigationTab.indexFor(NavigationTabId.liveTv, isOffline: _isOffline, hasLiveTv: _hasLiveTv);
|
||||
if (_currentIndex == liveTvIndex && liveTvIndex >= 0) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_liveTvKey.currentState case final FocusableTab focusable) {
|
||||
focusable.focusActiveTabIfReady();
|
||||
}
|
||||
});
|
||||
}
|
||||
// When content regains focus while on Settings, restore focus to last focused setting
|
||||
final settingsIndex = NavigationTab.indexFor(
|
||||
NavigationTabId.settings,
|
||||
@@ -876,6 +885,13 @@ class _MainScreenState extends State<MainScreen> with RouteAware, WindowListener
|
||||
focusable.focusActiveTabIfReady();
|
||||
}
|
||||
}
|
||||
// Ensure the Live TV screen applies focus when brought into view
|
||||
final liveTvIdx = NavigationTab.indexFor(NavigationTabId.liveTv, isOffline: _isOffline, hasLiveTv: _hasLiveTv);
|
||||
if (index == liveTvIdx && liveTvIdx >= 0 && previousIndex != liveTvIdx) {
|
||||
if (_liveTvKey.currentState case final FocusableTab focusable) {
|
||||
focusable.focusActiveTabIfReady();
|
||||
}
|
||||
}
|
||||
// Focus search input when selecting Search tab
|
||||
if (NavigationTab.isTabAtIndex(NavigationTabId.search, index, isOffline: _isOffline, hasLiveTv: _hasLiveTv)) {
|
||||
if (_searchKey.currentState case final SearchInputFocusable searchable) {
|
||||
|
||||
@@ -98,6 +98,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
late final FocusNode _castFocusNode;
|
||||
final ScrollController _castScrollController = ScrollController();
|
||||
final _castSectionKey = GlobalKey();
|
||||
final _seasonsSectionKey = GlobalKey();
|
||||
|
||||
String _toGlobalKey(String ratingKey, {String? serverId}) =>
|
||||
'${serverId ?? widget.metadata.serverId ?? ''}:$ratingKey';
|
||||
@@ -1039,19 +1040,19 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
|
||||
final metadata = _fullMetadata ?? widget.metadata;
|
||||
|
||||
// For shows, go to seasons first
|
||||
if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// For movies (or shows with no seasons): overview → cast → extras
|
||||
// DOWN order: overview → seasons → cast → extras
|
||||
if (metadata.summary != null) {
|
||||
_overviewFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_overviewSectionKey);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_seasonsSectionKey);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
if (metadata.role != null && metadata.role!.isNotEmpty) {
|
||||
_castFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_castSectionKey);
|
||||
@@ -1145,20 +1146,23 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// UP: scroll to top and focus play button
|
||||
// UP: overview → play button
|
||||
if (key.isUpKey) {
|
||||
_scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
|
||||
_playButtonFocusNode.requestFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// DOWN: overview → cast → extras (first that exists)
|
||||
if (key.isDownKey) {
|
||||
final metadata = _fullMetadata ?? widget.metadata;
|
||||
if (metadata.summary != null) {
|
||||
_overviewFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_overviewSectionKey);
|
||||
} else if (metadata.role != null && metadata.role!.isNotEmpty) {
|
||||
} else {
|
||||
_scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
|
||||
_playButtonFocusNode.requestFocus();
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// DOWN: cast → extras
|
||||
if (key.isDownKey) {
|
||||
final metadata = _fullMetadata ?? widget.metadata;
|
||||
if (metadata.role != null && metadata.role!.isNotEmpty) {
|
||||
_castFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_castSectionKey);
|
||||
} else if (_extras != null && _extras!.isNotEmpty) {
|
||||
@@ -1179,20 +1183,19 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
|
||||
final metadata = _fullMetadata ?? widget.metadata;
|
||||
|
||||
// UP: seasons (if show) or play button
|
||||
// UP: always play button (overview is directly below play)
|
||||
if (key.isUpKey) {
|
||||
if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
} else {
|
||||
_scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
|
||||
_playButtonFocusNode.requestFocus();
|
||||
}
|
||||
_scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
|
||||
_playButtonFocusNode.requestFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// DOWN: cast → extras → consume
|
||||
// DOWN: seasons (if show) → cast → extras
|
||||
if (key.isDownKey) {
|
||||
if (metadata.role != null && metadata.role!.isNotEmpty) {
|
||||
if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_seasonsSectionKey);
|
||||
} else if (metadata.role != null && metadata.role!.isNotEmpty) {
|
||||
_castFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_castSectionKey);
|
||||
} else if (_extras != null && _extras!.isNotEmpty) {
|
||||
@@ -1330,17 +1333,18 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// UP: cast → overview → seasons → play button (first that exists)
|
||||
// UP: cast → seasons (if show) → overview → play button
|
||||
if (key.isUpKey) {
|
||||
final metadata = _fullMetadata ?? widget.metadata;
|
||||
if (metadata.role != null && metadata.role!.isNotEmpty) {
|
||||
_castFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_castSectionKey);
|
||||
} else if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_seasonsSectionKey);
|
||||
} else if (metadata.summary != null) {
|
||||
_overviewFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_overviewSectionKey);
|
||||
} else if (_seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
} else {
|
||||
_scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
|
||||
_playButtonFocusNode.requestFocus();
|
||||
@@ -1383,13 +1387,14 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
// UP: overview → seasons (if show) → play button
|
||||
// UP: seasons (if show) → overview → play button
|
||||
if (key.isUpKey) {
|
||||
if (metadata.summary != null) {
|
||||
if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_seasonsSectionKey);
|
||||
} else if (metadata.summary != null) {
|
||||
_overviewFocusNode.requestFocus();
|
||||
_scrollSectionIntoView(_overviewSectionKey);
|
||||
} else if (metadata.isShow && _seasons.isNotEmpty) {
|
||||
_seasonsFocusNode.requestFocus();
|
||||
} else {
|
||||
_scrollController.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.easeOut);
|
||||
_playButtonFocusNode.requestFocus();
|
||||
@@ -1960,6 +1965,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
// Seasons (for TV shows)
|
||||
if (isShow) ...[
|
||||
Text(
|
||||
key: _seasonsSectionKey,
|
||||
t.discover.seasons,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:material_symbols_icons/symbols.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../../models/external_player_models.dart';
|
||||
import '../../services/settings_service.dart';
|
||||
import '../../focus/key_event_utils.dart';
|
||||
import '../../widgets/desktop_app_bar.dart';
|
||||
|
||||
class ExternalPlayerScreen extends StatefulWidget {
|
||||
@@ -45,64 +46,72 @@ class _ExternalPlayerScreenState extends State<ExternalPlayerScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: const Scaffold(body: Center(child: CircularProgressIndicator())),
|
||||
);
|
||||
}
|
||||
|
||||
final knownPlayers = KnownPlayers.getForCurrentPlatform();
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(title: Text(t.externalPlayer.title), pinned: true),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Card(
|
||||
child: SwitchListTile(
|
||||
secondary: const AppIcon(Symbols.open_in_new_rounded, fill: 1),
|
||||
title: Text(t.externalPlayer.useExternalPlayer),
|
||||
subtitle: Text(t.externalPlayer.useExternalPlayerDescription),
|
||||
value: _useExternalPlayer,
|
||||
onChanged: (value) async {
|
||||
setState(() => _useExternalPlayer = value);
|
||||
await _settingsService.setUseExternalPlayer(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (_useExternalPlayer) ...[
|
||||
const SizedBox(height: 16),
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(title: Text(t.externalPlayer.title), pinned: true),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
t.externalPlayer.selectPlayer,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
// Known players
|
||||
...knownPlayers.map((player) => _buildPlayerTile(player)),
|
||||
// Custom players
|
||||
if (_customPlayers.isNotEmpty) const Divider(),
|
||||
..._customPlayers.map((player) => _buildPlayerTile(player, isCustom: true)),
|
||||
// Add custom player button
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const AppIcon(Symbols.add_rounded, fill: 1),
|
||||
title: Text(t.externalPlayer.addCustomPlayer),
|
||||
onTap: _showAddCustomPlayerDialog,
|
||||
),
|
||||
],
|
||||
child: SwitchListTile(
|
||||
secondary: const AppIcon(Symbols.open_in_new_rounded, fill: 1),
|
||||
title: Text(t.externalPlayer.useExternalPlayer),
|
||||
subtitle: Text(t.externalPlayer.useExternalPlayerDescription),
|
||||
value: _useExternalPlayer,
|
||||
onChanged: (value) async {
|
||||
setState(() => _useExternalPlayer = value);
|
||||
await _settingsService.setUseExternalPlayer(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
]),
|
||||
if (_useExternalPlayer) ...[
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
t.externalPlayer.selectPlayer,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
// Known players
|
||||
...knownPlayers.map((player) => _buildPlayerTile(player)),
|
||||
// Custom players
|
||||
if (_customPlayers.isNotEmpty) const Divider(),
|
||||
..._customPlayers.map((player) => _buildPlayerTile(player, isCustom: true)),
|
||||
// Add custom player button
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const AppIcon(Symbols.add_rounded, fill: 1),
|
||||
title: Text(t.externalPlayer.addCustomPlayer),
|
||||
onTap: _showAddCustomPlayerDialog,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:logger/logger.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../../utils/app_logger.dart';
|
||||
import '../../utils/snackbar_helper.dart';
|
||||
import '../../focus/key_event_utils.dart';
|
||||
import '../../widgets/desktop_app_bar.dart';
|
||||
|
||||
class LogsScreen extends StatefulWidget {
|
||||
@@ -165,53 +166,57 @@ class _LogsScreenState extends State<LogsScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(
|
||||
title: Text(t.screens.logs),
|
||||
pinned: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.refresh_rounded, fill: 1),
|
||||
onPressed: _loadLogs,
|
||||
tooltip: t.common.refresh,
|
||||
),
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.upload_rounded, fill: 1),
|
||||
onPressed: _logs.isNotEmpty ? _uploadLogs : null,
|
||||
tooltip: t.logs.uploadLogs,
|
||||
),
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.content_copy_rounded, fill: 1),
|
||||
onPressed: _logs.isNotEmpty ? _copyAllLogs : null,
|
||||
tooltip: t.logs.copyLogs,
|
||||
),
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.delete_outline_rounded, fill: 1),
|
||||
onPressed: _logs.isNotEmpty ? _clearLogs : null,
|
||||
tooltip: t.logs.clearLogs,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_logs.isEmpty)
|
||||
SliverFillRemaining(child: Center(child: Text(t.messages.noLogsAvailable)))
|
||||
else
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final log = _logs[index];
|
||||
return _LogEntryCard(
|
||||
log: log,
|
||||
formatTime: _formatTime,
|
||||
levelColor: _getLevelColor(log.level),
|
||||
levelIcon: _getLevelIcon(log.level),
|
||||
);
|
||||
}, childCount: _logs.length),
|
||||
),
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(
|
||||
title: Text(t.screens.logs),
|
||||
pinned: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.refresh_rounded, fill: 1),
|
||||
onPressed: _loadLogs,
|
||||
tooltip: t.common.refresh,
|
||||
),
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.upload_rounded, fill: 1),
|
||||
onPressed: _logs.isNotEmpty ? _uploadLogs : null,
|
||||
tooltip: t.logs.uploadLogs,
|
||||
),
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.content_copy_rounded, fill: 1),
|
||||
onPressed: _logs.isNotEmpty ? _copyAllLogs : null,
|
||||
tooltip: t.logs.copyLogs,
|
||||
),
|
||||
IconButton(
|
||||
icon: const AppIcon(Symbols.delete_outline_rounded, fill: 1),
|
||||
onPressed: _logs.isNotEmpty ? _clearLogs : null,
|
||||
tooltip: t.logs.clearLogs,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
if (_logs.isEmpty)
|
||||
SliverFillRemaining(child: Center(child: Text(t.messages.noLogsAvailable)))
|
||||
else
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final log = _logs[index];
|
||||
return _LogEntryCard(
|
||||
log: log,
|
||||
formatTime: _formatTime,
|
||||
levelColor: _getLevelColor(log.level),
|
||||
levelIcon: _getLevelIcon(log.level),
|
||||
);
|
||||
}, childCount: _logs.length),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../models/mpv_config_models.dart';
|
||||
import '../../utils/dialogs.dart';
|
||||
import '../../utils/snackbar_helper.dart';
|
||||
import '../../services/settings_service.dart';
|
||||
import '../../focus/key_event_utils.dart';
|
||||
import '../../widgets/desktop_app_bar.dart';
|
||||
|
||||
class MpvConfigScreen extends StatefulWidget {
|
||||
@@ -236,25 +237,33 @@ class _MpvConfigScreenState extends State<MpvConfigScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: const Scaffold(body: Center(child: CircularProgressIndicator())),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(title: Text(t.screens.mpvConfig), pinned: true),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
_buildPresetsCard(),
|
||||
const SizedBox(height: 16),
|
||||
_buildEntriesCard(),
|
||||
const SizedBox(height: 24),
|
||||
]),
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(title: Text(t.screens.mpvConfig), pinned: true),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
_buildPresetsCard(),
|
||||
const SizedBox(height: 16),
|
||||
_buildEntriesCard(),
|
||||
const SizedBox(height: 24),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../focus/focus_memory_tracker.dart';
|
||||
import '../../focus/input_mode_tracker.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../main_screen.dart';
|
||||
import '../../mixins/refreshable.dart';
|
||||
@@ -147,7 +148,9 @@ class _SettingsScreenState extends State<SettingsScreen> with FocusableTab {
|
||||
|
||||
@override
|
||||
void focusActiveTabIfReady() {
|
||||
_focusTracker.restoreFocus(fallbackKey: _kTheme);
|
||||
if (InputModeTracker.isKeyboardMode(context)) {
|
||||
_focusTracker.restoreFocus(fallbackKey: _kTheme);
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigate focus to the sidebar
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flex_color_picker/flex_color_picker.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../../services/settings_service.dart';
|
||||
import '../../utils/platform_detector.dart';
|
||||
import '../../focus/key_event_utils.dart';
|
||||
import '../../widgets/desktop_app_bar.dart';
|
||||
import '../../widgets/tv_color_picker.dart';
|
||||
import '../../widgets/tv_number_spinner.dart';
|
||||
@@ -282,18 +283,26 @@ class _SubtitleStylingScreenState extends State<SubtitleStylingScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
return const Scaffold(body: Center(child: CircularProgressIndicator()));
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: const Scaffold(body: Center(child: CircularProgressIndicator())),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(title: Text(t.screens.subtitleStyling), pinned: true),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(delegate: SliverChildListDelegate([_buildStylingCard(), const SizedBox(height: 24)])),
|
||||
),
|
||||
],
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
CustomAppBar(title: Text(t.screens.subtitleStyling), pinned: true),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(delegate: SliverChildListDelegate([_buildStylingCard(), const SizedBox(height: 24)])),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import '../services/offline_watch_sync_service.dart';
|
||||
import '../services/settings_service.dart';
|
||||
import '../services/sleep_timer_service.dart';
|
||||
import '../services/track_selection_service.dart';
|
||||
import '../services/ambient_lighting_service.dart';
|
||||
import '../services/video_filter_manager.dart';
|
||||
import '../services/video_pip_manager.dart';
|
||||
import '../services/pip_service.dart';
|
||||
@@ -167,6 +168,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
VideoFilterManager? _videoFilterManager;
|
||||
VideoPIPManager? _videoPIPManager;
|
||||
ShaderService? _shaderService;
|
||||
AmbientLightingService? _ambientLightingService;
|
||||
final EpisodeNavigationService _episodeNavigation = EpisodeNavigationService();
|
||||
|
||||
// Watch Together provider reference (stored early to use in dispose)
|
||||
@@ -387,6 +389,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
await player!.setProperty('sub-ass', 'yes'); // Enable libass
|
||||
await player!.setProperty('demuxer-max-bytes', bufferSizeBytes.toString());
|
||||
await player!.setProperty('msg-level', debugLoggingEnabled ? 'all=debug' : 'all=error');
|
||||
await player!.setLogLevel(debugLoggingEnabled ? 'v' : 'warn');
|
||||
await player!.setProperty('hwdec', _getHwdecValue(enableHardwareDecoding));
|
||||
|
||||
// Subtitle styling
|
||||
@@ -1022,6 +1025,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
// Shader Service (MPV only)
|
||||
_shaderService = ShaderService(player!);
|
||||
if (_shaderService!.isSupported) {
|
||||
// Ambient Lighting Service
|
||||
_ambientLightingService = AmbientLightingService(player!);
|
||||
_shaderService!.ambientLightingService = _ambientLightingService;
|
||||
_videoFilterManager?.ambientLightingService = _ambientLightingService;
|
||||
|
||||
await _applySavedShaderPreset();
|
||||
}
|
||||
}
|
||||
@@ -1140,11 +1148,56 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
|
||||
/// Cycle through BoxFit modes: contain → cover → fill → contain (for button)
|
||||
void _cycleBoxFitMode() {
|
||||
// Disable ambient lighting when switching boxfit modes
|
||||
// (cover/fill change the video rect, making the baked-in shader incorrect)
|
||||
_ambientLightingService?.disable();
|
||||
setState(() {
|
||||
_videoFilterManager?.cycleBoxFitMode();
|
||||
});
|
||||
}
|
||||
|
||||
/// Update video-aspect-override when player size changes.
|
||||
/// The shader adapts automatically via built-in target_size uniform.
|
||||
void _updateAmbientLightingOnResize(Size newSize) {
|
||||
final ambientLighting = _ambientLightingService;
|
||||
if (ambientLighting == null || !ambientLighting.isEnabled) return;
|
||||
if (newSize.height == 0) return;
|
||||
|
||||
ambientLighting.updateOutputAspect(newSize.width / newSize.height);
|
||||
}
|
||||
|
||||
/// Toggle ambient lighting effect on/off
|
||||
Future<void> _toggleAmbientLighting() async {
|
||||
final ambientLighting = _ambientLightingService;
|
||||
if (ambientLighting == null || !ambientLighting.isSupported) return;
|
||||
|
||||
if (ambientLighting.isEnabled) {
|
||||
await ambientLighting.disable();
|
||||
_videoFilterManager?.updateVideoFilter();
|
||||
} else {
|
||||
// Get video display aspect ratio
|
||||
final dwidth = await player?.getProperty('dwidth');
|
||||
final dheight = await player?.getProperty('dheight');
|
||||
if (dwidth == null || dheight == null) return;
|
||||
final w = double.tryParse(dwidth);
|
||||
final h = double.tryParse(dheight);
|
||||
if (w == null || h == null || h == 0) return;
|
||||
final videoAspect = w / h;
|
||||
|
||||
// Get player widget aspect ratio
|
||||
final playerSize = _videoFilterManager?.playerSize;
|
||||
if (playerSize == null || playerSize.height == 0) return;
|
||||
final outputAspect = playerSize.width / playerSize.height;
|
||||
|
||||
// Force contain mode when enabling ambient lighting
|
||||
_videoFilterManager?.resetToContain();
|
||||
|
||||
await ambientLighting.enable(videoAspect, outputAspect);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
/// Toggle between contain and cover modes only (for pinch gesture)
|
||||
void _toggleContainCover() {
|
||||
setState(() {
|
||||
@@ -2150,7 +2203,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
}
|
||||
}
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
return event.logicalKey.isNavigationKey ? KeyEventResult.handled : KeyEventResult.ignored;
|
||||
},
|
||||
child: _isPlayerInitialized && player != null ? _buildVideoPlayer(context) : _buildLoadingSpinner(),
|
||||
);
|
||||
@@ -2214,6 +2267,8 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
if (mounted && player != null) {
|
||||
_videoFilterManager?.updatePlayerSize(newSize);
|
||||
_videoPIPManager?.updatePlayerSize(newSize);
|
||||
// Update ambient lighting shader if active (output aspect changed)
|
||||
_updateAmbientLightingOnResize(newSize);
|
||||
// Update Metal layer frame on iOS/macOS for rotation
|
||||
player!.updateFrame();
|
||||
}
|
||||
@@ -2283,6 +2338,8 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
: null,
|
||||
isLive: widget.isLive,
|
||||
liveChannelName: _liveChannelName,
|
||||
isAmbientLightingEnabled: _ambientLightingService?.isEnabled ?? false,
|
||||
onToggleAmbientLighting: _toggleAmbientLighting,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../mpv/player/player.dart';
|
||||
|
||||
/// Generates and manages an ambient lighting GLSL shader that fills letterbox/pillarbox
|
||||
/// bars with a blurred, dimmed version of the video edges.
|
||||
///
|
||||
/// Uses video-aspect-override to fill the window (eliminating black bars), then
|
||||
/// a GLSL shader composites the sharp original video centered at correct aspect
|
||||
/// over a blurred background.
|
||||
///
|
||||
/// The shader uses MPV's built-in `input_size` and `target_size` uniforms to
|
||||
/// dynamically compute the video rect position. On window resize, only
|
||||
/// `video-aspect-override` needs updating — no shader regeneration required.
|
||||
class AmbientLightingService {
|
||||
final Player _player;
|
||||
String? _shaderPath;
|
||||
bool _enabled = false;
|
||||
|
||||
/// Brightness multiplier for the blurred background (0.0-1.0).
|
||||
static const double _brightness = 0.5;
|
||||
|
||||
AmbientLightingService(this._player);
|
||||
|
||||
bool get isEnabled => _enabled;
|
||||
bool get isSupported => _player.playerType == 'mpv';
|
||||
|
||||
/// Enable ambient lighting effect.
|
||||
///
|
||||
/// [videoAspect] - the source video's display aspect ratio (width/height).
|
||||
/// [outputAspect] - the player widget's aspect ratio (width/height).
|
||||
Future<void> enable(double videoAspect, double outputAspect) async {
|
||||
if (!isSupported) return;
|
||||
|
||||
try {
|
||||
// Write static shader (only needs to happen once)
|
||||
if (_shaderPath == null) {
|
||||
_shaderPath = await _writeShaderToTemp(_generateShader());
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('AmbientLightingService: Shader path: $_shaderPath');
|
||||
}
|
||||
|
||||
// Set video-aspect-override to fill the entire output area
|
||||
await _player.setProperty('video-aspect-override', outputAspect.toString());
|
||||
|
||||
// Append ambient lighting shader
|
||||
await _player.command(['change-list', 'glsl-shaders', 'append', _shaderPath!]);
|
||||
|
||||
_enabled = true;
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('AmbientLightingService: Enabled (video=$videoAspect, output=$outputAspect)');
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
debugPrint('AmbientLightingService: Failed to enable: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Disable ambient lighting effect and restore normal letterboxing.
|
||||
Future<void> disable() async {
|
||||
if (!_enabled) return;
|
||||
|
||||
try {
|
||||
if (_shaderPath != null) {
|
||||
await _player.command(['change-list', 'glsl-shaders', 'remove', _shaderPath!]);
|
||||
}
|
||||
|
||||
await _player.setProperty('video-aspect-override', 'no');
|
||||
|
||||
_enabled = false;
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('AmbientLightingService: Disabled');
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
debugPrint('AmbientLightingService: Failed to disable: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-append the ambient lighting shader to the chain.
|
||||
/// Called by ShaderService after it rebuilds the shader chain (clr + append).
|
||||
Future<void> reappendShader() async {
|
||||
if (!_enabled || _shaderPath == null) return;
|
||||
await _player.command(['change-list', 'glsl-shaders', 'append', _shaderPath!]);
|
||||
}
|
||||
|
||||
/// Update video-aspect-override when the window resizes.
|
||||
/// The shader adapts automatically via dynamic `target_size` uniform.
|
||||
void updateOutputAspect(double outputAspect) {
|
||||
if (!_enabled) return;
|
||||
_player.setProperty('video-aspect-override', outputAspect.toString());
|
||||
}
|
||||
|
||||
/// Generate a static multi-pass GLSL shader.
|
||||
///
|
||||
/// Uses MPV's built-in `input_size` (video dimensions) and `target_size`
|
||||
/// (output dimensions) uniforms which update automatically on resize.
|
||||
/// No baked-in aspect constants — fully adaptive.
|
||||
///
|
||||
/// Pipeline (all MAIN hooks):
|
||||
/// 1. Save original video as ORIGINAL
|
||||
/// 2. Downscale to 1/8 as SMALL (center 60% zoom)
|
||||
/// 3-5. Three Kawase blur passes at 1/8 -> BLUR8C
|
||||
/// 6. Downscale BLUR8C to 1/64 as TINY
|
||||
/// 7-8. Two more Kawase blur passes at 1/64 -> GLOW
|
||||
/// 9. Composite: video rect -> ORIGINAL, bars -> GLOW
|
||||
String _generateShader() {
|
||||
final br = _brightness.toStringAsFixed(2);
|
||||
final buf = StringBuffer();
|
||||
|
||||
// Pass 1: Save original video
|
||||
buf.writeln('//!HOOK MAIN');
|
||||
buf.writeln('//!BIND HOOKED');
|
||||
buf.writeln('//!SAVE ORIGINAL');
|
||||
buf.writeln('//!DESC Ambient Lighting Save');
|
||||
buf.writeln('vec4 hook() {');
|
||||
buf.writeln(' return HOOKED_tex(HOOKED_pos);');
|
||||
buf.writeln('}');
|
||||
buf.writeln();
|
||||
|
||||
// Pass 2: Downscale to 1/8 with center zoom.
|
||||
buf.writeln('//!HOOK MAIN');
|
||||
buf.writeln('//!BIND ORIGINAL');
|
||||
buf.writeln('//!SAVE SMALL');
|
||||
buf.writeln('//!WIDTH ORIGINAL.w 8 /');
|
||||
buf.writeln('//!HEIGHT ORIGINAL.h 8 /');
|
||||
buf.writeln('//!DESC Ambient Lighting Downscale');
|
||||
buf.writeln('vec4 hook() {');
|
||||
buf.writeln(' vec2 uv = ORIGINAL_pos * 0.6 + 0.2;');
|
||||
buf.writeln(' return ORIGINAL_tex(uv);');
|
||||
buf.writeln('}');
|
||||
buf.writeln();
|
||||
|
||||
// Pass 3-5: Three Kawase blur passes at 1/8 resolution.
|
||||
const blur8Steps = [
|
||||
('SMALL', 'BLUR8A', '2.0', 'Blur1'),
|
||||
('BLUR8A', 'BLUR8B', '6.0', 'Blur2'),
|
||||
('BLUR8B', 'BLUR8C', '12.0', 'Blur3'),
|
||||
];
|
||||
for (final (input, output, offset, desc) in blur8Steps) {
|
||||
buf.writeln('//!HOOK MAIN');
|
||||
buf.writeln('//!BIND $input');
|
||||
buf.writeln('//!SAVE $output');
|
||||
buf.writeln('//!WIDTH $input.w');
|
||||
buf.writeln('//!HEIGHT $input.h');
|
||||
buf.writeln('//!DESC Ambient Lighting $desc');
|
||||
buf.writeln('vec4 hook() {');
|
||||
buf.writeln(' vec2 ps = ${input}_pt;');
|
||||
buf.writeln(' vec4 s = ${input}_tex(${input}_pos + vec2( $offset, $offset) * ps)');
|
||||
buf.writeln(' + ${input}_tex(${input}_pos + vec2( $offset, -$offset) * ps)');
|
||||
buf.writeln(' + ${input}_tex(${input}_pos + vec2(-$offset, $offset) * ps)');
|
||||
buf.writeln(' + ${input}_tex(${input}_pos + vec2(-$offset, -$offset) * ps);');
|
||||
buf.writeln(' return s * 0.25;');
|
||||
buf.writeln('}');
|
||||
buf.writeln();
|
||||
}
|
||||
|
||||
// Pass 6: Downscale the already-blurred 1/8 texture to 1/64.
|
||||
buf.writeln('//!HOOK MAIN');
|
||||
buf.writeln('//!BIND BLUR8C');
|
||||
buf.writeln('//!SAVE TINY');
|
||||
buf.writeln('//!WIDTH BLUR8C.w 8 /');
|
||||
buf.writeln('//!HEIGHT BLUR8C.h 8 /');
|
||||
buf.writeln('//!DESC Ambient Lighting Downscale2');
|
||||
buf.writeln('vec4 hook() {');
|
||||
buf.writeln(' return BLUR8C_tex(BLUR8C_pos);');
|
||||
buf.writeln('}');
|
||||
buf.writeln();
|
||||
|
||||
// Pass 7-8: Two more Kawase blur passes at 1/64 for maximum diffusion.
|
||||
const blur64Steps = [
|
||||
('TINY', 'GLOW1', '3.0', 'Blur4'),
|
||||
('GLOW1', 'GLOW', '6.0', 'Blur5'),
|
||||
];
|
||||
for (final (input, output, offset, desc) in blur64Steps) {
|
||||
buf.writeln('//!HOOK MAIN');
|
||||
buf.writeln('//!BIND $input');
|
||||
buf.writeln('//!SAVE $output');
|
||||
buf.writeln('//!WIDTH $input.w');
|
||||
buf.writeln('//!HEIGHT $input.h');
|
||||
buf.writeln('//!DESC Ambient Lighting $desc');
|
||||
buf.writeln('vec4 hook() {');
|
||||
buf.writeln(' vec2 ps = ${input}_pt;');
|
||||
buf.writeln(' vec4 s = ${input}_tex(${input}_pos + vec2( $offset, $offset) * ps)');
|
||||
buf.writeln(' + ${input}_tex(${input}_pos + vec2( $offset, -$offset) * ps)');
|
||||
buf.writeln(' + ${input}_tex(${input}_pos + vec2(-$offset, $offset) * ps)');
|
||||
buf.writeln(' + ${input}_tex(${input}_pos + vec2(-$offset, -$offset) * ps);');
|
||||
buf.writeln(' return s * 0.25;');
|
||||
buf.writeln('}');
|
||||
buf.writeln();
|
||||
}
|
||||
|
||||
// Pass 9: Composite — no //!SAVE so this replaces MAIN.
|
||||
// Uses built-in input_size (video coded dims) and target_size (output dims)
|
||||
// to dynamically compute where the video rect sits. These auto-update on resize.
|
||||
buf.writeln('//!HOOK MAIN');
|
||||
buf.writeln('//!BIND ORIGINAL');
|
||||
buf.writeln('//!BIND GLOW');
|
||||
buf.writeln('//!DESC Ambient Lighting Composite');
|
||||
buf.writeln('vec4 hook() {');
|
||||
buf.writeln(' float vid_aspect = input_size.x / input_size.y;');
|
||||
buf.writeln(' float out_aspect = target_size.x / target_size.y;');
|
||||
buf.writeln();
|
||||
buf.writeln(' vec2 scale, off;');
|
||||
buf.writeln(' if (vid_aspect > out_aspect) {');
|
||||
buf.writeln(' float s = out_aspect / vid_aspect;');
|
||||
buf.writeln(' scale = vec2(1.0, s);');
|
||||
buf.writeln(' off = vec2(0.0, (1.0 - s) * 0.5);');
|
||||
buf.writeln(' } else {');
|
||||
buf.writeln(' float s = vid_aspect / out_aspect;');
|
||||
buf.writeln(' scale = vec2(s, 1.0);');
|
||||
buf.writeln(' off = vec2((1.0 - s) * 0.5, 0.0);');
|
||||
buf.writeln(' }');
|
||||
buf.writeln();
|
||||
buf.writeln(' vec2 vid_pos = (ORIGINAL_pos - off) / scale;');
|
||||
buf.writeln();
|
||||
buf.writeln(' if (all(greaterThanEqual(vid_pos, vec2(0.0))) &&');
|
||||
buf.writeln(' all(lessThanEqual(vid_pos, vec2(1.0)))) {');
|
||||
buf.writeln(' return ORIGINAL_tex(vid_pos);');
|
||||
buf.writeln(' }');
|
||||
buf.writeln();
|
||||
buf.writeln(' return GLOW_tex(ORIGINAL_pos) * $br;');
|
||||
buf.writeln('}');
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/// Write the shader to a temp file and return the path.
|
||||
Future<String> _writeShaderToTemp(String shader) async {
|
||||
final cacheDir = await getTemporaryDirectory();
|
||||
final shaderDir = Directory(path.join(cacheDir.path, 'shaders'));
|
||||
if (!shaderDir.existsSync()) {
|
||||
shaderDir.createSync(recursive: true);
|
||||
}
|
||||
final file = File(path.join(shaderDir.path, 'ambient_lighting.glsl'));
|
||||
await file.writeAsString(shader);
|
||||
return file.path;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,21 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../models/shader_preset.dart';
|
||||
import '../mpv/player/player.dart';
|
||||
import 'ambient_lighting_service.dart';
|
||||
import 'shader_asset_loader.dart';
|
||||
|
||||
/// Service for applying GLSL shaders to the MPV video player.
|
||||
///
|
||||
/// Handles shader chain building, HDR detection, and runtime switching.
|
||||
/// When ambient lighting is active, the ambient lighting shader is always appended last
|
||||
/// in the chain after any upscaling/processing shaders.
|
||||
class ShaderService {
|
||||
final Player _player;
|
||||
ShaderPreset _currentPreset = ShaderPreset.none;
|
||||
|
||||
/// Reference to ambient lighting service for re-appending its shader after chain rebuilds.
|
||||
AmbientLightingService? ambientLightingService;
|
||||
|
||||
ShaderService(this._player);
|
||||
|
||||
/// The currently applied shader preset
|
||||
@@ -41,6 +47,7 @@ class ShaderService {
|
||||
}
|
||||
await _clearShaders();
|
||||
_currentPreset = ShaderPreset.none;
|
||||
await _reappendAmbientLighting();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -52,6 +59,7 @@ class ShaderService {
|
||||
// No shaders - clear any existing ones
|
||||
await _clearShaders();
|
||||
_currentPreset = preset;
|
||||
await _reappendAmbientLighting();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,6 +73,9 @@ class ShaderService {
|
||||
|
||||
_currentPreset = preset;
|
||||
|
||||
// Re-append ambient lighting shader at end of chain
|
||||
await _reappendAmbientLighting();
|
||||
|
||||
if (kDebugMode) {
|
||||
debugPrint('ShaderService: Applied ${preset.name} with ${shaderPaths.length} shaders');
|
||||
}
|
||||
@@ -87,6 +98,21 @@ class ShaderService {
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-append the ambient lighting shader if it's active.
|
||||
/// Called after shader chain rebuilds to keep ambient lighting last.
|
||||
Future<void> _reappendAmbientLighting() async {
|
||||
final service = ambientLightingService;
|
||||
if (service == null || !service.isEnabled) return;
|
||||
|
||||
try {
|
||||
await service.reappendShader();
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
debugPrint('ShaderService: Failed to re-append ambient lighting: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the current video content is HDR.
|
||||
Future<bool> _isHdrContent() async {
|
||||
try {
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../mpv/mpv.dart';
|
||||
|
||||
import '../models/plex_media_version.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import 'ambient_lighting_service.dart';
|
||||
|
||||
/// Manages video filtering, aspect ratio modes, and subtitle positioning for video playback.
|
||||
///
|
||||
@@ -13,6 +14,7 @@ import '../utils/app_logger.dart';
|
||||
/// - Video cropping calculations for fill screen mode
|
||||
/// - Subtitle positioning adjustments based on crop parameters
|
||||
/// - Debounced video filter updates on resize events
|
||||
/// - Ambient-lighting-friendly reset to contain mode
|
||||
class VideoFilterManager {
|
||||
final Player player;
|
||||
final List<PlexMediaVersion> availableVersions;
|
||||
@@ -24,6 +26,9 @@ class VideoFilterManager {
|
||||
/// Store the boxFitMode before entering PiP so it can be restored
|
||||
int? _prePipBoxFitMode;
|
||||
|
||||
/// Ambient lighting service reference - when active, video-aspect-override is managed by ambient lighting
|
||||
AmbientLightingService? ambientLightingService;
|
||||
|
||||
/// Track if a pinch gesture is occurring (public for gesture tracking)
|
||||
bool isPinching = false;
|
||||
|
||||
@@ -54,6 +59,14 @@ class VideoFilterManager {
|
||||
updateVideoFilter();
|
||||
}
|
||||
|
||||
/// Reset to contain mode (mode 0). Used when enabling ambient lighting.
|
||||
void resetToContain() {
|
||||
if (_boxFitMode != 0) {
|
||||
_boxFitMode = 0;
|
||||
updateVideoFilter();
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle between contain and cover modes only (for pinch gesture)
|
||||
void toggleContainCover() {
|
||||
_boxFitMode = _boxFitMode == 0 ? 1 : 0;
|
||||
@@ -89,11 +102,13 @@ class VideoFilterManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the video scaling and positioning based on current display mode
|
||||
/// Update the video scaling and positioning based on current display mode.
|
||||
/// When ambient lighting is active, video-aspect-override is managed by ambient lighting.
|
||||
void updateVideoFilter() async {
|
||||
try {
|
||||
// Clear all video filters and manual scaling first
|
||||
await player.setProperty('video-aspect-override', 'no');
|
||||
if (ambientLightingService?.isEnabled != true) {
|
||||
await player.setProperty('video-aspect-override', 'no');
|
||||
}
|
||||
await player.setProperty('sub-ass-force-margins', 'no');
|
||||
await player.setProperty('panscan', '0');
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class FocusedScrollScaffold extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Focus(
|
||||
canRequestFocus: false,
|
||||
autofocus: true,
|
||||
onKeyEvent: (_, event) => handleBackKeyNavigation(context, event),
|
||||
child: Scaffold(
|
||||
body: CustomScrollView(
|
||||
|
||||
@@ -130,7 +130,12 @@ class MediaContextMenuState extends State<MediaContextMenu> {
|
||||
metadata!.viewedLeafCount != null &&
|
||||
metadata.leafCount != null &&
|
||||
metadata.viewedLeafCount! > 0 &&
|
||||
metadata.viewedLeafCount! < widget.item.leafCount!;
|
||||
metadata.viewedLeafCount! < metadata.leafCount!;
|
||||
|
||||
final hasActiveProgress =
|
||||
mediaType != null &&
|
||||
(mediaType == PlexMediaType.movie || mediaType == PlexMediaType.episode) &&
|
||||
metadata?.hasActiveProgress == true;
|
||||
|
||||
// Check if we should use bottom sheet (on iOS and Android)
|
||||
final useBottomSheet = Platform.isIOS || Platform.isAndroid;
|
||||
@@ -154,14 +159,14 @@ class MediaContextMenuState extends State<MediaContextMenu> {
|
||||
// Regular menu items for other types
|
||||
|
||||
// Mark as Watched
|
||||
if (!metadata!.isWatched || isPartiallyWatched) {
|
||||
if (!metadata!.isWatched || isPartiallyWatched || hasActiveProgress) {
|
||||
menuActions.add(
|
||||
_MenuAction(value: 'watch', icon: Symbols.check_circle_outline_rounded, label: t.mediaMenu.markAsWatched),
|
||||
);
|
||||
}
|
||||
|
||||
// Mark as Unwatched
|
||||
if (metadata.isWatched || isPartiallyWatched) {
|
||||
if (metadata.isWatched || isPartiallyWatched || hasActiveProgress) {
|
||||
menuActions.add(
|
||||
_MenuAction(
|
||||
value: 'unwatch',
|
||||
|
||||
@@ -76,6 +76,7 @@ class NavigationRailItem extends StatelessWidget {
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
canRequestFocus: false,
|
||||
onTap: onTap,
|
||||
borderRadius: borderRadius,
|
||||
child: Container(
|
||||
@@ -256,10 +257,59 @@ class SideNavigationRailState extends State<SideNavigationRail> {
|
||||
_kDownloads,
|
||||
_kSettings,
|
||||
_kReconnect,
|
||||
'liveTv',
|
||||
...libraries.map((lib) => lib.globalKey),
|
||||
};
|
||||
}
|
||||
|
||||
/// Ordered list of focusable keys matching visual top-to-bottom order.
|
||||
List<String> _buildFocusOrder(List<PlexLibrary> visibleLibraries, {required bool hasLiveTv}) {
|
||||
return [
|
||||
if (widget.isOfflineMode && widget.onReconnect != null) _kReconnect,
|
||||
if (!widget.isOfflineMode) ...[
|
||||
_kHome,
|
||||
_kLibraries,
|
||||
if (_librariesExpanded) ...visibleLibraries.map((lib) => lib.globalKey),
|
||||
if (hasLiveTv) 'liveTv',
|
||||
_kSearch,
|
||||
],
|
||||
_kDownloads,
|
||||
_kSettings,
|
||||
];
|
||||
}
|
||||
|
||||
/// Handle D-pad UP/DOWN by explicitly moving focus to the next/previous item.
|
||||
KeyEventResult _handleVerticalNavigation(FocusNode node, KeyEvent event, List<String> focusOrder) {
|
||||
if (event is! KeyDownEvent) return KeyEventResult.ignored;
|
||||
|
||||
final isDown = event.logicalKey == LogicalKeyboardKey.arrowDown;
|
||||
final isUp = event.logicalKey == LogicalKeyboardKey.arrowUp;
|
||||
if (!isDown && !isUp) return KeyEventResult.ignored;
|
||||
|
||||
final currentKey = _focusTracker.lastFocusedKey;
|
||||
if (currentKey == null) return KeyEventResult.ignored;
|
||||
|
||||
final currentIndex = focusOrder.indexOf(currentKey);
|
||||
if (currentIndex == -1) return KeyEventResult.ignored;
|
||||
|
||||
final nextIndex = isDown ? currentIndex + 1 : currentIndex - 1;
|
||||
if (nextIndex < 0 || nextIndex >= focusOrder.length) return KeyEventResult.handled;
|
||||
|
||||
final nextNode = _focusTracker.nodeFor(focusOrder[nextIndex]);
|
||||
if (nextNode == null) return KeyEventResult.ignored;
|
||||
|
||||
nextNode.requestFocus();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
final ctx = nextNode.context;
|
||||
if (ctx != null) {
|
||||
Scrollable.ensureVisible(ctx,
|
||||
alignment: 0.5, duration: const Duration(milliseconds: 200));
|
||||
}
|
||||
});
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
/// Collapse the sidebar (resets touch-expand state).
|
||||
void collapse() {
|
||||
if (_isTouchExpanded) {
|
||||
@@ -319,6 +369,8 @@ class SideNavigationRailState extends State<SideNavigationRail> {
|
||||
_focusTracker.pruneExcept(_buildValidFocusKeys(allLibraries));
|
||||
|
||||
final isCollapsed = !_shouldExpand;
|
||||
final hasLiveTv = context.watch<MultiServerProvider>().hasLiveTv;
|
||||
final focusOrder = _buildFocusOrder(visibleLibraries, hasLiveTv: hasLiveTv);
|
||||
|
||||
// Listen to fullscreen changes for macOS
|
||||
return ListenableBuilder(
|
||||
@@ -344,7 +396,12 @@ class SideNavigationRailState extends State<SideNavigationRail> {
|
||||
decoration: BoxDecoration(color: t.surface),
|
||||
child: IgnorePointer(
|
||||
ignoring: isCollapsed,
|
||||
child: Column(
|
||||
child: Focus(
|
||||
canRequestFocus: false,
|
||||
skipTraversal: true,
|
||||
onKeyEvent: (node, event) =>
|
||||
_handleVerticalNavigation(node, event, focusOrder),
|
||||
child: Column(
|
||||
children: [
|
||||
// Safe area for status bar and macOS traffic lights
|
||||
SizedBox(height: _getTopPadding(context)),
|
||||
@@ -497,6 +554,7 @@ class SideNavigationRailState extends State<SideNavigationRail> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -596,6 +654,7 @@ class SideNavigationRailState extends State<SideNavigationRail> {
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
canRequestFocus: false,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_librariesExpanded = !_librariesExpanded;
|
||||
|
||||
@@ -89,6 +89,12 @@ class DesktopVideoControls extends StatefulWidget {
|
||||
/// Channel name for live TV display
|
||||
final String? liveChannelName;
|
||||
|
||||
/// Whether ambient lighting is enabled (passed to settings sheet)
|
||||
final bool isAmbientLightingEnabled;
|
||||
|
||||
/// Called to toggle ambient lighting (passed to settings sheet)
|
||||
final VoidCallback? onToggleAmbientLighting;
|
||||
|
||||
const DesktopVideoControls({
|
||||
super.key,
|
||||
required this.player,
|
||||
@@ -135,6 +141,8 @@ class DesktopVideoControls extends StatefulWidget {
|
||||
this.thumbnailUrlBuilder,
|
||||
this.isLive = false,
|
||||
this.liveChannelName,
|
||||
this.isAmbientLightingEnabled = false,
|
||||
this.onToggleAmbientLighting,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -680,6 +688,8 @@ class DesktopVideoControlsState extends State<DesktopVideoControls> {
|
||||
isLive: widget.isLive,
|
||||
shaderService: widget.shaderService,
|
||||
onShaderChanged: widget.onShaderChanged,
|
||||
isAmbientLightingEnabled: widget.isAmbientLightingEnabled,
|
||||
onToggleAmbientLighting: widget.onToggleAmbientLighting,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -86,6 +86,12 @@ class VideoSettingsSheet extends StatefulWidget {
|
||||
/// Called when shader preset changes
|
||||
final VoidCallback? onShaderChanged;
|
||||
|
||||
/// Whether ambient lighting is currently enabled
|
||||
final bool isAmbientLightingEnabled;
|
||||
|
||||
/// Called to toggle ambient lighting on/off (null if unsupported)
|
||||
final VoidCallback? onToggleAmbientLighting;
|
||||
|
||||
const VideoSettingsSheet({
|
||||
super.key,
|
||||
required this.player,
|
||||
@@ -95,6 +101,8 @@ class VideoSettingsSheet extends StatefulWidget {
|
||||
this.isLive = false,
|
||||
this.shaderService,
|
||||
this.onShaderChanged,
|
||||
this.isAmbientLightingEnabled = false,
|
||||
this.onToggleAmbientLighting,
|
||||
});
|
||||
|
||||
static Future<void> show(
|
||||
@@ -108,6 +116,8 @@ class VideoSettingsSheet extends StatefulWidget {
|
||||
bool isLive = false,
|
||||
ShaderService? shaderService,
|
||||
VoidCallback? onShaderChanged,
|
||||
bool isAmbientLightingEnabled = false,
|
||||
VoidCallback? onToggleAmbientLighting,
|
||||
}) {
|
||||
return BaseVideoControlSheet.showSheet(
|
||||
context: context,
|
||||
@@ -121,6 +131,8 @@ class VideoSettingsSheet extends StatefulWidget {
|
||||
isLive: isLive,
|
||||
shaderService: shaderService,
|
||||
onShaderChanged: onShaderChanged,
|
||||
isAmbientLightingEnabled: isAmbientLightingEnabled,
|
||||
onToggleAmbientLighting: onToggleAmbientLighting,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -347,7 +359,7 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
final currentDevice = snapshot.data ?? widget.player.state.audioDevice;
|
||||
final deviceLabel = currentDevice.description.isEmpty
|
||||
? currentDevice.name
|
||||
: '${currentDevice.name} · ${currentDevice.description}';
|
||||
: currentDevice.description;
|
||||
|
||||
return _SettingsMenuItem(
|
||||
icon: Symbols.speaker_rounded,
|
||||
@@ -369,6 +381,29 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
onTap: () => _navigateTo(_SettingsView.shader),
|
||||
),
|
||||
|
||||
// Ambient Lighting (MPV only)
|
||||
if (widget.onToggleAmbientLighting != null)
|
||||
ListTile(
|
||||
leading: AppIcon(
|
||||
Symbols.blur_on,
|
||||
fill: 1,
|
||||
color: widget.isAmbientLightingEnabled ? Colors.amber : Colors.white70,
|
||||
),
|
||||
title: Text(t.videoControls.ambientLighting, style: const TextStyle(color: Colors.white)),
|
||||
trailing: Switch(
|
||||
value: widget.isAmbientLightingEnabled,
|
||||
onChanged: (_) {
|
||||
widget.onToggleAmbientLighting?.call();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
activeThumbColor: Colors.amber,
|
||||
),
|
||||
onTap: () {
|
||||
widget.onToggleAmbientLighting?.call();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
|
||||
// Performance Overlay Toggle
|
||||
ListTile(
|
||||
leading: AppIcon(
|
||||
@@ -462,6 +497,27 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Extract the audio backend name from a device name (e.g. "coreaudio" from "coreaudio/BuiltIn").
|
||||
static String _audioBackend(String name) {
|
||||
final slash = name.indexOf('/');
|
||||
return slash > 0 ? name.substring(0, slash) : name;
|
||||
}
|
||||
|
||||
/// Pretty-print a backend identifier.
|
||||
static String _formatBackend(String backend) {
|
||||
const labels = {
|
||||
'coreaudio': 'CoreAudio',
|
||||
'avfoundation': 'AVFoundation',
|
||||
'wasapi': 'WASAPI',
|
||||
'pulse': 'PulseAudio',
|
||||
'pipewire': 'PipeWire',
|
||||
'alsa': 'ALSA',
|
||||
'jack': 'JACK',
|
||||
'oss': 'OSS',
|
||||
};
|
||||
return labels[backend] ?? backend;
|
||||
}
|
||||
|
||||
Widget _buildAudioDeviceView() {
|
||||
return StreamBuilder<List<AudioDevice>>(
|
||||
stream: widget.player.streams.audioDevices,
|
||||
@@ -475,22 +531,44 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
builder: (context, selectedSnapshot) {
|
||||
final currentDevice = selectedSnapshot.data ?? widget.player.state.audioDevice;
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: devices.length,
|
||||
itemBuilder: (context, index) {
|
||||
final device = devices[index];
|
||||
final isSelected = device.name == currentDevice.name;
|
||||
final label = device.description.isEmpty ? device.name : device.description;
|
||||
// Check for duplicate descriptions (same physical device across multiple backends).
|
||||
final descCounts = <String, int>{};
|
||||
for (final d in devices) {
|
||||
final desc = d.description.isEmpty ? d.name : d.description;
|
||||
descCounts[desc] = (descCounts[desc] ?? 0) + 1;
|
||||
}
|
||||
final hasDuplicates = descCounts.values.any((c) => c > 1);
|
||||
|
||||
return ListTile(
|
||||
title: Text(label, style: TextStyle(color: isSelected ? Colors.blue : Colors.white)),
|
||||
trailing: isSelected ? const AppIcon(Symbols.check_rounded, fill: 1, color: Colors.blue) : null,
|
||||
onTap: () {
|
||||
widget.player.setAudioDevice(device);
|
||||
Navigator.pop(context); // Close sheet after selection
|
||||
},
|
||||
);
|
||||
},
|
||||
if (!hasDuplicates) {
|
||||
return _buildFlatDeviceList(devices, currentDevice);
|
||||
}
|
||||
|
||||
// Group devices by backend, keeping "auto" at the top ungrouped.
|
||||
final ungrouped = <AudioDevice>[];
|
||||
final groups = <String, List<AudioDevice>>{};
|
||||
for (final d in devices) {
|
||||
final backend = _audioBackend(d.name);
|
||||
if (!d.name.contains('/')) {
|
||||
ungrouped.add(d);
|
||||
} else {
|
||||
(groups[backend] ??= []).add(d);
|
||||
}
|
||||
}
|
||||
|
||||
return ListView(
|
||||
children: [
|
||||
for (final d in ungrouped) _buildDeviceTile(d, currentDevice),
|
||||
for (final entry in groups.entries) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||
child: Text(
|
||||
_formatBackend(entry.key),
|
||||
style: TextStyle(color: Colors.white.withValues(alpha: 0.5), fontSize: 12, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
for (final d in entry.value) _buildDeviceTile(d, currentDevice),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -498,6 +576,27 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFlatDeviceList(List<AudioDevice> devices, AudioDevice currentDevice) {
|
||||
return ListView.builder(
|
||||
itemCount: devices.length,
|
||||
itemBuilder: (context, index) => _buildDeviceTile(devices[index], currentDevice),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDeviceTile(AudioDevice device, AudioDevice currentDevice) {
|
||||
final isSelected = device.name == currentDevice.name;
|
||||
final label = device.description.isEmpty ? device.name : device.description;
|
||||
|
||||
return ListTile(
|
||||
title: Text(label, style: TextStyle(color: isSelected ? Colors.blue : Colors.white)),
|
||||
trailing: isSelected ? const AppIcon(Symbols.check_rounded, fill: 1, color: Colors.blue) : null,
|
||||
onTap: () {
|
||||
widget.player.setAudioDevice(device);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShaderView() {
|
||||
if (widget.shaderService == null) return const SizedBox.shrink();
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ Widget plexVideoControlsBuilder(
|
||||
String Function(Duration time)? thumbnailUrlBuilder,
|
||||
bool isLive = false,
|
||||
String? liveChannelName,
|
||||
bool isAmbientLightingEnabled = false,
|
||||
VoidCallback? onToggleAmbientLighting,
|
||||
}) {
|
||||
return PlexVideoControls(
|
||||
player: player,
|
||||
@@ -101,6 +103,8 @@ Widget plexVideoControlsBuilder(
|
||||
thumbnailUrlBuilder: thumbnailUrlBuilder,
|
||||
isLive: isLive,
|
||||
liveChannelName: liveChannelName,
|
||||
isAmbientLightingEnabled: isAmbientLightingEnabled,
|
||||
onToggleAmbientLighting: onToggleAmbientLighting,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,6 +154,12 @@ class PlexVideoControls extends StatefulWidget {
|
||||
/// Channel name for live TV display
|
||||
final String? liveChannelName;
|
||||
|
||||
/// Whether ambient lighting is enabled (passed to settings sheet)
|
||||
final bool isAmbientLightingEnabled;
|
||||
|
||||
/// Called to toggle ambient lighting (passed to settings sheet)
|
||||
final VoidCallback? onToggleAmbientLighting;
|
||||
|
||||
const PlexVideoControls({
|
||||
super.key,
|
||||
required this.player,
|
||||
@@ -174,6 +184,8 @@ class PlexVideoControls extends StatefulWidget {
|
||||
this.thumbnailUrlBuilder,
|
||||
this.isLive = false,
|
||||
this.liveChannelName,
|
||||
this.isAmbientLightingEnabled = false,
|
||||
this.onToggleAmbientLighting,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -905,6 +917,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
isLive: widget.isLive,
|
||||
shaderService: widget.shaderService,
|
||||
onShaderChanged: widget.onShaderChanged,
|
||||
isAmbientLightingEnabled: widget.isAmbientLightingEnabled,
|
||||
onToggleAmbientLighting: widget.player.playerType != 'exoplayer' ? widget.onToggleAmbientLighting : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1895,6 +1909,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
thumbnailUrlBuilder: widget.thumbnailUrlBuilder,
|
||||
isLive: widget.isLive,
|
||||
liveChannelName: widget.liveChannelName,
|
||||
isAmbientLightingEnabled: widget.isAmbientLightingEnabled,
|
||||
onToggleAmbientLighting: widget.player.playerType != 'exoplayer' ? widget.onToggleAmbientLighting : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ class TrackChapterControls extends StatelessWidget {
|
||||
final ShaderService? shaderService;
|
||||
final VoidCallback? onShaderChanged;
|
||||
|
||||
/// Whether ambient lighting is enabled (passed to settings sheet)
|
||||
final bool isAmbientLightingEnabled;
|
||||
|
||||
/// Called to toggle ambient lighting (passed to settings sheet)
|
||||
final VoidCallback? onToggleAmbientLighting;
|
||||
|
||||
/// List of FocusNodes for the buttons (passed from parent for navigation)
|
||||
final List<FocusNode>? focusNodes;
|
||||
|
||||
@@ -95,6 +101,8 @@ class TrackChapterControls extends StatelessWidget {
|
||||
this.isLive = false,
|
||||
this.shaderService,
|
||||
this.onShaderChanged,
|
||||
this.isAmbientLightingEnabled = false,
|
||||
this.onToggleAmbientLighting,
|
||||
});
|
||||
|
||||
/// Handle key event for button navigation
|
||||
@@ -201,6 +209,8 @@ class TrackChapterControls extends StatelessWidget {
|
||||
isLive: isLive,
|
||||
shaderService: shaderService,
|
||||
onShaderChanged: onShaderChanged,
|
||||
isAmbientLightingEnabled: isAmbientLightingEnabled,
|
||||
onToggleAmbientLighting: onToggleAmbientLighting,
|
||||
);
|
||||
onLoadSeekTimes?.call();
|
||||
},
|
||||
|
||||
@@ -70,10 +70,6 @@ set_target_properties(${BINARY_NAME}
|
||||
)
|
||||
|
||||
|
||||
# Bundle SDL3 from source so the build works on systems without libsdl3-dev
|
||||
# (e.g. arm64 Linux where no distro package exists yet).
|
||||
set(BUNDLE_SDL3 ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
@@ -131,7 +131,7 @@ meson setup build \
|
||||
-Dalsa=enabled \
|
||||
-Dpulse=enabled \
|
||||
-Dpipewire=enabled \
|
||||
-Dwayland=enabled \
|
||||
-Dwayland=disabled \
|
||||
-Dx11=enabled
|
||||
|
||||
ninja -C build -j"$JOBS"
|
||||
|
||||
@@ -43,6 +43,7 @@ DISTROS = {
|
||||
"libmpv2 | libmpv1",
|
||||
"libepoxy0",
|
||||
"libasound2",
|
||||
"libevdev2",
|
||||
"libglib2.0-0",
|
||||
],
|
||||
},
|
||||
@@ -56,6 +57,7 @@ DISTROS = {
|
||||
"mpv-libs",
|
||||
"libepoxy",
|
||||
"alsa-lib",
|
||||
"libevdev",
|
||||
"glib2",
|
||||
],
|
||||
},
|
||||
@@ -69,6 +71,7 @@ DISTROS = {
|
||||
"mpv",
|
||||
"libepoxy",
|
||||
"alsa-lib",
|
||||
"libevdev",
|
||||
"glib2",
|
||||
],
|
||||
},
|
||||
|
||||
@@ -11,6 +11,7 @@ add_executable(${BINARY_NAME}
|
||||
"my_application.cc"
|
||||
"mpv/mpv_player.cc"
|
||||
"mpv/mpv_plugin.cc"
|
||||
"mpv/mpv_texture.cc"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
)
|
||||
|
||||
|
||||
@@ -43,19 +43,11 @@ MpvPlayer::~MpvPlayer() {
|
||||
Dispose();
|
||||
}
|
||||
|
||||
bool MpvPlayer::Initialize(GtkGLArea* gl_area) {
|
||||
bool MpvPlayer::Initialize() {
|
||||
if (mpv_) {
|
||||
return true; // Already initialized.
|
||||
}
|
||||
|
||||
gl_area_ = gl_area;
|
||||
|
||||
// Check if GL area is realized
|
||||
if (!gtk_widget_get_realized(GTK_WIDGET(gl_area))) {
|
||||
g_warning("MPV: GL area not realized yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
// MPV requires C locale for numeric formatting
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
|
||||
@@ -67,11 +59,11 @@ bool MpvPlayer::Initialize(GtkGLArea* gl_area) {
|
||||
}
|
||||
|
||||
// Configure mpv for embedded playback.
|
||||
mpv_set_option_string(mpv_, "vo", "libmpv"); // Render via mpv_render_context_render()
|
||||
mpv_set_option_string(mpv_, "vo", "libmpv");
|
||||
mpv_set_option_string(mpv_, "hwdec", "auto");
|
||||
mpv_set_option_string(mpv_, "keep-open", "yes");
|
||||
|
||||
// HDR tone mapping - ensures HDR content is properly converted to SDR
|
||||
// HDR tone mapping
|
||||
mpv_set_option_string(mpv_, "tone-mapping", "auto");
|
||||
mpv_set_option_string(mpv_, "target-colorspace-hint", "no");
|
||||
mpv_set_option_string(mpv_, "hdr-compute-peak", "auto");
|
||||
@@ -81,8 +73,8 @@ bool MpvPlayer::Initialize(GtkGLArea* gl_area) {
|
||||
mpv_set_option_string(mpv_, "osc", "no");
|
||||
mpv_set_option_string(mpv_, "terminal", "no");
|
||||
|
||||
// Enable verbose logging for debugging.
|
||||
mpv_request_log_messages(mpv_, "v");
|
||||
// Default to warn-level logging
|
||||
mpv_request_log_messages(mpv_, "warn");
|
||||
|
||||
// Initialize mpv.
|
||||
int err = mpv_initialize(mpv_);
|
||||
@@ -93,12 +85,20 @@ bool MpvPlayer::Initialize(GtkGLArea* gl_area) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make the GL context current.
|
||||
gtk_gl_area_make_current(gl_area_);
|
||||
if (gtk_gl_area_get_error(gl_area_) != nullptr) {
|
||||
g_warning("MPV: Failed to make GL context current");
|
||||
mpv_terminate_destroy(mpv_);
|
||||
mpv_ = nullptr;
|
||||
// Set up event wakeup callback.
|
||||
mpv_set_wakeup_callback(mpv_, OnMpvWakeup, this);
|
||||
|
||||
g_message("MPV: Initialization successful (render context deferred)");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MpvPlayer::InitRenderContext() {
|
||||
if (mpv_gl_) {
|
||||
return true; // Already created.
|
||||
}
|
||||
|
||||
if (!mpv_) {
|
||||
g_warning("MPV: Cannot create render context - mpv not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,45 +115,37 @@ bool MpvPlayer::Initialize(GtkGLArea* gl_area) {
|
||||
{MPV_RENDER_PARAM_INVALID, nullptr},
|
||||
};
|
||||
|
||||
err = mpv_render_context_create(&mpv_gl_, mpv_, params);
|
||||
int err = mpv_render_context_create(&mpv_gl_, mpv_, params);
|
||||
if (err < 0) {
|
||||
g_warning("MPV: mpv_render_context_create() failed: %s",
|
||||
mpv_error_string(err));
|
||||
mpv_terminate_destroy(mpv_);
|
||||
mpv_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set up event wakeup callback.
|
||||
mpv_set_wakeup_callback(mpv_, OnMpvWakeup, this);
|
||||
|
||||
// Set up render update callback.
|
||||
mpv_render_context_set_update_callback(mpv_gl_, OnMpvRenderUpdate, this);
|
||||
|
||||
g_message("MPV: Initialization successful");
|
||||
g_message("MPV: Render context created successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
void MpvPlayer::Dispose() {
|
||||
// Lock mutex to prevent race with OnMpvWakeup callbacks.
|
||||
// This ensures no new event processing starts during dispose.
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
|
||||
// Guard against multiple dispose calls (double-free protection)
|
||||
if (disposed_.exchange(true)) {
|
||||
return; // Already disposed
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel pending async commands
|
||||
{
|
||||
std::lock_guard<std::mutex> cmd_lock(pending_commands_mutex_);
|
||||
for (auto& pair : pending_commands_) {
|
||||
if (pair.second) pair.second(-1); // Call with error
|
||||
if (pair.second) pair.second(-1);
|
||||
}
|
||||
pending_commands_.clear();
|
||||
}
|
||||
|
||||
// Clear mpv callbacks BEFORE freeing to prevent new callbacks being scheduled
|
||||
// Clear mpv callbacks BEFORE freeing
|
||||
if (mpv_gl_) {
|
||||
mpv_render_context_set_update_callback(mpv_gl_, nullptr, nullptr);
|
||||
}
|
||||
@@ -167,20 +159,18 @@ void MpvPlayer::Dispose() {
|
||||
event_source_id_ = 0;
|
||||
}
|
||||
|
||||
// Now safe to free render context
|
||||
if (mpv_gl_) {
|
||||
mpv_render_context_free(mpv_gl_);
|
||||
mpv_gl_ = nullptr;
|
||||
}
|
||||
|
||||
// And terminate mpv
|
||||
if (mpv_) {
|
||||
mpv_terminate_destroy(mpv_);
|
||||
mpv_ = nullptr;
|
||||
}
|
||||
|
||||
observed_properties_.clear();
|
||||
gl_area_ = nullptr;
|
||||
redraw_callback_ = nullptr;
|
||||
}
|
||||
|
||||
void MpvPlayer::Command(const std::vector<std::string>& args) {
|
||||
@@ -210,7 +200,6 @@ void MpvPlayer::CommandAsync(const std::vector<std::string>& args,
|
||||
}
|
||||
c_args.push_back(nullptr);
|
||||
|
||||
// Generate unique request ID and store callback
|
||||
uint64_t request_id;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pending_commands_mutex_);
|
||||
@@ -218,10 +207,8 @@ void MpvPlayer::CommandAsync(const std::vector<std::string>& args,
|
||||
pending_commands_[request_id] = std::move(callback);
|
||||
}
|
||||
|
||||
// mpv_command_async returns immediately
|
||||
int result = mpv_command_async(mpv_, request_id, c_args.data());
|
||||
if (result < 0) {
|
||||
// Submission failed, complete immediately with error
|
||||
std::lock_guard<std::mutex> lock(pending_commands_mutex_);
|
||||
auto it = pending_commands_.find(request_id);
|
||||
if (it != pending_commands_.end()) {
|
||||
@@ -253,7 +240,6 @@ void MpvPlayer::ObserveProperty(const std::string& name,
|
||||
int id) {
|
||||
if (disposed_ || !mpv_) return;
|
||||
|
||||
// Check if already observing.
|
||||
if (observed_properties_.find(name) != observed_properties_.end()) {
|
||||
return;
|
||||
}
|
||||
@@ -288,7 +274,7 @@ void MpvPlayer::Render(int width, int height, int fbo) {
|
||||
.internal_format = 0,
|
||||
};
|
||||
|
||||
int flip_y = 1;
|
||||
int flip_y = 0;
|
||||
|
||||
mpv_render_param params[] = {
|
||||
{MPV_RENDER_PARAM_OPENGL_FBO, &mpv_fbo},
|
||||
@@ -312,42 +298,26 @@ void MpvPlayer::SetEventCallback(EventCallback callback) {
|
||||
event_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void MpvPlayer::RequestRedraw() {
|
||||
if (disposed_) return;
|
||||
void MpvPlayer::SetRedrawCallback(RedrawCallback callback) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
redraw_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
needs_redraw_.store(true);
|
||||
if (gl_area_) {
|
||||
// Queue redraw on main thread
|
||||
GtkGLArea* area = gl_area_;
|
||||
g_idle_add_full(
|
||||
GDK_PRIORITY_REDRAW,
|
||||
[](gpointer data) -> gboolean {
|
||||
GtkGLArea* area = static_cast<GtkGLArea*>(data);
|
||||
if (GTK_IS_GL_AREA(area)) {
|
||||
gtk_gl_area_queue_render(area);
|
||||
}
|
||||
return G_SOURCE_REMOVE;
|
||||
},
|
||||
area,
|
||||
nullptr);
|
||||
}
|
||||
void MpvPlayer::SetLogLevel(const std::string& level) {
|
||||
if (disposed_ || !mpv_) return;
|
||||
mpv_request_log_messages(mpv_, level.c_str());
|
||||
}
|
||||
|
||||
void MpvPlayer::OnMpvWakeup(void* ctx) {
|
||||
auto* player = static_cast<MpvPlayer*>(ctx);
|
||||
|
||||
// Don't schedule if already disposed (atomic check for early exit)
|
||||
if (player->disposed_) return;
|
||||
|
||||
// Schedule event processing on the main thread.
|
||||
g_idle_add_full(
|
||||
G_PRIORITY_HIGH_IDLE,
|
||||
[](gpointer data) -> gboolean {
|
||||
auto* player = static_cast<MpvPlayer*>(data);
|
||||
|
||||
// Check disposed - atomic ensures we see updated value.
|
||||
// Don't lock mutex here - ProcessEvents() calls SendPropertyChange/SendEvent
|
||||
// which lock callback_mutex_, causing deadlock if we hold it here.
|
||||
if (!player->disposed_ && player->mpv_) {
|
||||
player->ProcessEvents();
|
||||
}
|
||||
@@ -359,8 +329,18 @@ void MpvPlayer::OnMpvWakeup(void* ctx) {
|
||||
|
||||
void MpvPlayer::OnMpvRenderUpdate(void* ctx) {
|
||||
auto* player = static_cast<MpvPlayer*>(ctx);
|
||||
// RequestRedraw already checks disposed_
|
||||
player->RequestRedraw();
|
||||
if (player->disposed_) return;
|
||||
|
||||
bool expected = false;
|
||||
if (!player->needs_redraw_.compare_exchange_strong(expected, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Call the redraw callback to notify MpvTexture via the registrar
|
||||
std::lock_guard<std::mutex> lock(player->callback_mutex_);
|
||||
if (player->redraw_callback_) {
|
||||
player->redraw_callback_();
|
||||
}
|
||||
}
|
||||
|
||||
bool MpvPlayer::ProcessEvents() {
|
||||
@@ -382,7 +362,6 @@ bool MpvPlayer::ProcessEvents() {
|
||||
void MpvPlayer::HandleMpvEvent(mpv_event* event) {
|
||||
switch (event->event_id) {
|
||||
case MPV_EVENT_COMMAND_REPLY: {
|
||||
// Handle async command completion
|
||||
uint64_t request_id = event->reply_userdata;
|
||||
CommandCallback callback;
|
||||
{
|
||||
@@ -394,7 +373,6 @@ void MpvPlayer::HandleMpvEvent(mpv_event* event) {
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
// Call callback on main thread
|
||||
int error = event->error;
|
||||
g_idle_add(
|
||||
[](gpointer data) -> gboolean {
|
||||
|
||||
@@ -25,6 +25,9 @@ namespace mpv {
|
||||
/// Note: FlValue* is passed from the global namespace, not mpv namespace.
|
||||
using EventCallback = std::function<void(::_FlValue*)>;
|
||||
|
||||
/// Callback for requesting a redraw (called from mpv render update thread).
|
||||
using RedrawCallback = std::function<void()>;
|
||||
|
||||
/// Wrapper for libmpv that handles initialization, OpenGL rendering,
|
||||
/// commands, properties, and event dispatching.
|
||||
class MpvPlayer {
|
||||
@@ -32,65 +35,59 @@ class MpvPlayer {
|
||||
MpvPlayer();
|
||||
~MpvPlayer();
|
||||
|
||||
/// Initializes mpv with OpenGL rendering context.
|
||||
/// Must be called from the GTK main thread after GL context is available.
|
||||
/// @param gl_area The GtkGLArea widget for rendering.
|
||||
/// Initializes the mpv instance and configures options.
|
||||
/// Does NOT create the render context — call InitRenderContext() later
|
||||
/// when an OpenGL context is available.
|
||||
/// @return true if initialization succeeded.
|
||||
bool Initialize(GtkGLArea* gl_area);
|
||||
bool Initialize();
|
||||
|
||||
/// Creates the mpv OpenGL render context.
|
||||
/// Must be called with a valid GL context current (e.g., from FlTextureGL::populate).
|
||||
/// @return true if render context creation succeeded.
|
||||
bool InitRenderContext();
|
||||
|
||||
/// Returns true if the render context has been created.
|
||||
bool HasRenderContext() const { return mpv_gl_ != nullptr; }
|
||||
|
||||
/// Disposes mpv and releases resources.
|
||||
void Dispose();
|
||||
|
||||
/// Returns true if mpv is initialized.
|
||||
/// Returns true if mpv is initialized (has both mpv handle and render context).
|
||||
bool IsInitialized() const { return mpv_ != nullptr && mpv_gl_ != nullptr; }
|
||||
|
||||
/// Returns true if mpv handle exists (even without render context).
|
||||
bool HasMpvHandle() const { return mpv_ != nullptr; }
|
||||
|
||||
/// Executes an mpv command.
|
||||
/// @param args Command arguments (e.g., ["loadfile", "url", "replace"]).
|
||||
void Command(const std::vector<std::string>& args);
|
||||
|
||||
/// Callback type for async command completion.
|
||||
using CommandCallback = std::function<void(int error)>;
|
||||
|
||||
/// Executes an mpv command asynchronously to prevent UI blocking.
|
||||
/// The callback is called on the main thread when the command completes.
|
||||
/// @param args Command arguments.
|
||||
/// @param callback Callback called with error code (0 = success).
|
||||
void CommandAsync(const std::vector<std::string>& args, CommandCallback callback);
|
||||
|
||||
/// Sets an mpv property by name.
|
||||
/// @param name Property name.
|
||||
/// @param value Property value as string.
|
||||
void SetProperty(const std::string& name, const std::string& value);
|
||||
|
||||
/// Gets an mpv property value by name.
|
||||
/// @param name Property name.
|
||||
/// @return Property value as string, or empty if not found.
|
||||
std::string GetProperty(const std::string& name);
|
||||
|
||||
/// Observes an mpv property for changes.
|
||||
/// Changes will be reported via the event callback.
|
||||
/// @param name Property name to observe.
|
||||
/// @param format Format type ("string", "flag", "int64", "double", "node").
|
||||
/// @param id Property ID assigned by Dart for compact event encoding.
|
||||
void ObserveProperty(const std::string& name, const std::string& format,
|
||||
int id);
|
||||
|
||||
/// Renders a frame to the current OpenGL context.
|
||||
/// Must be called from the GTK render callback.
|
||||
/// @param width Viewport width.
|
||||
/// @param height Viewport height.
|
||||
/// @param fbo Framebuffer object to render into (0 for default).
|
||||
/// Renders a frame to the specified FBO.
|
||||
void Render(int width, int height, int fbo = 0);
|
||||
|
||||
/// Reports that the mouse has moved.
|
||||
/// This is used to show/hide the cursor.
|
||||
void ReportMouseMove(int x, int y);
|
||||
|
||||
/// Sets the event callback for property changes and events.
|
||||
void SetEventCallback(EventCallback callback);
|
||||
|
||||
/// Returns the GtkGLArea widget.
|
||||
GtkGLArea* GetGLArea() const { return gl_area_; }
|
||||
/// Sets the redraw callback (called when mpv has a new frame ready).
|
||||
void SetRedrawCallback(RedrawCallback callback);
|
||||
|
||||
/// Returns true if a redraw is needed.
|
||||
bool NeedsRedraw() const { return needs_redraw_.load(); }
|
||||
@@ -98,8 +95,8 @@ class MpvPlayer {
|
||||
/// Clears the redraw flag.
|
||||
void ClearRedrawFlag() { needs_redraw_.store(false); }
|
||||
|
||||
/// Request a redraw.
|
||||
void RequestRedraw();
|
||||
/// Sets the MPV log message level (e.g., "warn", "v", "debug").
|
||||
void SetLogLevel(const std::string& level);
|
||||
|
||||
private:
|
||||
/// MPV event wakeup callback (called from mpv thread).
|
||||
@@ -109,7 +106,6 @@ class MpvPlayer {
|
||||
static void OnMpvRenderUpdate(void* ctx);
|
||||
|
||||
/// Processes pending mpv events.
|
||||
/// @return true to keep processing, false if shutdown.
|
||||
bool ProcessEvents();
|
||||
|
||||
/// Handles a single mpv event.
|
||||
@@ -126,11 +122,11 @@ class MpvPlayer {
|
||||
|
||||
mpv_handle* mpv_ = nullptr;
|
||||
mpv_render_context* mpv_gl_ = nullptr;
|
||||
GtkGLArea* gl_area_ = nullptr;
|
||||
|
||||
std::atomic<bool> needs_redraw_{false};
|
||||
std::atomic<bool> disposed_{false};
|
||||
EventCallback event_callback_;
|
||||
RedrawCallback redraw_callback_;
|
||||
std::mutex callback_mutex_;
|
||||
|
||||
uint64_t next_reply_userdata_ = 1;
|
||||
|
||||
+81
-220
@@ -1,21 +1,18 @@
|
||||
#include "mpv_plugin.h"
|
||||
#include "mpv_texture.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
/// Plugin structure definition.
|
||||
struct _MpvPlugin {
|
||||
GObject parent_instance;
|
||||
|
||||
FlPluginRegistrar* registrar;
|
||||
FlMethodChannel* method_channel;
|
||||
FlEventChannel* event_channel;
|
||||
FlBasicMessageChannel* event_message_channel;
|
||||
|
||||
GtkOverlay* overlay;
|
||||
GtkGLArea* gl_area;
|
||||
GtkWidget* flutter_view;
|
||||
FlTextureRegistrar* texture_registrar;
|
||||
|
||||
std::unique_ptr<mpv::MpvPlayer> player;
|
||||
MpvTexture* texture; // owned via GObject ref
|
||||
gboolean visible;
|
||||
gboolean initialized;
|
||||
};
|
||||
@@ -26,12 +23,17 @@ G_DEFINE_TYPE(MpvPlugin, mpv_plugin, G_TYPE_OBJECT)
|
||||
static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
FlMethodCall* method_call,
|
||||
gpointer user_data);
|
||||
static gboolean on_gl_render(GtkGLArea* area,
|
||||
GdkGLContext* context,
|
||||
gpointer user_data);
|
||||
static void on_gl_realize(GtkGLArea* area, gpointer user_data);
|
||||
static void on_gl_unrealize(GtkGLArea* area, gpointer user_data);
|
||||
static void on_gl_resize(GtkGLArea* area, gint width, gint height, gpointer user_data);
|
||||
|
||||
static void send_event(MpvPlugin* self, FlValue* event) {
|
||||
if (self->event_channel) {
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!fl_event_channel_send(self->event_channel, event, nullptr, &error)) {
|
||||
if (error != nullptr) {
|
||||
g_warning("Failed to send event: %s", error->message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mpv_plugin_dispose(GObject* object) {
|
||||
MpvPlugin* self = MPV_PLUGIN(object);
|
||||
@@ -41,6 +43,16 @@ static void mpv_plugin_dispose(GObject* object) {
|
||||
self->player.reset();
|
||||
}
|
||||
|
||||
if (self->texture) {
|
||||
mpv_texture_dispose(self->texture);
|
||||
if (self->texture_registrar) {
|
||||
fl_texture_registrar_unregister_texture(self->texture_registrar,
|
||||
FL_TEXTURE(self->texture));
|
||||
}
|
||||
g_object_unref(self->texture);
|
||||
self->texture = nullptr;
|
||||
}
|
||||
|
||||
g_clear_object(&self->method_channel);
|
||||
g_clear_object(&self->event_channel);
|
||||
g_clear_object(&self->registrar);
|
||||
@@ -55,33 +67,18 @@ static void mpv_plugin_class_init(MpvPluginClass* klass) {
|
||||
static void mpv_plugin_init(MpvPlugin* self) {
|
||||
self->visible = FALSE;
|
||||
self->initialized = FALSE;
|
||||
self->texture = nullptr;
|
||||
self->texture_registrar = nullptr;
|
||||
}
|
||||
|
||||
/// Send an event through the event channel.
|
||||
static void send_event(MpvPlugin* self, FlValue* event) {
|
||||
if (self->event_channel) {
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!fl_event_channel_send(self->event_channel, event, nullptr, &error)) {
|
||||
if (error != nullptr) {
|
||||
g_warning("Failed to send event: %s", error->message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MpvPlugin* mpv_plugin_new(FlPluginRegistrar* registrar,
|
||||
GtkOverlay* overlay,
|
||||
GtkGLArea* gl_area,
|
||||
GtkWidget* flutter_view) {
|
||||
MpvPlugin* mpv_plugin_new(FlPluginRegistrar* registrar) {
|
||||
MpvPlugin* self = MPV_PLUGIN(g_object_new(MPV_PLUGIN_TYPE, nullptr));
|
||||
|
||||
self->registrar = FL_PLUGIN_REGISTRAR(g_object_ref(registrar));
|
||||
self->overlay = overlay;
|
||||
self->gl_area = gl_area;
|
||||
self->flutter_view = flutter_view;
|
||||
self->texture_registrar =
|
||||
fl_plugin_registrar_get_texture_registrar(registrar);
|
||||
self->player = std::make_unique<mpv::MpvPlayer>();
|
||||
|
||||
// Create method channel.
|
||||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
|
||||
self->method_channel = fl_method_channel_new(
|
||||
fl_plugin_registrar_get_messenger(registrar),
|
||||
@@ -94,167 +91,19 @@ MpvPlugin* mpv_plugin_new(FlPluginRegistrar* registrar,
|
||||
self,
|
||||
nullptr);
|
||||
|
||||
// Create event channel.
|
||||
self->event_channel = fl_event_channel_new(
|
||||
fl_plugin_registrar_get_messenger(registrar),
|
||||
"com.plezy/mpv_player/events",
|
||||
FL_METHOD_CODEC(codec));
|
||||
|
||||
// Connect GtkGLArea signals.
|
||||
g_signal_connect(gl_area, "render", G_CALLBACK(on_gl_render), self);
|
||||
g_signal_connect(gl_area, "realize", G_CALLBACK(on_gl_realize), self);
|
||||
g_signal_connect(gl_area, "unrealize", G_CALLBACK(on_gl_unrealize), self);
|
||||
g_signal_connect(gl_area, "resize", G_CALLBACK(on_gl_resize), self);
|
||||
|
||||
// Set up auto-render to false - we control when to render.
|
||||
gtk_gl_area_set_auto_render(gl_area, FALSE);
|
||||
|
||||
// Use OpenGL 3.3 core profile.
|
||||
gtk_gl_area_set_required_version(gl_area, 3, 3);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
// Static reference to keep the plugin alive for the lifetime of the app.
|
||||
// The plugin will be disposed when the GL area is unrealized.
|
||||
// Static reference to keep the plugin alive.
|
||||
static MpvPlugin* g_mpv_plugin = nullptr;
|
||||
|
||||
void mpv_plugin_register_with_registrar(FlPluginRegistrar* registrar,
|
||||
GtkOverlay* overlay,
|
||||
GtkGLArea* gl_area,
|
||||
GtkWidget* flutter_view) {
|
||||
g_mpv_plugin = mpv_plugin_new(registrar, overlay, gl_area, flutter_view);
|
||||
// Keep a reference - the plugin will be cleaned up when the app exits
|
||||
}
|
||||
|
||||
/// GtkGLArea render callback.
|
||||
static gboolean on_gl_render(GtkGLArea* area,
|
||||
GdkGLContext* context,
|
||||
gpointer user_data) {
|
||||
(void)context;
|
||||
MpvPlugin* self = MPV_PLUGIN(user_data);
|
||||
|
||||
// Ensure GL context is current before any GL operations.
|
||||
// Critical during fullscreen transitions and workspace switches (issue #202).
|
||||
gtk_gl_area_make_current(area);
|
||||
|
||||
// Check for GL context errors (can happen during window state changes)
|
||||
GError* error = gtk_gl_area_get_error(area);
|
||||
if (error != nullptr) {
|
||||
g_warning("MPV Plugin: GL context error in render: %s", error->message);
|
||||
return FALSE; // Signal failure to GTK
|
||||
}
|
||||
|
||||
if (!self->player || !self->player->IsInitialized() || !self->visible) {
|
||||
// Clear to transparent when not showing video.
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int width = gtk_widget_get_allocated_width(GTK_WIDGET(area));
|
||||
int height = gtk_widget_get_allocated_height(GTK_WIDGET(area));
|
||||
|
||||
// Get the scale factor for HiDPI support.
|
||||
int scale = gtk_widget_get_scale_factor(GTK_WIDGET(area));
|
||||
width *= scale;
|
||||
height *= scale;
|
||||
|
||||
// Get the FBO that GtkGLArea is rendering to.
|
||||
// GtkGLArea uses its own FBO, not the default framebuffer (0).
|
||||
GLint fbo = 0;
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
|
||||
|
||||
// Save GL state before MPV render (MPV modifies these and doesn't restore them)
|
||||
// This prevents GL state pollution that corrupts Flutter's rendering.
|
||||
GLint prev_viewport[4];
|
||||
GLint prev_scissor_box[4];
|
||||
GLboolean prev_blend, prev_scissor_test;
|
||||
GLint prev_blend_src, prev_blend_dst;
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, prev_viewport);
|
||||
glGetIntegerv(GL_SCISSOR_BOX, prev_scissor_box);
|
||||
glGetBooleanv(GL_BLEND, &prev_blend);
|
||||
glGetBooleanv(GL_SCISSOR_TEST, &prev_scissor_test);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &prev_blend_src);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &prev_blend_dst);
|
||||
|
||||
// Set viewport and render the video frame.
|
||||
glViewport(0, 0, width, height);
|
||||
self->player->Render(width, height, fbo);
|
||||
self->player->ClearRedrawFlag();
|
||||
|
||||
// Restore GL state after MPV render to prevent Flutter corruption.
|
||||
glViewport(prev_viewport[0], prev_viewport[1], prev_viewport[2], prev_viewport[3]);
|
||||
glScissor(prev_scissor_box[0], prev_scissor_box[1], prev_scissor_box[2], prev_scissor_box[3]);
|
||||
if (prev_blend) {
|
||||
glEnable(GL_BLEND);
|
||||
} else {
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
if (prev_scissor_test) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
} else {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
glBlendFunc(prev_blend_src, prev_blend_dst);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/// GtkGLArea realize callback.
|
||||
static void on_gl_realize(GtkGLArea* area, gpointer user_data) {
|
||||
(void)user_data;
|
||||
gtk_gl_area_make_current(area);
|
||||
|
||||
// Check for GL errors.
|
||||
GError* error = gtk_gl_area_get_error(area);
|
||||
if (error != nullptr) {
|
||||
g_warning("MPV Plugin: GL area error: %s", error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable blending for transparency support.
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
g_message("MPV Plugin: GL area realized");
|
||||
}
|
||||
|
||||
/// GtkGLArea unrealize callback.
|
||||
static void on_gl_unrealize(GtkGLArea* area, gpointer user_data) {
|
||||
MpvPlugin* self = MPV_PLUGIN(user_data);
|
||||
|
||||
gtk_gl_area_make_current(area);
|
||||
|
||||
// Check if context is valid before disposing GL resources (issue #202)
|
||||
GError* error = gtk_gl_area_get_error(area);
|
||||
if (error != nullptr) {
|
||||
g_warning("MPV Plugin: GL context error in unrealize: %s", error->message);
|
||||
}
|
||||
|
||||
// Always try to dispose - Dispose() handles its own safety checks
|
||||
if (self->player) {
|
||||
self->player->Dispose();
|
||||
}
|
||||
|
||||
g_message("MPV Plugin: GL area unrealized");
|
||||
}
|
||||
|
||||
/// GtkGLArea resize callback.
|
||||
static void on_gl_resize(GtkGLArea* area,
|
||||
gint width,
|
||||
gint height,
|
||||
gpointer user_data) {
|
||||
MpvPlugin* self = MPV_PLUGIN(user_data);
|
||||
(void)width;
|
||||
(void)height;
|
||||
|
||||
// Force a redraw when size changes to prevent lag during resize.
|
||||
if (self->visible && self->player && self->player->IsInitialized()) {
|
||||
gtk_gl_area_queue_render(area);
|
||||
}
|
||||
void mpv_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
|
||||
g_mpv_plugin = mpv_plugin_new(registrar);
|
||||
}
|
||||
|
||||
/// Method call handler.
|
||||
@@ -269,40 +118,41 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
g_autoptr(FlMethodResponse) response = nullptr;
|
||||
|
||||
if (strcmp(method, "initialize") == 0) {
|
||||
if (self->initialized) {
|
||||
response = FL_METHOD_RESPONSE(
|
||||
fl_method_success_response_new(fl_value_new_bool(TRUE)));
|
||||
if (self->initialized && self->texture) {
|
||||
// Already initialized — return existing texture ID
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(
|
||||
fl_value_new_int(mpv_texture_get_id(self->texture))));
|
||||
} else {
|
||||
// Create player if it was disposed
|
||||
if (!self->player) {
|
||||
self->player = std::make_unique<mpv::MpvPlayer>();
|
||||
}
|
||||
|
||||
// Check if GL area is realized before trying to use it
|
||||
if (!gtk_widget_get_realized(GTK_WIDGET(self->gl_area))) {
|
||||
// Force realization of the GL area
|
||||
gtk_widget_realize(GTK_WIDGET(self->gl_area));
|
||||
}
|
||||
if (self->player->Initialize()) {
|
||||
// Create the FlTextureGL and register it
|
||||
FlView* view = fl_plugin_registrar_get_view(self->registrar);
|
||||
self->texture = mpv_texture_new(
|
||||
self->player.get(), self->texture_registrar, view);
|
||||
|
||||
// Initialize the player with the GL area.
|
||||
gtk_gl_area_make_current(self->gl_area);
|
||||
fl_texture_registrar_register_texture(
|
||||
self->texture_registrar, FL_TEXTURE(self->texture));
|
||||
|
||||
// Set redraw callback: when mpv has a frame, mark texture available
|
||||
MpvTexture* tex = self->texture;
|
||||
self->player->SetRedrawCallback([tex]() {
|
||||
mpv_texture_mark_frame_available(tex);
|
||||
});
|
||||
|
||||
GError* error = gtk_gl_area_get_error(self->gl_area);
|
||||
if (error != nullptr) {
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new(
|
||||
"GL_ERROR", error->message, nullptr));
|
||||
} else if (self->player->Initialize(self->gl_area)) {
|
||||
self->initialized = TRUE;
|
||||
|
||||
// Set up event callback.
|
||||
// Set up event callback
|
||||
self->player->SetEventCallback([self](FlValue* event) {
|
||||
// Send event - must be called from main thread
|
||||
// The event is already created on the main thread via g_idle_add in mpv_player.cc
|
||||
send_event(self, event);
|
||||
});
|
||||
|
||||
response = FL_METHOD_RESPONSE(
|
||||
fl_method_success_response_new(fl_value_new_bool(TRUE)));
|
||||
// Return the texture ID for the Dart Texture widget
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(
|
||||
fl_value_new_int(mpv_texture_get_id(self->texture))));
|
||||
} else {
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new(
|
||||
"INIT_FAILED", "Failed to initialize MPV player", nullptr));
|
||||
@@ -310,18 +160,18 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
}
|
||||
} else if (strcmp(method, "dispose") == 0) {
|
||||
if (self->player) {
|
||||
// Make GL context current before disposing mpv GL resources
|
||||
gtk_gl_area_make_current(self->gl_area);
|
||||
self->player->Dispose();
|
||||
self->player.reset();
|
||||
}
|
||||
if (self->texture) {
|
||||
mpv_texture_dispose(self->texture);
|
||||
fl_texture_registrar_unregister_texture(self->texture_registrar,
|
||||
FL_TEXTURE(self->texture));
|
||||
g_object_unref(self->texture);
|
||||
self->texture = nullptr;
|
||||
}
|
||||
self->initialized = FALSE;
|
||||
self->visible = FALSE;
|
||||
gtk_widget_set_visible(GTK_WIDGET(self->gl_area), FALSE);
|
||||
if (self->flutter_view != nullptr) {
|
||||
// Force Flutter view to redraw
|
||||
gtk_widget_queue_draw(self->flutter_view);
|
||||
}
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
|
||||
} else if (strcmp(method, "command") == 0) {
|
||||
if (!self->player || !self->initialized) {
|
||||
@@ -342,8 +192,6 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
command_args.push_back(fl_value_get_string(item));
|
||||
}
|
||||
}
|
||||
// Use async command to prevent UI blocking during network operations
|
||||
// Take ownership of method_call to respond asynchronously
|
||||
g_object_ref(method_call);
|
||||
self->player->CommandAsync(command_args, [method_call](int error) {
|
||||
g_autoptr(FlMethodResponse) async_response = nullptr;
|
||||
@@ -356,7 +204,7 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
fl_method_call_respond(method_call, async_response, nullptr);
|
||||
g_object_unref(method_call);
|
||||
});
|
||||
return; // Response will be sent asynchronously
|
||||
return; // Response sent asynchronously
|
||||
}
|
||||
}
|
||||
} else if (strcmp(method, "setProperty") == 0) {
|
||||
@@ -381,6 +229,22 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
|
||||
}
|
||||
}
|
||||
} else if (strcmp(method, "setLogLevel") == 0) {
|
||||
if (!self->player || !self->initialized) {
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new(
|
||||
"NOT_INITIALIZED", "Player not initialized", nullptr));
|
||||
} else {
|
||||
FlValue* level_value = fl_value_lookup_string(args, "level");
|
||||
|
||||
if (level_value == nullptr ||
|
||||
fl_value_get_type(level_value) != FL_VALUE_TYPE_STRING) {
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new(
|
||||
"INVALID_ARGS", "Missing 'level'", nullptr));
|
||||
} else {
|
||||
self->player->SetLogLevel(fl_value_get_string(level_value));
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
|
||||
}
|
||||
}
|
||||
} else if (strcmp(method, "getProperty") == 0) {
|
||||
if (!self->player || !self->initialized) {
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new(
|
||||
@@ -440,14 +304,11 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
response = FL_METHOD_RESPONSE(fl_method_error_response_new(
|
||||
"INVALID_ARGS", "Missing 'visible'", nullptr));
|
||||
} else {
|
||||
gboolean visible = fl_value_get_bool(visible_value);
|
||||
self->visible = visible;
|
||||
self->visible = fl_value_get_bool(visible_value);
|
||||
|
||||
// Show/hide the GL area.
|
||||
gtk_widget_set_visible(GTK_WIDGET(self->gl_area), visible);
|
||||
|
||||
if (visible) {
|
||||
gtk_gl_area_queue_render(self->gl_area);
|
||||
if (self->visible && self->texture) {
|
||||
// Trigger a frame render when becoming visible
|
||||
mpv_texture_mark_frame_available(self->texture);
|
||||
}
|
||||
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define MPV_PLUGIN_H_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -12,28 +11,18 @@ G_BEGIN_DECLS
|
||||
|
||||
/// Plugin for MPV video playback on Linux.
|
||||
///
|
||||
/// This plugin uses OpenGL rendering via GtkGLArea,
|
||||
/// positioned behind the Flutter view using a GtkOverlay.
|
||||
/// This plugin renders mpv video through Flutter's GPU-accelerated
|
||||
/// texture pipeline via FlTextureGL.
|
||||
|
||||
#define MPV_PLUGIN_TYPE (mpv_plugin_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE(MpvPlugin, mpv_plugin, MPV, PLUGIN, GObject)
|
||||
|
||||
/// Creates a new MpvPlugin instance.
|
||||
/// @param registrar The Flutter plugin registrar.
|
||||
/// @param overlay The GtkOverlay containing the GtkGLArea and FlView.
|
||||
/// @param gl_area The GtkGLArea widget for video rendering.
|
||||
/// @param flutter_view The Flutter view widget (for visibility control).
|
||||
MpvPlugin* mpv_plugin_new(FlPluginRegistrar* registrar,
|
||||
GtkOverlay* overlay,
|
||||
GtkGLArea* gl_area,
|
||||
GtkWidget* flutter_view);
|
||||
MpvPlugin* mpv_plugin_new(FlPluginRegistrar* registrar);
|
||||
|
||||
/// Registers the plugin with Flutter.
|
||||
void mpv_plugin_register_with_registrar(FlPluginRegistrar* registrar,
|
||||
GtkOverlay* overlay,
|
||||
GtkGLArea* gl_area,
|
||||
GtkWidget* flutter_view);
|
||||
void mpv_plugin_register_with_registrar(FlPluginRegistrar* registrar);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
#include "mpv_texture.h"
|
||||
|
||||
#include <epoxy/gl.h>
|
||||
|
||||
struct _MpvTexture {
|
||||
FlTextureGL parent_instance;
|
||||
|
||||
mpv::MpvPlayer* player; // not owned
|
||||
FlTextureRegistrar* registrar; // not owned
|
||||
FlView* view; // not owned, for querying allocation size
|
||||
|
||||
GLuint fbo;
|
||||
GLuint texture;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MpvTexture, mpv_texture, fl_texture_gl_get_type())
|
||||
|
||||
static void ensure_fbo(MpvTexture* self, int32_t w, int32_t h) {
|
||||
if (self->fbo != 0 && self->width == w && self->height == h) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete old resources.
|
||||
if (self->fbo != 0) {
|
||||
glDeleteFramebuffers(1, &self->fbo);
|
||||
self->fbo = 0;
|
||||
}
|
||||
if (self->texture != 0) {
|
||||
glDeleteTextures(1, &self->texture);
|
||||
self->texture = 0;
|
||||
}
|
||||
|
||||
self->width = w;
|
||||
self->height = h;
|
||||
|
||||
glGenTextures(1, &self->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, self->texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glGenFramebuffers(1, &self->fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, self->fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
self->texture, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
static gboolean mpv_texture_populate(FlTextureGL* gl_texture,
|
||||
uint32_t* target,
|
||||
uint32_t* name,
|
||||
uint32_t* width,
|
||||
uint32_t* height,
|
||||
GError** error) {
|
||||
MpvTexture* self = MPV_TEXTURE(gl_texture);
|
||||
|
||||
if (!self->player) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Lazily create the mpv render context on first populate() call,
|
||||
// since Flutter's GL context is current here.
|
||||
if (!self->player->HasRenderContext()) {
|
||||
if (!self->player->InitRenderContext()) {
|
||||
g_set_error(error, g_quark_from_static_string("mpv"), 0,
|
||||
"Failed to create mpv render context");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine target size from the FlView widget allocation.
|
||||
GtkAllocation alloc;
|
||||
gtk_widget_get_allocation(GTK_WIDGET(self->view), &alloc);
|
||||
int scale = gtk_widget_get_scale_factor(GTK_WIDGET(self->view));
|
||||
int32_t w = alloc.width * scale;
|
||||
int32_t h = alloc.height * scale;
|
||||
|
||||
if (w <= 0 || h <= 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ensure_fbo(self, w, h);
|
||||
|
||||
// Save GL state that mpv may clobber.
|
||||
GLint prev_viewport[4];
|
||||
GLint prev_scissor_box[4];
|
||||
GLboolean prev_blend, prev_scissor_test;
|
||||
GLint prev_blend_src, prev_blend_dst;
|
||||
GLint prev_fbo;
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, prev_viewport);
|
||||
glGetIntegerv(GL_SCISSOR_BOX, prev_scissor_box);
|
||||
glGetBooleanv(GL_BLEND, &prev_blend);
|
||||
glGetBooleanv(GL_SCISSOR_TEST, &prev_scissor_test);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &prev_blend_src);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &prev_blend_dst);
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prev_fbo);
|
||||
|
||||
// Render mpv into our FBO.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, self->fbo);
|
||||
glViewport(0, 0, w, h);
|
||||
self->player->ClearRedrawFlag();
|
||||
self->player->Render(w, h, static_cast<int>(self->fbo));
|
||||
|
||||
// Restore GL state.
|
||||
glViewport(prev_viewport[0], prev_viewport[1], prev_viewport[2],
|
||||
prev_viewport[3]);
|
||||
glScissor(prev_scissor_box[0], prev_scissor_box[1], prev_scissor_box[2],
|
||||
prev_scissor_box[3]);
|
||||
if (prev_blend)
|
||||
glEnable(GL_BLEND);
|
||||
else
|
||||
glDisable(GL_BLEND);
|
||||
if (prev_scissor_test)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
else
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glBlendFunc(prev_blend_src, prev_blend_dst);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, prev_fbo);
|
||||
|
||||
*target = GL_TEXTURE_2D;
|
||||
*name = self->texture;
|
||||
*width = static_cast<uint32_t>(w);
|
||||
*height = static_cast<uint32_t>(h);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void mpv_texture_class_init(MpvTextureClass* klass) {
|
||||
FL_TEXTURE_GL_CLASS(klass)->populate = mpv_texture_populate;
|
||||
}
|
||||
|
||||
static void mpv_texture_init(MpvTexture* self) {
|
||||
self->player = nullptr;
|
||||
self->registrar = nullptr;
|
||||
self->view = nullptr;
|
||||
self->fbo = 0;
|
||||
self->texture = 0;
|
||||
self->width = 0;
|
||||
self->height = 0;
|
||||
}
|
||||
|
||||
MpvTexture* mpv_texture_new(mpv::MpvPlayer* player,
|
||||
FlTextureRegistrar* registrar,
|
||||
FlView* view) {
|
||||
MpvTexture* self = MPV_TEXTURE(g_object_new(MPV_TEXTURE_TYPE, nullptr));
|
||||
self->player = player;
|
||||
self->registrar = registrar;
|
||||
self->view = view;
|
||||
return self;
|
||||
}
|
||||
|
||||
void mpv_texture_mark_frame_available(MpvTexture* self) {
|
||||
if (self && self->registrar) {
|
||||
fl_texture_registrar_mark_texture_frame_available(
|
||||
self->registrar, FL_TEXTURE(self));
|
||||
}
|
||||
}
|
||||
|
||||
void mpv_texture_dispose(MpvTexture* self) {
|
||||
if (!self) return;
|
||||
|
||||
if (self->fbo != 0) {
|
||||
glDeleteFramebuffers(1, &self->fbo);
|
||||
self->fbo = 0;
|
||||
}
|
||||
if (self->texture != 0) {
|
||||
glDeleteTextures(1, &self->texture);
|
||||
self->texture = 0;
|
||||
}
|
||||
|
||||
self->player = nullptr;
|
||||
self->registrar = nullptr;
|
||||
self->view = nullptr;
|
||||
}
|
||||
|
||||
int64_t mpv_texture_get_id(MpvTexture* self) {
|
||||
return fl_texture_get_id(FL_TEXTURE(self));
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef MPV_TEXTURE_H_
|
||||
#define MPV_TEXTURE_H_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
#include "mpv_player.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MPV_TEXTURE_TYPE (mpv_texture_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE(MpvTexture, mpv_texture, MPV, TEXTURE, FlTextureGL)
|
||||
|
||||
/// Creates a new MpvTexture that renders mpv video to an offscreen FBO.
|
||||
MpvTexture* mpv_texture_new(mpv::MpvPlayer* player,
|
||||
FlTextureRegistrar* registrar,
|
||||
FlView* view);
|
||||
|
||||
/// Notifies Flutter that a new frame is available.
|
||||
void mpv_texture_mark_frame_available(MpvTexture* self);
|
||||
|
||||
/// Cleans up GL resources (FBO/texture).
|
||||
void mpv_texture_dispose(MpvTexture* self);
|
||||
|
||||
/// Returns the Flutter texture ID.
|
||||
int64_t mpv_texture_get_id(MpvTexture* self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // MPV_TEXTURE_H_
|
||||
@@ -11,29 +11,11 @@
|
||||
struct _MyApplication {
|
||||
GtkApplication parent_instance;
|
||||
char** dart_entrypoint_arguments;
|
||||
|
||||
// MPV-related widgets
|
||||
GtkOverlay* overlay;
|
||||
GtkGLArea* gl_area;
|
||||
FlView* flutter_view;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
/// Sets up an RGBA visual for transparency support.
|
||||
static void setup_rgba_visual(GtkWidget* widget) {
|
||||
GdkScreen* screen = gtk_widget_get_screen(widget);
|
||||
if (!gdk_screen_is_composited(screen)) {
|
||||
g_warning("Screen is not composited - transparency may not work");
|
||||
}
|
||||
GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
|
||||
if (visual != nullptr) {
|
||||
gtk_widget_set_visual(widget, visual);
|
||||
} else {
|
||||
g_warning("No RGBA visual available");
|
||||
}
|
||||
}
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
@@ -69,72 +51,23 @@ static void my_application_activate(GApplication* application) {
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
|
||||
// Set up RGBA visual for transparency support.
|
||||
gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
|
||||
setup_rgba_visual(GTK_WIDGET(window));
|
||||
|
||||
// Create the overlay container.
|
||||
// The overlay allows us to layer widgets on top of each other:
|
||||
// - Bottom layer: GtkGLArea for mpv video rendering
|
||||
// - Top layer: FlView (Flutter) with transparent background
|
||||
self->overlay = GTK_OVERLAY(gtk_overlay_new());
|
||||
gtk_widget_show(GTK_WIDGET(self->overlay));
|
||||
|
||||
// Create the GtkGLArea for mpv video rendering.
|
||||
// This will be the bottom layer (behind Flutter).
|
||||
self->gl_area = GTK_GL_AREA(gtk_gl_area_new());
|
||||
gtk_widget_set_hexpand(GTK_WIDGET(self->gl_area), TRUE);
|
||||
gtk_widget_set_vexpand(GTK_WIDGET(self->gl_area), TRUE);
|
||||
|
||||
// Configure GL area for transparency and proper rendering.
|
||||
gtk_gl_area_set_has_alpha(self->gl_area, TRUE);
|
||||
gtk_gl_area_set_has_depth_buffer(self->gl_area, FALSE);
|
||||
gtk_gl_area_set_has_stencil_buffer(self->gl_area, FALSE);
|
||||
|
||||
// Make GL area non-interactive so mouse events pass through to Flutter.
|
||||
gtk_widget_set_can_focus(GTK_WIDGET(self->gl_area), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(self->gl_area), FALSE);
|
||||
|
||||
// Set the GL area as the base widget of the overlay.
|
||||
// Initially hidden - will be shown when video playback starts.
|
||||
gtk_widget_set_visible(GTK_WIDGET(self->gl_area), FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(self->overlay), GTK_WIDGET(self->gl_area));
|
||||
|
||||
// Create the Flutter view.
|
||||
// Create the Flutter view (opaque — no overlay needed).
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project,
|
||||
self->dart_entrypoint_arguments);
|
||||
|
||||
self->flutter_view = fl_view_new(project);
|
||||
gtk_widget_set_hexpand(GTK_WIDGET(self->flutter_view), TRUE);
|
||||
gtk_widget_set_vexpand(GTK_WIDGET(self->flutter_view), TRUE);
|
||||
|
||||
// Set up RGBA visual for transparency support.
|
||||
// Note: app_paintable is only set on the window (line 73), not on child widgets,
|
||||
// to avoid redundant composition passes.
|
||||
setup_rgba_visual(GTK_WIDGET(self->flutter_view));
|
||||
|
||||
// Enable transparent background for the Flutter view.
|
||||
// This allows the mpv video to show through transparent areas.
|
||||
GdkRGBA transparent = {0.0, 0.0, 0.0, 0.0};
|
||||
fl_view_set_background_color(self->flutter_view, &transparent);
|
||||
|
||||
// Add the Flutter view as an overlay on top of the GL area.
|
||||
gtk_widget_show(GTK_WIDGET(self->flutter_view));
|
||||
gtk_overlay_add_overlay(self->overlay, GTK_WIDGET(self->flutter_view));
|
||||
|
||||
// Add the overlay to the window.
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(self->overlay));
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(self->flutter_view));
|
||||
|
||||
// Register Flutter plugins.
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(self->flutter_view));
|
||||
|
||||
// Register the MPV plugin with the GL area and Flutter view for video rendering.
|
||||
// Register the MPV plugin (uses FlTextureGL — no overlay/GtkGLArea needed).
|
||||
FlPluginRegistrar* registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(FL_PLUGIN_REGISTRY(self->flutter_view),
|
||||
"MpvPlugin");
|
||||
mpv_plugin_register_with_registrar(registrar, self->overlay, self->gl_area,
|
||||
GTK_WIDGET(self->flutter_view));
|
||||
mpv_plugin_register_with_registrar(registrar);
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
gtk_widget_grab_focus(GTK_WIDGET(self->flutter_view));
|
||||
@@ -163,19 +96,11 @@ static gboolean my_application_local_command_line(GApplication* application,
|
||||
|
||||
// Implements GApplication::startup.
|
||||
static void my_application_startup(GApplication* application) {
|
||||
// MyApplication* self = MY_APPLICATION(object);
|
||||
|
||||
// Perform any actions required at application startup.
|
||||
|
||||
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
|
||||
}
|
||||
|
||||
// Implements GApplication::shutdown.
|
||||
static void my_application_shutdown(GApplication* application) {
|
||||
// MyApplication* self = MY_APPLICATION(object);
|
||||
|
||||
// Perform any actions required at application shutdown.
|
||||
|
||||
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
|
||||
}
|
||||
|
||||
@@ -196,16 +121,10 @@ static void my_application_class_init(MyApplicationClass* klass) {
|
||||
}
|
||||
|
||||
static void my_application_init(MyApplication* self) {
|
||||
self->overlay = nullptr;
|
||||
self->gl_area = nullptr;
|
||||
self->flutter_view = nullptr;
|
||||
}
|
||||
|
||||
MyApplication* my_application_new() {
|
||||
// Set the program name to the application ID, which helps various systems
|
||||
// like GTK and desktop environments map this running application to its
|
||||
// corresponding .desktop file. This ensures better integration by allowing
|
||||
// the application to be recognized beyond its binary name.
|
||||
g_set_prgname(APPLICATION_ID);
|
||||
|
||||
return MY_APPLICATION(g_object_new(my_application_get_type(),
|
||||
|
||||
@@ -28,5 +28,7 @@
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>FLTEnableMergedPlatformUIThread</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -191,6 +191,11 @@ class MpvPlayerCore: NSObject {
|
||||
|
||||
// MARK: - MPV Properties and Commands
|
||||
|
||||
func setLogLevel(_ level: String) {
|
||||
guard mpv != nil else { return }
|
||||
mpv_request_log_messages(mpv, level)
|
||||
}
|
||||
|
||||
func setProperty(_ name: String, value: String) {
|
||||
guard mpv != nil else { return }
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ class MpvPlayerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, MpvPlayerD
|
||||
case "updateFrame":
|
||||
handleUpdateFrame(result: result)
|
||||
|
||||
case "setLogLevel":
|
||||
handleSetLogLevel(call: call, result: result)
|
||||
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
@@ -218,6 +221,20 @@ class MpvPlayerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, MpvPlayerD
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSetLogLevel(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
guard let playerCore = playerCore else {
|
||||
result(FlutterError(code: "NOT_INITIALIZED", message: "Player not initialized", details: nil))
|
||||
return
|
||||
}
|
||||
guard let args = call.arguments as? [String: Any],
|
||||
let level = args["level"] as? String else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: "Missing 'level'", details: nil))
|
||||
return
|
||||
}
|
||||
playerCore.setLogLevel(level)
|
||||
result(nil)
|
||||
}
|
||||
|
||||
// MARK: - MpvPlayerDelegate
|
||||
|
||||
func onPropertyChange(name: String, value: Any?) {
|
||||
|
||||
+4
-4
@@ -729,8 +729,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "6463fd18875ead347e739189b9687307f629f090"
|
||||
resolved-ref: "6463fd18875ead347e739189b9687307f629f090"
|
||||
ref: "467251821f76bba37ed4c6d5ee1c9de27c285e34"
|
||||
resolved-ref: "467251821f76bba37ed4c6d5ee1c9de27c285e34"
|
||||
url: "https://github.com/edde746/os-media-controls"
|
||||
source: git
|
||||
version: "0.2.0"
|
||||
@@ -1263,10 +1263,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: universal_gamepad
|
||||
sha256: fff36a78ac91986ec4ef6281e16df644f14b690a0c4978792e86055e0cc809ad
|
||||
sha256: afd3106195aa2052ec23fe61069cad8d0caed255c7e2e6ed33a403e0a94f365e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.4.4"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
name: plezy
|
||||
description: "A beautiful Plex client for Flutter"
|
||||
publish_to: "none"
|
||||
version: 1.17.0+38
|
||||
version: 1.18.0+39
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
@@ -30,7 +30,7 @@ dependencies:
|
||||
os_media_controls:
|
||||
git:
|
||||
url: https://github.com/edde746/os-media-controls
|
||||
ref: 6463fd18875ead347e739189b9687307f629f090
|
||||
ref: 467251821f76bba37ed4c6d5ee1c9de27c285e34
|
||||
rate_limiter: ^1.0.0
|
||||
wakelock_plus:
|
||||
git:
|
||||
@@ -38,7 +38,7 @@ dependencies:
|
||||
path: wakelock_plus
|
||||
path_provider: ^2.1.0
|
||||
path: ^1.9.0
|
||||
universal_gamepad: ^1.1.0
|
||||
universal_gamepad: ^1.4.4
|
||||
drift: ^2.28.2
|
||||
sqlite3_flutter_libs: ^0.5.41
|
||||
workmanager: ^0.9.0+3
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -W 2>/dev/null || pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd -W 2>/dev/null || pwd)"
|
||||
|
||||
echo "==> Building plezy for Steam (Docker)..."
|
||||
MSYS_NO_PATHCONV=1 docker build \
|
||||
--platform linux/amd64 \
|
||||
-f "$PROJECT_ROOT/scripts/steam.Dockerfile" \
|
||||
-t plezy-steam-build \
|
||||
"$PROJECT_ROOT"
|
||||
|
||||
echo "==> Extracting tarball..."
|
||||
MSYS_NO_PATHCONV=1 docker create --name plezy-steam-extract plezy-steam-build true 2>/dev/null \
|
||||
|| { docker rm plezy-steam-extract 2>/dev/null; MSYS_NO_PATHCONV=1 docker create --name plezy-steam-extract plezy-steam-build true; }
|
||||
MSYS_NO_PATHCONV=1 docker cp plezy-steam-extract:/app/plezy-steam-linux-x64.tar.gz "$PROJECT_ROOT/"
|
||||
docker rm plezy-steam-extract
|
||||
|
||||
echo "==> Output: plezy-steam-linux-x64.tar.gz"
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "==> Assembling Steam bundle..."
|
||||
BUNDLE=build/linux/x64/release/bundle
|
||||
BUNDLE_LIB="$BUNDLE/lib"
|
||||
|
||||
# Copy libmpv + shaderc into bundle
|
||||
LIBMPV_DIR=$(dirname "$(find /build/libmpv-prefix -name libmpv.so | head -1)")
|
||||
cp -a "$LIBMPV_DIR"/libmpv.so* "$BUNDLE_LIB/"
|
||||
cp -a /build/libmpv-prefix/lib/libshaderc_shared.so* "$BUNDLE_LIB/"
|
||||
|
||||
# Bundle runtime deps that the Steam Runtime doesn't ship.
|
||||
# /steam-rt-libs.txt was snapshot before we built anything (see Dockerfile).
|
||||
# Iteratively resolve the main binary + all bundled .so files until no new deps appear.
|
||||
echo ""
|
||||
echo "==> Bundling runtime dependencies..."
|
||||
RT_LIBS="/steam-rt-libs.txt"
|
||||
while true; do
|
||||
new_count=0
|
||||
while read dep; do
|
||||
dep_name=$(basename "$dep")
|
||||
if ! grep -qF "$dep_name" "$RT_LIBS"; then
|
||||
if [ ! -f "$BUNDLE_LIB/$dep_name" ]; then
|
||||
echo " Bundling $dep_name"
|
||||
cp -a "$dep" "$BUNDLE_LIB/"
|
||||
dep_dir=$(dirname "$dep")
|
||||
dep_base=$(echo "$dep_name" | sed 's/\.so.*//')
|
||||
cp -a "$dep_dir"/${dep_base}.so* "$BUNDLE_LIB/" 2>/dev/null || true
|
||||
new_count=$((new_count + 1))
|
||||
fi
|
||||
fi
|
||||
done < <({ ldd "$BUNDLE/plezy" 2>/dev/null; find "$BUNDLE_LIB" -name '*.so*' -type f -exec ldd {} \; 2>/dev/null; } | grep "=> /" | awk '{print $3}' | sort -u)
|
||||
if [ "$new_count" -eq 0 ]; then
|
||||
break
|
||||
fi
|
||||
echo " Bundled $new_count new libraries, re-scanning..."
|
||||
done
|
||||
|
||||
# Verify all deps resolve
|
||||
echo ""
|
||||
echo "==> Checking dependencies..."
|
||||
MISSING=$({ LD_LIBRARY_PATH="$BUNDLE_LIB" ldd "$BUNDLE/plezy" 2>&1; find "$BUNDLE_LIB" -name '*.so*' -type f -exec env LD_LIBRARY_PATH="$BUNDLE_LIB" ldd {} \; 2>&1; } | grep "not found" | sort -u || true)
|
||||
if [[ -n "$MISSING" ]]; then
|
||||
echo "WARNING: Unresolved dependencies (will need Steam runtime):"
|
||||
echo "$MISSING"
|
||||
else
|
||||
echo "All dependencies resolved."
|
||||
fi
|
||||
|
||||
# Create launcher script that sets LD_LIBRARY_PATH for bundled libs
|
||||
echo ""
|
||||
echo "==> Creating launcher script..."
|
||||
mv "$BUNDLE/plezy" "$BUNDLE/plezy.bin"
|
||||
cat > "$BUNDLE/plezy" <<'LAUNCHER'
|
||||
#!/usr/bin/env bash
|
||||
SCRIPT_PATH="$(readlink -f "$0")"
|
||||
INSTALL_DIR="$(dirname "$SCRIPT_PATH")"
|
||||
|
||||
export LD_LIBRARY_PATH="$INSTALL_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
|
||||
exec "$INSTALL_DIR/plezy.bin" "$@"
|
||||
LAUNCHER
|
||||
chmod +x "$BUNDLE/plezy"
|
||||
|
||||
echo ""
|
||||
echo "==> Creating tarball..."
|
||||
cd "$BUNDLE"
|
||||
tar -czf /app/plezy-steam-linux-x64.tar.gz *
|
||||
|
||||
echo ""
|
||||
echo "==> Done! Output: plezy-steam-linux-x64.tar.gz"
|
||||
@@ -0,0 +1,41 @@
|
||||
# Snapshot libs from the runtime (not SDK) — this is what's actually on the Steam Deck.
|
||||
FROM registry.gitlab.steamos.cloud/steamrt/sniper/platform:latest AS runtime-snapshot
|
||||
RUN find /lib /usr/lib -name '*.so*' -type f -o -type l 2>/dev/null | xargs -r basename -a | sort -u > /steam-rt-libs.txt
|
||||
|
||||
FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
|
||||
COPY --from=runtime-snapshot /steam-rt-libs.txt /steam-rt-libs.txt
|
||||
|
||||
# ─── Layer 1: apt deps (cached unless this block changes) ─────────────────────
|
||||
RUN apt-get update -qq && apt-get install -y -qq \
|
||||
clang cmake meson ninja-build pkg-config nasm git curl unzip xz-utils \
|
||||
libgtk-3-dev libevdev-dev liblzma-dev \
|
||||
libasound2-dev libass-dev libfreetype-dev libfontconfig-dev libfribidi-dev libharfbuzz-dev \
|
||||
libepoxy-dev libegl-dev libgl-dev libgnutls28-dev \
|
||||
libpipewire-0.3-dev libva-dev libvdpau-dev \
|
||||
libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev libxpresent-dev \
|
||||
libxkbcommon-dev libpulse-dev libdbus-1-dev libdrm-dev libgbm-dev \
|
||||
libwayland-dev wayland-protocols liblcms2-dev python3-pip \
|
||||
&& pip3 install meson --upgrade \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# ─── Layer 2: libmpv (cached unless build-libmpv.sh changes) ──────────────────
|
||||
WORKDIR /build
|
||||
COPY linux/packaging/build-libmpv.sh linux/packaging/
|
||||
RUN bash linux/packaging/build-libmpv.sh
|
||||
|
||||
# ─── Layer 3: Flutter SDK (cached unless Flutter channel changes) ──────────────
|
||||
RUN git clone --depth 1 --branch stable https://github.com/flutter/flutter.git /opt/flutter
|
||||
ENV PATH="/opt/flutter/bin:$PATH"
|
||||
RUN flutter --disable-analytics \
|
||||
&& flutter config --no-cli-animations \
|
||||
&& flutter precache --linux
|
||||
|
||||
# ─── Layer 4: App build (runs on every source change) ─────────────────────────
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
ENV PKG_CONFIG_PATH="/build/libmpv-prefix/lib/pkgconfig:/build/libmpv-prefix/lib/x86_64-linux-gnu/pkgconfig"
|
||||
RUN flutter pub get \
|
||||
&& flutter build linux --release
|
||||
|
||||
# ─── Layer 5: Bundle assembly + dep bundling ──────────────────────────────────
|
||||
RUN bash scripts/bundle_steam.sh
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_ID=4435320
|
||||
DEPOT_WIN=4435321
|
||||
DEPOT_LINUX=4435322
|
||||
REPO="edde746/plezy"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
WORK="$SCRIPT_DIR/build"
|
||||
|
||||
# Get latest release tag
|
||||
TAG=$(gh release view --repo "$REPO" --json tagName -q .tagName)
|
||||
echo "Latest release: $TAG"
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
|
||||
# Download & extract
|
||||
echo "Downloading Windows build..."
|
||||
gh release download "$TAG" --repo "$REPO" -p "plezy-windows-x64-portable.7z" -D "$WORK"
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
unar -o "$WORK" "$WORK/plezy-windows-x64-portable.7z"
|
||||
else
|
||||
7z x "$WORK/plezy-windows-x64-portable.7z" -o"$WORK" -y
|
||||
fi
|
||||
mv "$WORK"/plezy-windows-x64-portable "$WORK/windows"
|
||||
|
||||
echo "Extracting Linux Steam build..."
|
||||
STEAM_TARBALL="$SCRIPT_DIR/../plezy-steam-linux-x64.tar.gz"
|
||||
if [[ ! -f "$STEAM_TARBALL" ]]; then
|
||||
echo "Error: $STEAM_TARBALL not found. Run build_steam.sh first." >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$WORK/linux"
|
||||
tar xzf "$STEAM_TARBALL" -C "$WORK/linux"
|
||||
|
||||
# Generate VDF files
|
||||
cat > "$WORK/app_build.vdf" <<EOF
|
||||
"appbuild"
|
||||
{
|
||||
"appid" "$APP_ID"
|
||||
"desc" "$TAG"
|
||||
"buildoutput" "$WORK/output"
|
||||
"contentroot" "$WORK"
|
||||
"setlive" "public"
|
||||
"depots"
|
||||
{
|
||||
"$DEPOT_WIN"
|
||||
{
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "windows/*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
}
|
||||
"$DEPOT_LINUX"
|
||||
{
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "linux/*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p "$WORK/output"
|
||||
|
||||
echo "Uploading to Steam..."
|
||||
steamcmd +login "$STEAM_USER" +run_app_build "$WORK/app_build.vdf" +quit
|
||||
|
||||
echo "Done! Uploaded $TAG to Steam."
|
||||
@@ -84,8 +84,8 @@ bool MpvPlayer::Initialize(HWND container, HWND flutter_window) {
|
||||
mpv_set_option_string(mpv_, "tone-mapping", "auto");
|
||||
mpv_set_option_string(mpv_, "hdr-compute-peak", "auto");
|
||||
|
||||
// Enable logging
|
||||
mpv_request_log_messages(mpv_, "v");
|
||||
// Default to warn-level logging; Dart side can raise to "v" if debug logging is enabled.
|
||||
mpv_request_log_messages(mpv_, "warn");
|
||||
|
||||
// Initialize mpv.
|
||||
LogToFile("MpvPlayer::Initialize - calling mpv_initialize()");
|
||||
@@ -282,6 +282,11 @@ void MpvPlayer::SetVisible(bool visible) {
|
||||
}
|
||||
}
|
||||
|
||||
void MpvPlayer::SetLogLevel(const std::string& level) {
|
||||
if (!mpv_) return;
|
||||
mpv_request_log_messages(mpv_, level.c_str());
|
||||
}
|
||||
|
||||
void MpvPlayer::SetEventCallback(EventCallback callback) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
event_callback_ = std::move(callback);
|
||||
|
||||
@@ -65,6 +65,9 @@ class MpvPlayer {
|
||||
// Shows or hides the video window.
|
||||
void SetVisible(bool visible);
|
||||
|
||||
// Sets the MPV log message level (e.g., "warn", "v", "debug").
|
||||
void SetLogLevel(const std::string& level);
|
||||
|
||||
// Sets the event callback for property changes and events.
|
||||
void SetEventCallback(EventCallback callback);
|
||||
|
||||
|
||||
@@ -248,6 +248,29 @@ void MpvPlayerPlugin::HandleMethodCall(
|
||||
player_->SetProperty(std::get<std::string>(name_it->second),
|
||||
std::get<std::string>(value_it->second));
|
||||
result->Success();
|
||||
} else if (method == "setLogLevel") {
|
||||
if (!player_ || !player_->IsInitialized()) {
|
||||
result->Error("NOT_INITIALIZED", "Player not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto* args = method_call.arguments();
|
||||
if (!args || !std::holds_alternative<flutter::EncodableMap>(*args)) {
|
||||
result->Error("INVALID_ARGS", "Expected map argument");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& map = std::get<flutter::EncodableMap>(*args);
|
||||
auto level_it = map.find(flutter::EncodableValue("level"));
|
||||
|
||||
if (level_it == map.end() ||
|
||||
!std::holds_alternative<std::string>(level_it->second)) {
|
||||
result->Error("INVALID_ARGS", "Missing 'level'");
|
||||
return;
|
||||
}
|
||||
|
||||
player_->SetLogLevel(std::get<std::string>(level_it->second));
|
||||
result->Success();
|
||||
} else if (method == "getProperty") {
|
||||
if (!player_ || !player_->IsInitialized()) {
|
||||
result->Error("NOT_INITIALIZED", "Player not initialized");
|
||||
|
||||
Reference in New Issue
Block a user