Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b796491e60 | ||
|
|
2ad06c4dbc | ||
|
|
3494fbc5be | ||
|
|
c2ff56b1f1 | ||
|
|
95436529c6 | ||
|
|
ad7f381f54 | ||
|
|
d50a86501b | ||
|
|
d9bc7d6b86 | ||
|
|
8ab972691a | ||
|
|
47cb3f2614 |
+60
-35
@@ -1,4 +1,4 @@
|
||||
name: Build Flutter App
|
||||
name: Build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -57,27 +57,35 @@ jobs:
|
||||
storeFile=upload-keystore.jks
|
||||
EOF
|
||||
|
||||
- name: Build APK
|
||||
run: flutter build apk --release --dart-define=ENABLE_UPDATE_CHECK=true
|
||||
- name: Build APKs
|
||||
run: flutter build apk --release --split-per-abi --dart-define=ENABLE_UPDATE_CHECK=true
|
||||
|
||||
- name: Clean up keystore
|
||||
if: always()
|
||||
run: rm -f android/app/upload-keystore.jks android/key.properties
|
||||
|
||||
- name: Rename APK
|
||||
- name: Package APKs
|
||||
run: |
|
||||
cp build/app/outputs/flutter-apk/app-release.apk plezy-android.apk
|
||||
tar -czf plezy-android-arm64-v8a.tar.gz -C build/app/outputs/flutter-apk app-arm64-v8a-release.apk --transform 's/app-arm64-v8a-release.apk/plezy.apk/'
|
||||
tar -czf plezy-android-armeabi-v7a.tar.gz -C build/app/outputs/flutter-apk app-armeabi-v7a-release.apk --transform 's/app-armeabi-v7a-release.apk/plezy.apk/'
|
||||
tar -czf plezy-android-x86_64.tar.gz -C build/app/outputs/flutter-apk app-x86_64-release.apk --transform 's/app-x86_64-release.apk/plezy.apk/'
|
||||
|
||||
- name: Attest APK
|
||||
- name: Attest APKs
|
||||
uses: actions/attest-build-provenance@v2
|
||||
with:
|
||||
subject-path: plezy-android.apk
|
||||
subject-path: |
|
||||
plezy-android-arm64-v8a.tar.gz
|
||||
plezy-android-armeabi-v7a.tar.gz
|
||||
plezy-android-x86_64.tar.gz
|
||||
|
||||
- name: Upload APK
|
||||
- name: Upload APKs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android-apk
|
||||
path: plezy-android.apk
|
||||
path: |
|
||||
plezy-android-arm64-v8a.tar.gz
|
||||
plezy-android-armeabi-v7a.tar.gz
|
||||
plezy-android-x86_64.tar.gz
|
||||
|
||||
build-ios:
|
||||
runs-on: macos-26
|
||||
@@ -254,21 +262,23 @@ jobs:
|
||||
echo "Verifying notarization..."
|
||||
xcrun stapler validate "$APP_PATH"
|
||||
|
||||
- name: Create ZIP
|
||||
- name: Create DMG
|
||||
run: |
|
||||
cd build/macos/Build/Products/Release
|
||||
ditto -c -k --sequesterRsrc --keepParent plezy.app $GITHUB_WORKSPACE/plezy-macos.zip
|
||||
mkdir -p dmg-staging
|
||||
cp -R build/macos/Build/Products/Release/plezy.app dmg-staging/
|
||||
ln -s /Applications dmg-staging/Applications
|
||||
hdiutil create -format ULMO -srcfolder dmg-staging -volname "Plezy" plezy-macos.dmg
|
||||
|
||||
- name: Attest macOS ZIP
|
||||
- name: Attest macOS DMG
|
||||
uses: actions/attest-build-provenance@v2
|
||||
with:
|
||||
subject-path: plezy-macos.zip
|
||||
subject-path: plezy-macos.dmg
|
||||
|
||||
- name: Upload macOS ZIP
|
||||
- name: Upload macOS DMG
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: macos-zip
|
||||
path: plezy-macos.zip
|
||||
name: macos-dmg
|
||||
path: plezy-macos.dmg
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
@@ -307,14 +317,14 @@ jobs:
|
||||
uses: actions/attest-build-provenance@v2
|
||||
with:
|
||||
subject-path: |
|
||||
plezy-windows-portable.zip
|
||||
plezy-windows-portable.7z
|
||||
plezy-windows-installer.exe
|
||||
|
||||
- name: Upload Portable Archive
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows-portable
|
||||
path: plezy-windows-portable.zip
|
||||
path: plezy-windows-portable.7z
|
||||
|
||||
- name: Upload Installer
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -349,13 +359,16 @@ jobs:
|
||||
- name: Cache APT packages
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0
|
||||
version: 1.0
|
||||
packages: clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0 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 ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0
|
||||
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0 ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
|
||||
|
||||
- name: Install fpm
|
||||
run: sudo gem install fpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
@@ -368,10 +381,17 @@ jobs:
|
||||
cd build/linux/x64/release/bundle
|
||||
tar -czf $GITHUB_WORKSPACE/plezy-linux.tar.gz *
|
||||
|
||||
- name: Attest Linux tarball
|
||||
- name: Build Linux Packages
|
||||
run: OUTPUT_DIR=$GITHUB_WORKSPACE python3 linux/packaging/build-packages.py
|
||||
|
||||
- name: Attest Linux artifacts
|
||||
uses: actions/attest-build-provenance@v2
|
||||
with:
|
||||
subject-path: plezy-linux.tar.gz
|
||||
subject-path: |
|
||||
plezy-linux.tar.gz
|
||||
plezy-linux.deb
|
||||
plezy-linux.rpm
|
||||
plezy-linux.pkg.tar.zst
|
||||
|
||||
- name: Upload Linux App
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -379,15 +399,17 @@ jobs:
|
||||
name: linux-app
|
||||
path: plezy-linux.tar.gz
|
||||
|
||||
- name: Upload Linux Packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-packages
|
||||
path: |
|
||||
plezy-linux.deb
|
||||
plezy-linux.rpm
|
||||
plezy-linux.pkg.tar.zst
|
||||
|
||||
create-release:
|
||||
needs:
|
||||
[
|
||||
build-android,
|
||||
build-ios,
|
||||
build-macos,
|
||||
build-windows,
|
||||
build-linux,
|
||||
]
|
||||
needs: [build-android, build-ios, build-macos, build-windows, build-linux]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -404,12 +426,15 @@ jobs:
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
artifacts/android-apk/plezy-android.apk
|
||||
artifacts/android-apk/plezy-android-arm64-v8a.tar.gz
|
||||
artifacts/android-apk/plezy-android-armeabi-v7a.tar.gz
|
||||
artifacts/android-apk/plezy-android-x86_64.tar.gz
|
||||
artifacts/ios-ipa/plezy-ios.ipa
|
||||
artifacts/macos-zip/plezy-macos.zip
|
||||
artifacts/windows-portable/plezy-windows-portable.zip
|
||||
artifacts/macos-dmg/plezy-macos.dmg
|
||||
artifacts/windows-portable/plezy-windows-portable.7z
|
||||
artifacts/windows-installer/plezy-windows-installer.exe
|
||||
artifacts/linux-app/plezy-linux.tar.gz
|
||||
artifacts/linux-packages/*
|
||||
draft: true
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
|
||||
@@ -19,9 +19,9 @@ A modern Plex client for desktop and mobile. Built with Flutter for native perfo
|
||||
|
||||
### Desktop
|
||||
- [Windows (x64)](https://github.com/edde746/plezy/releases/latest/download/plezy-windows-installer.exe)
|
||||
- [macOS (Universal)](https://github.com/edde746/plezy/releases/latest/download/plezy-macos.zip)
|
||||
- [Linux (x64)](https://github.com/edde746/plezy/releases/latest/download/plezy-linux.tar.gz)
|
||||
- [NixOS/Nix](https://github.com/mio-19/nurpkgs/tree/main/pkgs/plezy) - Community package by [@mio-19](https://github.com/mio-19) via `nur.repos.mio.plezy`
|
||||
- [macOS (Universal)](https://github.com/edde746/plezy/releases/latest/download/plezy-macos.dmg)
|
||||
- [Linux (x64)](https://github.com/edde746/plezy/releases/latest) - .deb, .rpm, .pkg.tar.zst, and portable tar.gz available
|
||||
- [NixOS/Nix](https://github.com/mio-19/nurpkgs/tree/main/pkgs/plezy) - Community package by [@mio-19](https://github.com/mio-19)
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ PODS:
|
||||
- path_provider_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- share_plus (0.0.1):
|
||||
- Flutter
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
@@ -72,7 +70,6 @@ DEPENDENCIES:
|
||||
- os_media_controls (from `.symlinks/plugins/os_media_controls/ios`)
|
||||
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
|
||||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
|
||||
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/darwin`)
|
||||
@@ -106,8 +103,6 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/package_info_plus/ios"
|
||||
path_provider_foundation:
|
||||
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
||||
share_plus:
|
||||
:path: ".symlinks/plugins/share_plus/ios"
|
||||
shared_preferences_foundation:
|
||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||
sqflite_darwin:
|
||||
@@ -132,7 +127,6 @@ SPEC CHECKSUMS:
|
||||
os_media_controls: 86dceab6245a5325af90fc0fdebe243c42d789b4
|
||||
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
||||
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
|
||||
share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a
|
||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
|
||||
sqlite3: 8d708bc63e9f4ce48f0ad9d6269e478c5ced1d9b
|
||||
|
||||
+8255
-15336
File diff suppressed because it is too large
Load Diff
@@ -146,7 +146,9 @@
|
||||
"maxVolume": "Maximum Volume",
|
||||
"maxVolumeDescription": "Allow volume boost above 100% for quiet media",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "Enter max volume (100-300)"
|
||||
"maxVolumeHint": "Enter max volume (100-300)",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Show what you're watching on Discord"
|
||||
},
|
||||
"search": {
|
||||
"hint": "Search movies, shows, music...",
|
||||
|
||||
@@ -147,7 +147,9 @@
|
||||
"maxVolume": "Maximale Lautstärke",
|
||||
"maxVolumeDescription": "Lautstärke über 100% für leise Medien erlauben",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "Maximale Lautstärke eingeben (100-300)"
|
||||
"maxVolumeHint": "Maximale Lautstärke eingeben (100-300)",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Zeige auf Discord, was du gerade schaust"
|
||||
},
|
||||
"search": {
|
||||
"hint": "Filme, Serien, Musik suchen...",
|
||||
|
||||
@@ -147,7 +147,9 @@
|
||||
"maxVolume": "Volume massimo",
|
||||
"maxVolumeDescription": "Consenti volume superiore al 100% per contenuti audio bassi",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "Inserisci volume massimo (100-300)"
|
||||
"maxVolumeHint": "Inserisci volume massimo (100-300)",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Mostra su Discord cosa stai guardando"
|
||||
},
|
||||
"search": {
|
||||
"hint": "Cerca film. spettacoli, musica...",
|
||||
|
||||
@@ -147,7 +147,9 @@
|
||||
"maxVolume": "최대 볼륨",
|
||||
"maxVolumeDescription": "조용한 미디어를 위해 100% 이상의 볼륨 허용",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "최대 볼륨 입력 (100-300)"
|
||||
"maxVolumeHint": "최대 볼륨 입력 (100-300)",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Discord에서 시청 중인 콘텐츠 표시"
|
||||
},
|
||||
"search": {
|
||||
"hint": "영화, 시리즈, 음악 등을 검색하세요...",
|
||||
|
||||
@@ -147,7 +147,9 @@
|
||||
"maxVolume": "Maximaal volume",
|
||||
"maxVolumeDescription": "Volume boven 100% toestaan voor stille media",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "Voer maximaal volume in (100-300)"
|
||||
"maxVolumeHint": "Voer maximaal volume in (100-300)",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Toon op Discord wat je aan het kijken bent"
|
||||
},
|
||||
"search": {
|
||||
"hint": "Zoek films, series, muziek...",
|
||||
|
||||
@@ -147,7 +147,9 @@
|
||||
"maxVolume": "Maximal volym",
|
||||
"maxVolumeDescription": "Tillåt volym över 100% för tyst media",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "Ange maximal volym (100-300)"
|
||||
"maxVolumeHint": "Ange maximal volym (100-300)",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Visa vad du tittar på i Discord"
|
||||
},
|
||||
"search": {
|
||||
"hint": "Sök filmer, serier, musik...",
|
||||
|
||||
@@ -147,7 +147,9 @@
|
||||
"maxVolume": "最大音量",
|
||||
"maxVolumeDescription": "允许音量超过 100% 以适应安静的媒体",
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"maxVolumeHint": "输入最大音量 (100-300)"
|
||||
"maxVolumeHint": "输入最大音量 (100-300)",
|
||||
"discordRichPresence": "Discord 动态状态",
|
||||
"discordRichPresenceDescription": "在 Discord 上显示您正在观看的内容"
|
||||
},
|
||||
"search": {
|
||||
"hint": "搜索电影、系列、音乐...",
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'services/fullscreen_state_manager.dart';
|
||||
import 'services/update_service.dart';
|
||||
import 'services/settings_service.dart';
|
||||
import 'utils/platform_detector.dart';
|
||||
import 'services/discord_rpc_service.dart';
|
||||
import 'services/gamepad_service.dart';
|
||||
import 'providers/user_profile_provider.dart';
|
||||
import 'providers/plex_client_provider.dart';
|
||||
@@ -90,6 +91,7 @@ void main() async {
|
||||
// Initialize gamepad service for desktop platforms
|
||||
if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
|
||||
GamepadService.instance.start();
|
||||
DiscordRPCService.instance.initialize();
|
||||
}
|
||||
|
||||
// DTD service is available for MCP tooling connection if needed
|
||||
|
||||
@@ -53,6 +53,7 @@ class PlexConfig {
|
||||
'X-Plex-Product': product,
|
||||
'X-Plex-Version': version,
|
||||
'X-Plex-Platform': platform,
|
||||
'X-Plex-Client-Profile-Name': 'Generic',
|
||||
if (device != null) 'X-Plex-Device': device!,
|
||||
if (acceptJson) 'Accept': 'application/json',
|
||||
'Accept-Charset': 'utf-8',
|
||||
|
||||
@@ -354,6 +354,7 @@ class PlayerNative implements Player {
|
||||
await _observeProperty('track-list', (Platform.isAndroid || Platform.isWindows) ? 'string' : 'node');
|
||||
await _observeProperty('eof-reached', 'flag');
|
||||
await _observeProperty('volume', 'double');
|
||||
await _observeProperty('speed', 'double');
|
||||
await _observeProperty('aid', 'string');
|
||||
await _observeProperty('sid', 'string');
|
||||
} catch (e) {
|
||||
@@ -402,6 +403,12 @@ class PlayerNative implements Player {
|
||||
// Show the video layer
|
||||
await _methodChannel.invokeMethod('setVisible', {'visible': true});
|
||||
|
||||
// Set HTTP headers for Plex authentication and profile
|
||||
if (media.headers != null && media.headers!.isNotEmpty) {
|
||||
final headerList = media.headers!.entries.map((e) => '${e.key}: ${e.value}').toList();
|
||||
await setProperty('http-header-fields', headerList.join(','));
|
||||
}
|
||||
|
||||
// Set start position if provided (must be set before loading file)
|
||||
if (media.start != null && media.start!.inSeconds > 0) {
|
||||
await setProperty('start', media.start!.inSeconds.toString());
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../../services/discord_rpc_service.dart';
|
||||
import '../../services/download_storage_service.dart';
|
||||
import '../../services/saf_storage_service.dart';
|
||||
import '../../providers/settings_provider.dart';
|
||||
@@ -61,6 +62,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
bool _downloadOnWifiOnly = false;
|
||||
bool _videoPlayerNavigationEnabled = false;
|
||||
int _maxVolume = 100;
|
||||
bool _enableDiscordRPC = false;
|
||||
|
||||
// Update checking state
|
||||
bool _isCheckingForUpdate = false;
|
||||
@@ -92,6 +94,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
_downloadOnWifiOnly = _settingsService.getDownloadOnWifiOnly();
|
||||
_videoPlayerNavigationEnabled = _settingsService.getVideoPlayerNavigationEnabled();
|
||||
_maxVolume = _settingsService.getMaxVolume();
|
||||
_enableDiscordRPC = _settingsService.getEnableDiscordRPC();
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -292,6 +295,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
trailing: const AppIcon(Symbols.chevron_right_rounded, fill: 1),
|
||||
onTap: () => _showMaxVolumeDialog(),
|
||||
),
|
||||
if (DiscordRPCService.isAvailable)
|
||||
SwitchListTile(
|
||||
secondary: const AppIcon(Symbols.chat_rounded, fill: 1),
|
||||
title: Text(t.settings.discordRichPresence),
|
||||
subtitle: Text(t.settings.discordRichPresenceDescription),
|
||||
value: _enableDiscordRPC,
|
||||
onChanged: (value) async {
|
||||
setState(() => _enableDiscordRPC = value);
|
||||
await _settingsService.setEnableDiscordRPC(value);
|
||||
await DiscordRPCService.instance.setEnabled(value);
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
secondary: const AppIcon(Symbols.bookmark_rounded, fill: 1),
|
||||
title: Text(t.settings.rememberTrackSelections),
|
||||
|
||||
@@ -20,6 +20,7 @@ import '../models/plex_media_info.dart';
|
||||
import '../providers/download_provider.dart';
|
||||
import '../providers/multi_server_provider.dart';
|
||||
import '../providers/playback_state_provider.dart';
|
||||
import '../services/discord_rpc_service.dart';
|
||||
import '../services/episode_navigation_service.dart';
|
||||
import '../services/media_controls_manager.dart';
|
||||
import '../services/playback_initialization_service.dart';
|
||||
@@ -556,14 +557,20 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
_updateMediaControlsPlaybackState();
|
||||
});
|
||||
|
||||
// Listen to position updates for media controls
|
||||
// Listen to position updates for media controls and Discord
|
||||
player!.streams.position.listen((position) {
|
||||
_mediaControlsManager?.updatePlaybackState(
|
||||
isPlaying: player!.state.playing,
|
||||
position: position,
|
||||
speed: player!.state.rate,
|
||||
);
|
||||
DiscordRPCService.instance.updatePosition(position);
|
||||
});
|
||||
|
||||
// Start Discord Rich Presence for current media
|
||||
if (client != null) {
|
||||
DiscordRPCService.instance.startPlayback(widget.metadata, client);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensure a play queue exists for sequential episode playback
|
||||
@@ -665,6 +672,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
|
||||
try {
|
||||
PlaybackInitializationResult result;
|
||||
Map<String, String>? plexHeaders;
|
||||
|
||||
if (widget.isOffline) {
|
||||
// Offline mode: get video path from downloads without requiring server
|
||||
@@ -672,6 +680,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
} else {
|
||||
// Online mode: use server-specific client
|
||||
final client = _getClientForMetadata(context);
|
||||
plexHeaders = client.config.headers;
|
||||
final playbackService = PlaybackInitializationService(client: client, database: PlexApiCache.instance.database);
|
||||
result = await playbackService.getPlaybackData(
|
||||
metadata: widget.metadata,
|
||||
@@ -689,7 +698,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
final resumePosition = widget.metadata.viewOffset != null
|
||||
? Duration(milliseconds: widget.metadata.viewOffset!)
|
||||
: null;
|
||||
await player!.open(Media(result.videoUrl!, start: resumePosition));
|
||||
await player!.open(Media(result.videoUrl!, start: resumePosition, headers: plexHeaders));
|
||||
|
||||
// Attach player to Watch Together session for sync (if in session)
|
||||
if (mounted && !widget.isOffline) {
|
||||
@@ -964,6 +973,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
_mediaControlsManager?.clear();
|
||||
_mediaControlsManager?.dispose();
|
||||
|
||||
// Clear Discord Rich Presence
|
||||
DiscordRPCService.instance.stopPlayback();
|
||||
|
||||
// Disable wakelock when leaving the video player
|
||||
WakelockPlus.disable();
|
||||
appLogger.d('Wakelock disabled');
|
||||
@@ -1012,6 +1024,13 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
|
||||
// Update OS media controls playback state
|
||||
_updateMediaControlsPlaybackState();
|
||||
|
||||
// Update Discord Rich Presence
|
||||
if (isPlaying) {
|
||||
DiscordRPCService.instance.resumePlayback();
|
||||
} else {
|
||||
DiscordRPCService.instance.pausePlayback();
|
||||
}
|
||||
}
|
||||
|
||||
void _onVideoCompleted(bool completed) {
|
||||
@@ -1351,6 +1370,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
// Set flag to skip orientation restoration in dispose()
|
||||
_isReplacingWithVideo = true;
|
||||
|
||||
// Clear Discord Rich Presence before switching episodes
|
||||
DiscordRPCService.instance.stopPlayback();
|
||||
|
||||
// If player isn't available, navigate without preserving settings
|
||||
if (player == null) {
|
||||
if (mounted) {
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:dart_discord_presence/dart_discord_presence.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../models/plex_metadata.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import 'plex_client.dart';
|
||||
import 'settings_service.dart';
|
||||
|
||||
/// Cached Litterbox URL with expiry timestamp
|
||||
class _CachedUrl {
|
||||
final String url;
|
||||
final DateTime expiresAt;
|
||||
|
||||
_CachedUrl(this.url, this.expiresAt);
|
||||
|
||||
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
||||
}
|
||||
|
||||
/// Service that manages Discord Rich Presence integration.
|
||||
///
|
||||
/// Desktop only (Windows, macOS, Linux). Shows "Watching" activity
|
||||
/// when video is playing. Gracefully handles Discord not running.
|
||||
class DiscordRPCService {
|
||||
static const String _applicationId = '1453773470306402439';
|
||||
static const String _litterboxUrl = 'https://litterbox.catbox.moe/resources/internals/api.php';
|
||||
|
||||
/// Cache of Plex thumbnail paths to Litterbox URLs with expiry (1 hour)
|
||||
static final Map<String, _CachedUrl> _litterboxCache = {};
|
||||
|
||||
static DiscordRPCService? _instance;
|
||||
static DiscordRPCService get instance {
|
||||
_instance ??= DiscordRPCService._();
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
DiscordRPC? _rpc;
|
||||
bool _isConnected = false;
|
||||
bool _isEnabled = false;
|
||||
bool _isInitialized = false;
|
||||
PlexMetadata? _currentMetadata;
|
||||
PlexClient? _currentClient;
|
||||
String? _cachedThumbnailUrl;
|
||||
DateTime? _playbackStartTime;
|
||||
Duration? _mediaDuration;
|
||||
Duration? _currentPosition;
|
||||
Timer? _reconnectTimer;
|
||||
DateTime? _lastPresenceUpdate;
|
||||
StreamSubscription<void>? _readySubscription;
|
||||
StreamSubscription<void>? _disconnectedSubscription;
|
||||
StreamSubscription<dynamic>? _errorSubscription;
|
||||
|
||||
DiscordRPCService._();
|
||||
|
||||
/// Check if Discord RPC is available on this platform
|
||||
static bool get isAvailable {
|
||||
if (!Platform.isMacOS && !Platform.isWindows && !Platform.isLinux) {
|
||||
return false;
|
||||
}
|
||||
return DiscordRPC.isAvailable;
|
||||
}
|
||||
|
||||
/// Initialize the service. Call once at app startup (main.dart).
|
||||
Future<void> initialize() async {
|
||||
if (!isAvailable) {
|
||||
appLogger.d('Discord RPC not available on this platform');
|
||||
return;
|
||||
}
|
||||
|
||||
if (_isInitialized) return;
|
||||
_isInitialized = true;
|
||||
|
||||
final settings = await SettingsService.getInstance();
|
||||
_isEnabled = settings.getEnableDiscordRPC();
|
||||
|
||||
if (_isEnabled) {
|
||||
await _connect();
|
||||
}
|
||||
}
|
||||
|
||||
/// Enable or disable Discord RPC
|
||||
Future<void> setEnabled(bool enabled) async {
|
||||
if (_isEnabled == enabled) return;
|
||||
|
||||
_isEnabled = enabled;
|
||||
|
||||
if (enabled) {
|
||||
await _connect();
|
||||
// Restore presence if we have active playback
|
||||
if (_currentMetadata != null) {
|
||||
await _updatePresence();
|
||||
}
|
||||
} else {
|
||||
await _disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/// Start showing presence for media playback
|
||||
Future<void> startPlayback(PlexMetadata metadata, PlexClient client) async {
|
||||
_currentMetadata = metadata;
|
||||
_currentClient = client;
|
||||
_playbackStartTime = DateTime.now();
|
||||
_mediaDuration = metadata.duration != null
|
||||
? Duration(milliseconds: metadata.duration!)
|
||||
: null;
|
||||
_currentPosition = Duration.zero;
|
||||
_cachedThumbnailUrl = null;
|
||||
|
||||
if (_isEnabled && _isConnected) {
|
||||
// Upload thumbnail in background, don't block playback
|
||||
_uploadThumbnailAndUpdatePresence();
|
||||
}
|
||||
}
|
||||
|
||||
/// Update current playback position (for progress bar)
|
||||
void updatePosition(Duration position) {
|
||||
final previousPosition = _currentPosition;
|
||||
_currentPosition = position;
|
||||
|
||||
// Update presence if position jumped significantly (seek detected)
|
||||
if (_isEnabled && _isConnected && _playbackStartTime != null && previousPosition != null) {
|
||||
final drift = (position - previousPosition).abs();
|
||||
// If position changed by more than 5 seconds, likely a seek
|
||||
if (drift > const Duration(seconds: 5)) {
|
||||
// Throttle updates to max once per second
|
||||
final now = DateTime.now();
|
||||
if (_lastPresenceUpdate == null || now.difference(_lastPresenceUpdate!) > const Duration(seconds: 1)) {
|
||||
_lastPresenceUpdate = now;
|
||||
_updatePresence();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Resume playback (restore timestamp)
|
||||
Future<void> resumePlayback() async {
|
||||
if (_currentMetadata == null) return;
|
||||
|
||||
// Reset start time for elapsed time display
|
||||
_playbackStartTime = DateTime.now();
|
||||
|
||||
if (_isEnabled && _isConnected) {
|
||||
await _updatePresence();
|
||||
}
|
||||
}
|
||||
|
||||
/// Pause - clear timestamp but keep showing what's playing
|
||||
Future<void> pausePlayback() async {
|
||||
// Clear start time so Discord stops counting
|
||||
_playbackStartTime = null;
|
||||
|
||||
if (_isEnabled && _isConnected) {
|
||||
await _updatePresence();
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop showing presence when playback ends
|
||||
Future<void> stopPlayback() async {
|
||||
_currentMetadata = null;
|
||||
_currentClient = null;
|
||||
_playbackStartTime = null;
|
||||
_cachedThumbnailUrl = null;
|
||||
|
||||
if (_isEnabled && _isConnected) {
|
||||
await clearPresence();
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear the presence
|
||||
Future<void> clearPresence() async {
|
||||
try {
|
||||
_rpc?.clearPresence();
|
||||
} catch (e) {
|
||||
appLogger.d('Failed to clear Discord presence', error: e);
|
||||
}
|
||||
}
|
||||
|
||||
/// Dispose the service (call on app shutdown)
|
||||
Future<void> dispose() async {
|
||||
_reconnectTimer?.cancel();
|
||||
await _disconnect();
|
||||
}
|
||||
|
||||
// Private methods
|
||||
|
||||
Future<void> _connect() async {
|
||||
if (_rpc != null) return;
|
||||
|
||||
try {
|
||||
_rpc = DiscordRPC();
|
||||
|
||||
_readySubscription = _rpc!.onReady.listen((_) async {
|
||||
_isConnected = true;
|
||||
appLogger.i('Discord RPC connected');
|
||||
|
||||
// Small delay to let Discord stabilize after connection
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
// Update presence if we have active playback
|
||||
if (_currentMetadata != null) {
|
||||
await _uploadThumbnailAndUpdatePresence();
|
||||
}
|
||||
});
|
||||
|
||||
_disconnectedSubscription = _rpc!.onDisconnected.listen((_) {
|
||||
_isConnected = false;
|
||||
appLogger.i('Discord RPC disconnected');
|
||||
_scheduleReconnect();
|
||||
});
|
||||
|
||||
_errorSubscription = _rpc!.onError.listen((error) {
|
||||
appLogger.w('Discord RPC error: $error');
|
||||
});
|
||||
|
||||
await _rpc!.initialize(_applicationId);
|
||||
} catch (e) {
|
||||
appLogger.w('Failed to initialize Discord RPC', error: e);
|
||||
// Clean up on failure so reconnect attempts can work
|
||||
await _readySubscription?.cancel();
|
||||
await _disconnectedSubscription?.cancel();
|
||||
await _errorSubscription?.cancel();
|
||||
_readySubscription = null;
|
||||
_disconnectedSubscription = null;
|
||||
_errorSubscription = null;
|
||||
try {
|
||||
_rpc?.dispose();
|
||||
} catch (_) {}
|
||||
_rpc = null;
|
||||
_scheduleReconnect();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _disconnect() async {
|
||||
_reconnectTimer?.cancel();
|
||||
_isConnected = false;
|
||||
|
||||
await _readySubscription?.cancel();
|
||||
await _disconnectedSubscription?.cancel();
|
||||
await _errorSubscription?.cancel();
|
||||
_readySubscription = null;
|
||||
_disconnectedSubscription = null;
|
||||
_errorSubscription = null;
|
||||
|
||||
try {
|
||||
_rpc?.dispose();
|
||||
} catch (e) {
|
||||
appLogger.d('Error disposing Discord RPC', error: e);
|
||||
}
|
||||
_rpc = null;
|
||||
}
|
||||
|
||||
void _scheduleReconnect() {
|
||||
if (!_isEnabled) return;
|
||||
|
||||
_reconnectTimer?.cancel();
|
||||
_reconnectTimer = Timer(const Duration(seconds: 30), () {
|
||||
if (_isEnabled && !_isConnected) {
|
||||
_connect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _uploadThumbnailAndUpdatePresence() async {
|
||||
// Try to upload thumbnail, but don't block on failure
|
||||
if (_cachedThumbnailUrl == null && _currentMetadata != null && _currentClient != null) {
|
||||
_cachedThumbnailUrl = await _uploadThumbnail(_currentMetadata!, _currentClient!);
|
||||
}
|
||||
await _updatePresence();
|
||||
}
|
||||
|
||||
Future<String?> _uploadThumbnail(PlexMetadata metadata, PlexClient client) async {
|
||||
try {
|
||||
// Get the thumbnail path (prefer show poster for episodes)
|
||||
final thumbPath = metadata.grandparentThumb ?? metadata.thumb;
|
||||
if (thumbPath == null || thumbPath.isEmpty) return null;
|
||||
|
||||
// Check cache first (with expiry check)
|
||||
final cached = _litterboxCache[thumbPath];
|
||||
if (cached != null && !cached.isExpired) {
|
||||
appLogger.d('Using cached Litterbox URL for: $thumbPath');
|
||||
return cached.url;
|
||||
}
|
||||
|
||||
// Get the full URL with auth token
|
||||
final imageUrl = client.getThumbnailUrl(thumbPath);
|
||||
if (imageUrl.isEmpty) return null;
|
||||
|
||||
// Fetch image data
|
||||
final dio = Dio();
|
||||
final imageResponse = await dio.get<List<int>>(
|
||||
imageUrl,
|
||||
options: Options(responseType: ResponseType.bytes, receiveTimeout: const Duration(seconds: 10)),
|
||||
);
|
||||
|
||||
final imageBytes = imageResponse.data;
|
||||
if (imageBytes == null || imageBytes.isEmpty) return null;
|
||||
|
||||
// Upload to Litterbox
|
||||
final formData = FormData.fromMap({
|
||||
'reqtype': 'fileupload',
|
||||
'time': '1h',
|
||||
'fileToUpload': MultipartFile.fromBytes(Uint8List.fromList(imageBytes), filename: 'thumbnail.jpg'),
|
||||
});
|
||||
|
||||
final uploadResponse = await dio.post<String>(
|
||||
_litterboxUrl,
|
||||
data: formData,
|
||||
options: Options(receiveTimeout: const Duration(seconds: 15)),
|
||||
);
|
||||
|
||||
final uploadedUrl = uploadResponse.data?.trim();
|
||||
if (uploadedUrl != null && uploadedUrl.startsWith('http')) {
|
||||
// Cache the URL with 1 hour expiry (matching Litterbox)
|
||||
_litterboxCache[thumbPath] = _CachedUrl(uploadedUrl, DateTime.now().add(const Duration(hours: 1)));
|
||||
appLogger.d('Uploaded and cached thumbnail: $uploadedUrl');
|
||||
return uploadedUrl;
|
||||
}
|
||||
} catch (e) {
|
||||
appLogger.d('Failed to upload thumbnail to Litterbox', error: e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> _updatePresence() async {
|
||||
if (_rpc == null || !_isConnected || _currentMetadata == null) return;
|
||||
|
||||
try {
|
||||
final metadata = _currentMetadata!;
|
||||
final details = _buildDetails(metadata);
|
||||
final state = _buildState(metadata);
|
||||
|
||||
await _rpc!.setPresence(
|
||||
DiscordPresence(
|
||||
type: DiscordActivityType.watching,
|
||||
details: details,
|
||||
state: state,
|
||||
timestamps: _buildTimestamps(),
|
||||
statusDisplayType: DiscordStatusDisplayType.details,
|
||||
largeAsset: _cachedThumbnailUrl != null
|
||||
? DiscordAsset(url: _cachedThumbnailUrl!, text: metadata.grandparentTitle ?? metadata.title)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
appLogger.d('Failed to update Discord presence', error: e);
|
||||
}
|
||||
}
|
||||
|
||||
/// Build timestamps for Discord progress bar
|
||||
DiscordTimestamps? _buildTimestamps() {
|
||||
// When paused, don't show timestamps (progress bar would be inaccurate)
|
||||
if (_playbackStartTime == null) return null;
|
||||
|
||||
// If we have duration, show progress bar
|
||||
if (_mediaDuration != null) {
|
||||
final now = DateTime.now();
|
||||
final position = _currentPosition ?? Duration.zero;
|
||||
|
||||
// Calculate when playback "started" (now minus current position)
|
||||
final effectiveStart = now.subtract(position);
|
||||
|
||||
// Calculate when playback will "end" (start + total duration)
|
||||
final effectiveEnd = effectiveStart.add(_mediaDuration!);
|
||||
|
||||
return DiscordTimestamps.range(effectiveStart, effectiveEnd);
|
||||
}
|
||||
|
||||
// Fallback: just show elapsed time
|
||||
return DiscordTimestamps.started(_playbackStartTime!);
|
||||
}
|
||||
|
||||
/// Build the main "details" line (first line of presence)
|
||||
String _buildDetails(PlexMetadata metadata) {
|
||||
switch (metadata.mediaType) {
|
||||
case PlexMediaType.movie:
|
||||
final year = metadata.year != null ? ' (${metadata.year})' : '';
|
||||
return metadata.title + year;
|
||||
|
||||
case PlexMediaType.episode:
|
||||
// Show: "Show Name" or just episode title if no show name
|
||||
return metadata.grandparentTitle ?? metadata.title;
|
||||
|
||||
default:
|
||||
return metadata.title;
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the "state" line (second line of presence)
|
||||
String? _buildState(PlexMetadata metadata) {
|
||||
switch (metadata.mediaType) {
|
||||
case PlexMediaType.episode:
|
||||
// Format: "S1 E5 - Episode Title"
|
||||
final season = metadata.parentIndex;
|
||||
final episode = metadata.index;
|
||||
if (season != null && episode != null) {
|
||||
return 'S$season E$episode - ${metadata.title}';
|
||||
}
|
||||
return metadata.title;
|
||||
|
||||
case PlexMediaType.movie:
|
||||
return metadata.studio;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
static const String _keyMpvConfigEntries = 'mpv_config_entries';
|
||||
static const String _keyMpvConfigPresets = 'mpv_config_presets';
|
||||
static const String _keyMaxVolume = 'max_volume';
|
||||
static const String _keyEnableDiscordRPC = 'enable_discord_rpc';
|
||||
|
||||
SettingsService._();
|
||||
|
||||
@@ -894,6 +895,15 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
await setMpvConfigEntries(preset.entries);
|
||||
}
|
||||
|
||||
// Discord Rich Presence
|
||||
Future<void> setEnableDiscordRPC(bool enabled) async {
|
||||
await prefs.setBool(_keyEnableDiscordRPC, enabled);
|
||||
}
|
||||
|
||||
bool getEnableDiscordRPC() {
|
||||
return prefs.getBool(_keyEnableDiscordRPC) ?? false; // Default disabled
|
||||
}
|
||||
|
||||
// Reset all settings to defaults
|
||||
Future<void> resetAllSettings() async {
|
||||
await Future.wait([
|
||||
@@ -933,6 +943,7 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
prefs.remove(_keyShowPerformanceOverlay),
|
||||
prefs.remove(_keyMpvConfigEntries),
|
||||
prefs.remove(_keyMpvConfigPresets),
|
||||
prefs.remove(_keyEnableDiscordRPC),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ import '../../mpv/mpv.dart';
|
||||
import '../../models/plex_media_info.dart';
|
||||
import '../../models/plex_metadata.dart';
|
||||
import '../../utils/desktop_window_padding.dart';
|
||||
import '../../utils/player_utils.dart';
|
||||
import 'icons.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import 'widgets/video_controls_header.dart';
|
||||
import 'widgets/video_timeline_bar.dart';
|
||||
@@ -128,26 +126,14 @@ class MobileVideoControls extends StatelessWidget {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Previous episode button (hidden when unavailable)
|
||||
if (onPrevious != null) ...[
|
||||
_buildCircularButton(
|
||||
semanticLabel: t.videoControls.previousButton,
|
||||
icon: Symbols.skip_previous_rounded,
|
||||
iconSize: 48,
|
||||
onPressed: onPrevious!,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
// Previous episode button (greyed out when unavailable)
|
||||
_buildCircularButton(
|
||||
semanticLabel: t.videoControls.seekBackwardButton(seconds: seekTimeSmall),
|
||||
icon: getReplayIcon(seekTimeSmall),
|
||||
semanticLabel: t.videoControls.previousButton,
|
||||
icon: Symbols.skip_previous_rounded,
|
||||
iconSize: 48,
|
||||
onPressed: () {
|
||||
final newPosition = seekWithClamping(player, Duration(seconds: -seekTimeSmall));
|
||||
onSeekCompleted?.call(newPosition);
|
||||
},
|
||||
onPressed: onPrevious,
|
||||
),
|
||||
const SizedBox(width: 48),
|
||||
const SizedBox(width: 24),
|
||||
_buildCircularButton(
|
||||
semanticLabel: isPlaying ? t.videoControls.pauseButton : t.videoControls.playButton,
|
||||
icon: isPlaying ? Symbols.pause_rounded : Symbols.play_arrow_rounded,
|
||||
@@ -162,26 +148,14 @@ class MobileVideoControls extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 48),
|
||||
const SizedBox(width: 24),
|
||||
// Next episode button (greyed out when unavailable)
|
||||
_buildCircularButton(
|
||||
semanticLabel: t.videoControls.seekForwardButton(seconds: seekTimeSmall),
|
||||
icon: getForwardIcon(seekTimeSmall),
|
||||
semanticLabel: t.videoControls.nextButton,
|
||||
icon: Symbols.skip_next_rounded,
|
||||
iconSize: 48,
|
||||
onPressed: () {
|
||||
final newPosition = seekWithClamping(player, Duration(seconds: seekTimeSmall));
|
||||
onSeekCompleted?.call(newPosition);
|
||||
},
|
||||
onPressed: onNext,
|
||||
),
|
||||
// Next episode button (hidden when unavailable)
|
||||
if (onNext != null) ...[
|
||||
const SizedBox(width: 16),
|
||||
_buildCircularButton(
|
||||
semanticLabel: t.videoControls.nextButton,
|
||||
icon: Symbols.skip_next_rounded,
|
||||
iconSize: 48,
|
||||
onPressed: onNext!,
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -229,8 +203,9 @@ class MobileVideoControls extends StatelessWidget {
|
||||
required String semanticLabel,
|
||||
required IconData icon,
|
||||
required double iconSize,
|
||||
required VoidCallback onPressed,
|
||||
VoidCallback? onPressed,
|
||||
}) {
|
||||
final isEnabled = onPressed != null;
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: Colors.black.withValues(alpha: 0.5), shape: BoxShape.circle),
|
||||
child: Semantics(
|
||||
@@ -238,7 +213,12 @@ class MobileVideoControls extends StatelessWidget {
|
||||
button: true,
|
||||
excludeSemantics: true,
|
||||
child: IconButton(
|
||||
icon: AppIcon(icon, fill: 1, color: Colors.white, size: iconSize),
|
||||
icon: AppIcon(
|
||||
icon,
|
||||
fill: 1,
|
||||
color: isEnabled ? Colors.white : Colors.white.withValues(alpha: 0.3),
|
||||
size: iconSize,
|
||||
),
|
||||
iconSize: iconSize,
|
||||
onPressed: onPressed,
|
||||
),
|
||||
|
||||
@@ -152,6 +152,12 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
double _doubleTapFeedbackOpacity = 0.0;
|
||||
bool _lastDoubleTapWasForward = true;
|
||||
Timer? _feedbackTimer;
|
||||
int _accumulatedSkipSeconds = 0; // Stacking skip: total skip during active feedback
|
||||
// Custom tap detection state (more reliable than Flutter's onDoubleTap)
|
||||
DateTime? _lastSkipTapTime;
|
||||
bool _lastSkipTapWasForward = true;
|
||||
DateTime? _lastSkipActionTime; // Debounce: prevents double-tap counting as 2 skips
|
||||
Timer? _singleTapTimer; // Timer for delayed single-tap action (toggle controls)
|
||||
// Seek throttle
|
||||
late final Throttle _seekThrottle;
|
||||
// Current marker state
|
||||
@@ -175,6 +181,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
bool _videoPlayerNavigationEnabled = false;
|
||||
// Performance overlay
|
||||
bool _showPerformanceOverlay = false;
|
||||
// Long-press 2x speed state
|
||||
bool _isLongPressing = false;
|
||||
double? _rateBeforeLongPress;
|
||||
bool _showSpeedIndicator = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -276,6 +286,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
void _listenToCompleted() {
|
||||
_completedSubscription = widget.player.streams.completed.listen((completed) {
|
||||
if (completed && mounted) {
|
||||
// Cancel long-press 2x speed if active
|
||||
if (_isLongPressing) {
|
||||
_handleLongPressCancel();
|
||||
}
|
||||
// Show controls when video completes (for play next dialog etc.)
|
||||
setState(() {
|
||||
_showControls = true;
|
||||
@@ -422,10 +436,15 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
_feedbackTimer?.cancel();
|
||||
_resizeDebounceTimer?.cancel();
|
||||
_autoSkipTimer?.cancel();
|
||||
_singleTapTimer?.cancel();
|
||||
_seekThrottle.cancel();
|
||||
_playingSubscription?.cancel();
|
||||
_completedSubscription?.cancel();
|
||||
_focusNode.dispose();
|
||||
// Restore original rate if long-press was active when disposed
|
||||
if (_isLongPressing && _rateBeforeLongPress != null) {
|
||||
widget.player.setRate(_rateBeforeLongPress!);
|
||||
}
|
||||
// Remove lifecycle observer
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
// Remove window listener
|
||||
@@ -797,11 +816,81 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
widget.onSeekCompleted?.call(position);
|
||||
}
|
||||
|
||||
/// Handle tap in skip zone with custom double-tap detection
|
||||
void _handleTapInSkipZone({required bool isForward}) {
|
||||
final now = DateTime.now();
|
||||
|
||||
// Cancel any pending single-tap action
|
||||
_singleTapTimer?.cancel();
|
||||
_singleTapTimer = null;
|
||||
|
||||
// Debounce: ignore taps within 200ms of last skip action
|
||||
// This prevents double-taps from counting as two separate skips
|
||||
if (_lastSkipActionTime != null &&
|
||||
now.difference(_lastSkipActionTime!).inMilliseconds < 200) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this qualifies as a double-tap (within 250ms of last tap, same side)
|
||||
final isDoubleTap =
|
||||
_lastSkipTapTime != null &&
|
||||
now.difference(_lastSkipTapTime!).inMilliseconds < 250 &&
|
||||
_lastSkipTapWasForward == isForward;
|
||||
|
||||
// Skip ONLY on detected double-tap (no single-tap-to-add behavior)
|
||||
if (isDoubleTap) {
|
||||
_lastSkipTapTime = null; // Reset to prevent triple-tap chaining
|
||||
|
||||
if (_showDoubleTapFeedback && _lastDoubleTapWasForward == isForward) {
|
||||
// Stacking skip - add to accumulated
|
||||
_handleStackingSkip(isForward: isForward);
|
||||
} else {
|
||||
// First double-tap - initiate skip
|
||||
_handleDoubleTapSkip(isForward: isForward);
|
||||
}
|
||||
} else {
|
||||
// First tap - record timestamp and start timer for single-tap action
|
||||
_lastSkipTapTime = now;
|
||||
_lastSkipTapWasForward = isForward;
|
||||
|
||||
// If no second tap within 250ms, treat as single tap to toggle controls
|
||||
_singleTapTimer = Timer(const Duration(milliseconds: 250), () {
|
||||
if (mounted) {
|
||||
_toggleControls();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle stacking skip - add to accumulated skip when feedback is active
|
||||
void _handleStackingSkip({required bool isForward}) {
|
||||
if (!widget.canControl) return;
|
||||
|
||||
// Add to accumulated skip
|
||||
_accumulatedSkipSeconds += _seekTimeSmall;
|
||||
|
||||
// Calculate and perform seek
|
||||
final delta = Duration(seconds: isForward ? _seekTimeSmall : -_seekTimeSmall);
|
||||
final newPosition = seekWithClamping(widget.player, delta);
|
||||
|
||||
// Notify Watch Together
|
||||
widget.onSeekCompleted?.call(newPosition);
|
||||
|
||||
// Refresh feedback (extends timer, updates display)
|
||||
_showSkipFeedback(isForward: isForward);
|
||||
|
||||
// Record skip time for debounce
|
||||
_lastSkipActionTime = DateTime.now();
|
||||
}
|
||||
|
||||
/// Handle double-tap skip forward or backward
|
||||
void _handleDoubleTapSkip({required bool isForward}) {
|
||||
// Ignore if user cannot control playback
|
||||
if (!widget.canControl) return;
|
||||
|
||||
// Reset accumulated skip for new gesture
|
||||
_accumulatedSkipSeconds = _seekTimeSmall;
|
||||
|
||||
// Calculate the new position (clamped to valid range)
|
||||
final currentPosition = widget.player.state.position;
|
||||
final duration = widget.player.state.duration;
|
||||
@@ -817,6 +906,9 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
|
||||
// Show visual feedback
|
||||
_showSkipFeedback(isForward: isForward);
|
||||
|
||||
// Record skip time for debounce
|
||||
_lastSkipActionTime = DateTime.now();
|
||||
}
|
||||
|
||||
/// Show animated visual feedback for skip gesture
|
||||
@@ -832,8 +924,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
// Capture duration before timer to avoid context access in callback
|
||||
final slowDuration = tokens(context).slow;
|
||||
|
||||
// Fade out after delay
|
||||
_feedbackTimer = Timer(const Duration(milliseconds: 500), () {
|
||||
// Fade out after delay (1200ms gives time to see value and continue tapping)
|
||||
_feedbackTimer = Timer(const Duration(milliseconds: 1200), () {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_doubleTapFeedbackOpacity = 0.0;
|
||||
@@ -843,6 +935,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_showDoubleTapFeedback = false;
|
||||
_accumulatedSkipSeconds = 0; // Reset when feedback hides
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -850,6 +943,69 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle tap on controls overlay - route to skip zones or toggle controls
|
||||
void _handleControlsOverlayTap(TapUpDetails details, BoxConstraints constraints) {
|
||||
final isMobile = PlatformDetector.isMobile(context);
|
||||
if (!isMobile) {
|
||||
_toggleControls();
|
||||
return;
|
||||
}
|
||||
|
||||
final width = constraints.maxWidth;
|
||||
final height = constraints.maxHeight;
|
||||
final tapX = details.localPosition.dx;
|
||||
final tapY = details.localPosition.dy;
|
||||
|
||||
// Skip zone dimensions (must match the skip zone Positioned widgets)
|
||||
final topExclude = height * 0.15;
|
||||
final bottomExclude = height * 0.15;
|
||||
final leftZoneWidth = width * 0.35;
|
||||
|
||||
// Check if tap is in vertical range for skip zones
|
||||
final inVerticalRange = tapY > topExclude && tapY < (height - bottomExclude);
|
||||
|
||||
if (inVerticalRange) {
|
||||
if (tapX < leftZoneWidth) {
|
||||
// Left skip zone
|
||||
_handleTapInSkipZone(isForward: false);
|
||||
return;
|
||||
} else if (tapX > (width - leftZoneWidth)) {
|
||||
// Right skip zone
|
||||
_handleTapInSkipZone(isForward: true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Not in skip zone, toggle controls
|
||||
_toggleControls();
|
||||
}
|
||||
|
||||
/// Handle long-press start - activate 2x speed
|
||||
void _handleLongPressStart() {
|
||||
if (!widget.canControl) return; // Respect Watch Together permissions
|
||||
|
||||
setState(() {
|
||||
_isLongPressing = true;
|
||||
_rateBeforeLongPress = widget.player.state.rate;
|
||||
_showSpeedIndicator = true;
|
||||
});
|
||||
widget.player.setRate(2.0);
|
||||
}
|
||||
|
||||
/// Handle long-press end - restore original speed
|
||||
void _handleLongPressEnd() {
|
||||
if (!_isLongPressing) return;
|
||||
widget.player.setRate(_rateBeforeLongPress ?? 1.0);
|
||||
setState(() {
|
||||
_isLongPressing = false;
|
||||
_rateBeforeLongPress = null;
|
||||
_showSpeedIndicator = false;
|
||||
});
|
||||
}
|
||||
|
||||
/// Handle long-press cancel (same as end)
|
||||
void _handleLongPressCancel() => _handleLongPressEnd();
|
||||
|
||||
/// Build the visual feedback widget for double-tap skip
|
||||
Widget _buildDoubleTapFeedback() {
|
||||
return Align(
|
||||
@@ -858,11 +1014,58 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
margin: const EdgeInsets.symmetric(horizontal: 60),
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(color: Colors.black.withValues(alpha: 0.6), shape: BoxShape.circle),
|
||||
child: AppIcon(
|
||||
_lastDoubleTapWasForward ? getForwardIcon(_seekTimeSmall) : getReplayIcon(_seekTimeSmall),
|
||||
fill: 1,
|
||||
color: Colors.white,
|
||||
size: 48,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppIcon(
|
||||
_lastDoubleTapWasForward ? Symbols.fast_forward_rounded : Symbols.fast_rewind_rounded,
|
||||
fill: 1,
|
||||
color: Colors.white,
|
||||
size: 32,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$_accumulatedSkipSeconds${t.settings.secondsShort}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build the visual indicator for long-press 2x speed
|
||||
Widget _buildSpeedIndicator() {
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.7),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppIcon(
|
||||
Symbols.fast_forward_rounded,
|
||||
fill: 1,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
'2x',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1115,9 +1318,13 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
child: Stack(
|
||||
children: [
|
||||
// Invisible tap detector that always covers the full area
|
||||
// Also handles long-press for 2x speed
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: _toggleControls,
|
||||
onLongPressStart: (_) => _handleLongPressStart(),
|
||||
onLongPressEnd: (_) => _handleLongPressEnd(),
|
||||
onLongPressCancel: _handleLongPressCancel,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(color: Colors.transparent),
|
||||
),
|
||||
@@ -1168,29 +1375,33 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
// Left zone - skip backward
|
||||
// Left zone - skip backward (custom double-tap detection)
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: topExclude,
|
||||
bottom: bottomExclude,
|
||||
width: leftZoneWidth,
|
||||
child: GestureDetector(
|
||||
onTap: _toggleControls,
|
||||
onDoubleTap: () => _handleDoubleTapSkip(isForward: false),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => _handleTapInSkipZone(isForward: false),
|
||||
onLongPressStart: (_) => _handleLongPressStart(),
|
||||
onLongPressEnd: (_) => _handleLongPressEnd(),
|
||||
onLongPressCancel: _handleLongPressCancel,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
// Right zone - skip forward
|
||||
// Right zone - skip forward (custom double-tap detection)
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: topExclude,
|
||||
bottom: bottomExclude,
|
||||
width: leftZoneWidth,
|
||||
child: GestureDetector(
|
||||
onTap: _toggleControls,
|
||||
onDoubleTap: () => _handleDoubleTapSkip(isForward: true),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => _handleTapInSkipZone(isForward: true),
|
||||
onLongPressStart: (_) => _handleLongPressStart(),
|
||||
onLongPressEnd: (_) => _handleLongPressEnd(),
|
||||
onLongPressCancel: _handleLongPressCancel,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
@@ -1213,105 +1424,112 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
child: AnimatedOpacity(
|
||||
opacity: _showControls ? 1.0 : 0.0,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: GestureDetector(
|
||||
onTap: _toggleControls,
|
||||
behavior: HitTestBehavior.deferToChild,
|
||||
child: ValueListenableBuilder<bool>(
|
||||
valueListenable: widget.hasFirstFrame ?? ValueNotifier(true),
|
||||
builder: (context, hasFrame, child) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
// Use solid black when loading, gradient when loaded
|
||||
color: hasFrame ? null : Colors.black,
|
||||
gradient: hasFrame
|
||||
? LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.black.withValues(alpha: 0.7),
|
||||
Colors.transparent,
|
||||
Colors.transparent,
|
||||
Colors.black.withValues(alpha: 0.7),
|
||||
],
|
||||
stops: const [0.0, 0.2, 0.8, 1.0],
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: isMobile
|
||||
? Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) => _restartHideTimerIfPlaying(),
|
||||
child: MobileVideoControls(
|
||||
player: widget.player,
|
||||
metadata: widget.metadata,
|
||||
chapters: _chapters,
|
||||
chaptersLoaded: _chaptersLoaded,
|
||||
seekTimeSmall: _seekTimeSmall,
|
||||
trackChapterControls: _buildTrackChapterControlsWidget(),
|
||||
onSeek: _throttledSeek,
|
||||
onSeekEnd: _finalizeSeek,
|
||||
onSeekCompleted: widget.onSeekCompleted,
|
||||
onPlayPause: () {}, // Not used, handled internally
|
||||
onCancelAutoHide: () => _hideTimer?.cancel(),
|
||||
onStartAutoHide: _startHideTimer,
|
||||
onBack: widget.onBack,
|
||||
onNext: widget.onNext,
|
||||
onPrevious: widget.onPrevious,
|
||||
canControl: widget.canControl,
|
||||
hasFirstFrame: widget.hasFirstFrame,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return GestureDetector(
|
||||
onTapUp: (details) => _handleControlsOverlayTap(details, constraints),
|
||||
onLongPressStart: (_) => _handleLongPressStart(),
|
||||
onLongPressEnd: (_) => _handleLongPressEnd(),
|
||||
onLongPressCancel: _handleLongPressCancel,
|
||||
behavior: HitTestBehavior.deferToChild,
|
||||
child: ValueListenableBuilder<bool>(
|
||||
valueListenable: widget.hasFirstFrame ?? ValueNotifier(true),
|
||||
builder: (context, hasFrame, child) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
// Use solid black when loading, gradient when loaded
|
||||
color: hasFrame ? null : Colors.black,
|
||||
gradient: hasFrame
|
||||
? LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.black.withValues(alpha: 0.7),
|
||||
Colors.transparent,
|
||||
Colors.transparent,
|
||||
Colors.black.withValues(alpha: 0.7),
|
||||
],
|
||||
stops: const [0.0, 0.2, 0.8, 1.0],
|
||||
)
|
||||
: null,
|
||||
),
|
||||
)
|
||||
: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) => _restartHideTimerIfPlaying(),
|
||||
child: DesktopVideoControls(
|
||||
key: _desktopControlsKey,
|
||||
player: widget.player,
|
||||
metadata: widget.metadata,
|
||||
onNext: widget.onNext,
|
||||
onPrevious: widget.onPrevious,
|
||||
chapters: _chapters,
|
||||
chaptersLoaded: _chaptersLoaded,
|
||||
seekTimeSmall: _seekTimeSmall,
|
||||
onSeekToPreviousChapter: _seekToPreviousChapter,
|
||||
onSeekToNextChapter: _seekToNextChapter,
|
||||
onSeek: _throttledSeek,
|
||||
onSeekEnd: _finalizeSeek,
|
||||
getReplayIcon: getReplayIcon,
|
||||
getForwardIcon: getForwardIcon,
|
||||
onFocusActivity: _restartHideTimerIfPlaying,
|
||||
onHideControls: _hideControlsFromKeyboard,
|
||||
// Track chapter controls data
|
||||
availableVersions: widget.availableVersions,
|
||||
selectedMediaIndex: widget.selectedMediaIndex,
|
||||
boxFitMode: widget.boxFitMode,
|
||||
audioSyncOffset: _audioSyncOffset,
|
||||
subtitleSyncOffset: _subtitleSyncOffset,
|
||||
isFullscreen: _isFullscreen,
|
||||
isAlwaysOnTop: _isAlwaysOnTop,
|
||||
onCycleBoxFitMode: widget.onCycleBoxFitMode,
|
||||
onToggleFullscreen: _toggleFullscreen,
|
||||
onToggleAlwaysOnTop: _toggleAlwaysOnTop,
|
||||
onSwitchVersion: _switchMediaVersion,
|
||||
onAudioTrackChanged: widget.onAudioTrackChanged,
|
||||
onSubtitleTrackChanged: widget.onSubtitleTrackChanged,
|
||||
onLoadSeekTimes: () async {
|
||||
if (mounted) {
|
||||
await _loadSeekTimes();
|
||||
}
|
||||
},
|
||||
onCancelAutoHide: () => _hideTimer?.cancel(),
|
||||
onStartAutoHide: _startHideTimer,
|
||||
serverId: widget.metadata.serverId ?? '',
|
||||
onBack: widget.onBack,
|
||||
canControl: widget.canControl,
|
||||
hasFirstFrame: widget.hasFirstFrame,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: isMobile
|
||||
? Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) => _restartHideTimerIfPlaying(),
|
||||
child: MobileVideoControls(
|
||||
player: widget.player,
|
||||
metadata: widget.metadata,
|
||||
chapters: _chapters,
|
||||
chaptersLoaded: _chaptersLoaded,
|
||||
seekTimeSmall: _seekTimeSmall,
|
||||
trackChapterControls: _buildTrackChapterControlsWidget(),
|
||||
onSeek: _throttledSeek,
|
||||
onSeekEnd: _finalizeSeek,
|
||||
onSeekCompleted: widget.onSeekCompleted,
|
||||
onPlayPause: () {}, // Not used, handled internally
|
||||
onCancelAutoHide: () => _hideTimer?.cancel(),
|
||||
onStartAutoHide: _startHideTimer,
|
||||
onBack: widget.onBack,
|
||||
onNext: widget.onNext,
|
||||
onPrevious: widget.onPrevious,
|
||||
canControl: widget.canControl,
|
||||
hasFirstFrame: widget.hasFirstFrame,
|
||||
),
|
||||
)
|
||||
: Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPointerDown: (_) => _restartHideTimerIfPlaying(),
|
||||
child: DesktopVideoControls(
|
||||
key: _desktopControlsKey,
|
||||
player: widget.player,
|
||||
metadata: widget.metadata,
|
||||
onNext: widget.onNext,
|
||||
onPrevious: widget.onPrevious,
|
||||
chapters: _chapters,
|
||||
chaptersLoaded: _chaptersLoaded,
|
||||
seekTimeSmall: _seekTimeSmall,
|
||||
onSeekToPreviousChapter: _seekToPreviousChapter,
|
||||
onSeekToNextChapter: _seekToNextChapter,
|
||||
onSeek: _throttledSeek,
|
||||
onSeekEnd: _finalizeSeek,
|
||||
getReplayIcon: getReplayIcon,
|
||||
getForwardIcon: getForwardIcon,
|
||||
onFocusActivity: _restartHideTimerIfPlaying,
|
||||
onHideControls: _hideControlsFromKeyboard,
|
||||
// Track chapter controls data
|
||||
availableVersions: widget.availableVersions,
|
||||
selectedMediaIndex: widget.selectedMediaIndex,
|
||||
boxFitMode: widget.boxFitMode,
|
||||
audioSyncOffset: _audioSyncOffset,
|
||||
subtitleSyncOffset: _subtitleSyncOffset,
|
||||
isFullscreen: _isFullscreen,
|
||||
isAlwaysOnTop: _isAlwaysOnTop,
|
||||
onCycleBoxFitMode: widget.onCycleBoxFitMode,
|
||||
onToggleFullscreen: _toggleFullscreen,
|
||||
onToggleAlwaysOnTop: _toggleAlwaysOnTop,
|
||||
onSwitchVersion: _switchMediaVersion,
|
||||
onAudioTrackChanged: widget.onAudioTrackChanged,
|
||||
onSubtitleTrackChanged: widget.onSubtitleTrackChanged,
|
||||
onLoadSeekTimes: () async {
|
||||
if (mounted) {
|
||||
await _loadSeekTimes();
|
||||
}
|
||||
},
|
||||
onCancelAutoHide: () => _hideTimer?.cancel(),
|
||||
onStartAutoHide: _startHideTimer,
|
||||
serverId: widget.metadata.serverId ?? '',
|
||||
onBack: widget.onBack,
|
||||
canControl: widget.canControl,
|
||||
hasFirstFrame: widget.hasFirstFrame,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1329,6 +1547,13 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
),
|
||||
),
|
||||
),
|
||||
// Speed indicator overlay for long-press 2x
|
||||
if (_showSpeedIndicator)
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: _buildSpeedIndicator(),
|
||||
),
|
||||
),
|
||||
// Skip intro/credits button
|
||||
if (_currentMarker != null)
|
||||
Positioned(
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Update icon cache
|
||||
if command -v gtk-update-icon-cache &> /dev/null; then
|
||||
gtk-update-icon-cache -f -t /usr/share/icons/hicolor || true
|
||||
fi
|
||||
|
||||
# Update desktop database
|
||||
if command -v update-desktop-database &> /dev/null; then
|
||||
update-desktop-database /usr/share/applications || true
|
||||
fi
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Update icon cache
|
||||
if command -v gtk-update-icon-cache &> /dev/null; then
|
||||
gtk-update-icon-cache -f -t /usr/share/icons/hicolor || true
|
||||
fi
|
||||
|
||||
# Update desktop database
|
||||
if command -v update-desktop-database &> /dev/null; then
|
||||
update-desktop-database /usr/share/applications || true
|
||||
fi
|
||||
Executable
+192
@@ -0,0 +1,192 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# Paths
|
||||
SCRIPT_DIR = Path(__file__).parent.resolve()
|
||||
PROJECT_ROOT = SCRIPT_DIR.parent.parent
|
||||
BUILD_DIR = PROJECT_ROOT / "build/linux/x64/release/bundle"
|
||||
OUTPUT_DIR = Path(os.environ.get("OUTPUT_DIR", PROJECT_ROOT))
|
||||
|
||||
# Package metadata
|
||||
METADATA = {
|
||||
"name": "plezy",
|
||||
"license": "Proprietary",
|
||||
"vendor": "edde746",
|
||||
"maintainer": "edde746 <noreply@github.com>",
|
||||
"url": "https://github.com/edde746/plezy",
|
||||
"description": "A modern Plex client for desktop and mobile",
|
||||
}
|
||||
|
||||
# Icon sizes to generate
|
||||
ICON_SIZES = [16, 32, 48, 64, 128, 256, 512]
|
||||
|
||||
# Distro-specific configuration
|
||||
DISTROS = {
|
||||
"deb": {
|
||||
"type": "deb",
|
||||
"arch": "amd64",
|
||||
"category": "video",
|
||||
"ext": "deb",
|
||||
"compression": ["--deb-compression", "xz", "--deb-priority", "optional"],
|
||||
"depends": [
|
||||
"libgtk-3-0",
|
||||
"libmpv2 | libmpv1",
|
||||
"libepoxy0",
|
||||
"libkeybinder-3.0-0",
|
||||
"libasound2",
|
||||
"libglib2.0-0",
|
||||
],
|
||||
},
|
||||
"rpm": {
|
||||
"type": "rpm",
|
||||
"arch": "x86_64",
|
||||
"category": "Multimedia",
|
||||
"ext": "rpm",
|
||||
"compression": ["--rpm-compression", "xzmt"],
|
||||
"depends": [
|
||||
"gtk3",
|
||||
"mpv-libs",
|
||||
"libepoxy",
|
||||
"keybinder3",
|
||||
"alsa-lib",
|
||||
"glib2",
|
||||
],
|
||||
},
|
||||
"pacman": {
|
||||
"type": "pacman",
|
||||
"arch": "x86_64",
|
||||
"category": None,
|
||||
"ext": "pkg.tar.zst",
|
||||
"compression": ["--pacman-compression", "zstd"],
|
||||
"depends": [
|
||||
"gtk3",
|
||||
"mpv",
|
||||
"libepoxy",
|
||||
"keybinder3",
|
||||
"alsa-lib",
|
||||
"glib2",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def get_version() -> str:
|
||||
"""Extract version from pubspec.yaml."""
|
||||
pubspec = PROJECT_ROOT / "pubspec.yaml"
|
||||
content = pubspec.read_text()
|
||||
match = re.search(r"^version:\s*(.+)$", content, re.MULTILINE)
|
||||
if not match:
|
||||
raise RuntimeError("Could not find version in pubspec.yaml")
|
||||
return match.group(1).split("+")[0]
|
||||
|
||||
|
||||
def generate_icons():
|
||||
"""Generate icons at multiple sizes using ImageMagick."""
|
||||
print("Generating icons...")
|
||||
source = PROJECT_ROOT / "assets/plezy.png"
|
||||
|
||||
for size in ICON_SIZES:
|
||||
dest_dir = SCRIPT_DIR / f"icons/{size}x{size}"
|
||||
dest_dir.mkdir(parents=True, exist_ok=True)
|
||||
dest = dest_dir / "plezy.png"
|
||||
|
||||
# Try magick (ImageMagick 7) first, then convert (ImageMagick 6)
|
||||
for cmd in ["magick", "convert"]:
|
||||
if shutil.which(cmd):
|
||||
subprocess.run([cmd, str(source), "-resize", f"{size}x{size}", str(dest)], check=True)
|
||||
break
|
||||
else:
|
||||
print(f"Warning: ImageMagick not found, copying original icon for {size}x{size}")
|
||||
shutil.copy(source, dest)
|
||||
|
||||
|
||||
def get_file_mappings() -> list[str]:
|
||||
"""Get file mappings for fpm."""
|
||||
mappings = [
|
||||
f"{BUILD_DIR}/=/opt/plezy/",
|
||||
f"{SCRIPT_DIR}/com.edde746.plezy.desktop=/usr/share/applications/com.edde746.plezy.desktop",
|
||||
f"{SCRIPT_DIR}/plezy.sh=/usr/bin/plezy",
|
||||
]
|
||||
|
||||
for size in ICON_SIZES:
|
||||
mappings.append(
|
||||
f"{SCRIPT_DIR}/icons/{size}x{size}/plezy.png=/usr/share/icons/hicolor/{size}x{size}/apps/plezy.png"
|
||||
)
|
||||
|
||||
return mappings
|
||||
|
||||
|
||||
def build_package(distro: str, version: str):
|
||||
"""Build a package for the specified distro."""
|
||||
config = DISTROS[distro]
|
||||
output_file = OUTPUT_DIR / f"{METADATA['name']}-linux.{config['ext']}"
|
||||
|
||||
print(f"Building .{config['ext']} package...")
|
||||
|
||||
cmd = [
|
||||
"fpm",
|
||||
"-s", "dir",
|
||||
"-t", config["type"],
|
||||
"-n", METADATA["name"],
|
||||
"-v", version,
|
||||
"--iteration", "1",
|
||||
"--license", METADATA["license"],
|
||||
"--vendor", METADATA["vendor"],
|
||||
"--maintainer", METADATA["maintainer"],
|
||||
"--url", METADATA["url"],
|
||||
"--description", METADATA["description"],
|
||||
"--architecture", config["arch"],
|
||||
]
|
||||
|
||||
if config["category"]:
|
||||
cmd.extend(["--category", config["category"]])
|
||||
|
||||
for dep in config["depends"]:
|
||||
cmd.extend(["--depends", dep])
|
||||
|
||||
cmd.extend(config["compression"])
|
||||
|
||||
cmd.extend([
|
||||
"--after-install", str(SCRIPT_DIR / "after-install.sh"),
|
||||
"--after-remove", str(SCRIPT_DIR / "after-remove.sh"),
|
||||
"--package", str(output_file),
|
||||
])
|
||||
|
||||
cmd.extend(get_file_mappings())
|
||||
|
||||
subprocess.run(cmd, check=True)
|
||||
print(f"Created: {output_file}")
|
||||
|
||||
|
||||
def main():
|
||||
# Verify build exists
|
||||
if not BUILD_DIR.exists():
|
||||
print(f"Error: Build directory not found at {BUILD_DIR}")
|
||||
print("Please run 'flutter build linux --release' first")
|
||||
exit(1)
|
||||
|
||||
version = get_version()
|
||||
print(f"Building packages for {METADATA['name']} version {version}")
|
||||
|
||||
# Make scripts executable
|
||||
for script in ["plezy.sh", "after-install.sh", "after-remove.sh"]:
|
||||
(SCRIPT_DIR / script).chmod(0o755)
|
||||
|
||||
# Generate icons
|
||||
generate_icons()
|
||||
|
||||
# Build all packages
|
||||
for distro in DISTROS:
|
||||
build_package(distro, version)
|
||||
|
||||
print("\nAll packages built successfully!")
|
||||
for f in OUTPUT_DIR.glob(f"{METADATA['name']}-linux.*"):
|
||||
print(f" {f}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Plezy
|
||||
Comment=A modern Plex client for desktop and mobile
|
||||
Exec=/opt/plezy/plezy
|
||||
Icon=plezy
|
||||
Terminal=false
|
||||
Categories=AudioVideo;Video;Player;
|
||||
Keywords=plex;media;streaming;video;
|
||||
StartupWMClass=plezy
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
cd /opt/plezy
|
||||
exec ./plezy "$@"
|
||||
@@ -17,7 +17,6 @@ import os_media_controls
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import screen_retriever_macos
|
||||
import share_plus
|
||||
import shared_preferences_foundation
|
||||
import sqflite_darwin
|
||||
import sqlite3_flutter_libs
|
||||
@@ -38,7 +37,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||
|
||||
@@ -28,8 +28,6 @@ PODS:
|
||||
- FlutterMacOS
|
||||
- screen_retriever_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- share_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
@@ -83,7 +81,6 @@ DEPENDENCIES:
|
||||
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
|
||||
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- screen_retriever_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos`)
|
||||
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
|
||||
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- sqflite_darwin (from `Flutter/ephemeral/.symlinks/plugins/sqflite_darwin/darwin`)
|
||||
- sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/darwin`)
|
||||
@@ -124,8 +121,6 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
|
||||
screen_retriever_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/screen_retriever_macos/macos
|
||||
share_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos
|
||||
shared_preferences_foundation:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
|
||||
sqflite_darwin:
|
||||
@@ -154,7 +149,6 @@ SPEC CHECKSUMS:
|
||||
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
|
||||
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
|
||||
screen_retriever_macos: 452e51764a9e1cdb74b3c541238795849f21557f
|
||||
share_plus: 510bf0af1a42cd602274b4629920c9649c52f4cc
|
||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
|
||||
sqlite3: 8d708bc63e9f4ce48f0ad9d6269e478c5ced1d9b
|
||||
|
||||
+9
-17
@@ -281,6 +281,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
dart_discord_presence:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dart_discord_presence
|
||||
sha256: "4679b197eb37af3676766bbfba9f1f766ba27131588237f13ea7085e9dfe068a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1105,22 +1113,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
share_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: share_plus
|
||||
sha256: fce43200aa03ea87b91ce4c3ac79f0cecd52e2a7a56c7a4185023c271fbfa6da
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.1.4"
|
||||
share_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: share_plus_platform_interface
|
||||
sha256: cc012a23fc2d479854e6c80150696c4a5f5bb62cb89af4de1c505cf78d0a5d0b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.2"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1615,5 +1607,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.9.2 <4.0.0"
|
||||
dart: ">=3.10.4 <4.0.0"
|
||||
flutter: ">=3.35.0"
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
name: plezy
|
||||
description: "A beautiful Plex client for Flutter"
|
||||
publish_to: "none"
|
||||
version: 1.12.0+28
|
||||
version: 1.13.0+29
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
@@ -46,8 +46,8 @@ dependencies:
|
||||
saf_stream: ^0.12.2
|
||||
material_symbols_icons: ^4.2892.0
|
||||
peerdart: ^0.5.6
|
||||
share_plus: ^10.0.0
|
||||
in_app_review: ^2.0.11
|
||||
dart_discord_presence: ^1.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -18,7 +18,7 @@ Set-Location $ProjectRoot
|
||||
|
||||
# Define paths
|
||||
$BuildDir = "build\windows\x64\runner\Release"
|
||||
$PortableZip = Join-Path (Resolve-Path $OutputDir) "plezy-windows-portable.zip"
|
||||
$PortableZip = Join-Path (Resolve-Path $OutputDir) "plezy-windows-portable.7z"
|
||||
$InstallerExe = Join-Path (Resolve-Path $OutputDir) "plezy-windows-installer.exe"
|
||||
$SetupScript = "setup.iss"
|
||||
|
||||
@@ -30,6 +30,25 @@ if (-not (Test-Path $BuildDir)) {
|
||||
|
||||
Write-Host "Found build at: $BuildDir" -ForegroundColor Green
|
||||
|
||||
# Check for 7-Zip
|
||||
Write-Host "`nChecking for 7-Zip..." -ForegroundColor Cyan
|
||||
if (-not (Get-Command 7z -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "7-Zip not found in PATH. Installing via Chocolatey..." -ForegroundColor Yellow
|
||||
|
||||
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "Chocolatey is not installed. Please install it from https://chocolatey.org/install"
|
||||
exit 1
|
||||
}
|
||||
|
||||
choco install 7zip -y
|
||||
refreshenv
|
||||
|
||||
if (-not (Get-Command 7z -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "Failed to install 7-Zip"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Create Portable Archive
|
||||
Write-Host "`nCreating portable archive..." -ForegroundColor Cyan
|
||||
Push-Location $BuildDir
|
||||
@@ -37,7 +56,7 @@ try {
|
||||
if (Test-Path $PortableZip) {
|
||||
Remove-Item $PortableZip -Force
|
||||
}
|
||||
Compress-Archive -Path * -DestinationPath $PortableZip
|
||||
7z a -mx=9 $PortableZip *
|
||||
Write-Host "Created: $PortableZip" -ForegroundColor Green
|
||||
} finally {
|
||||
Pop-Location
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <hotkey_manager_windows/hotkey_manager_windows_plugin_c_api.h>
|
||||
#include <os_media_controls/os_media_controls_plugin_c_api.h>
|
||||
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
@@ -30,8 +29,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("OsMediaControlsPluginCApi"));
|
||||
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
|
||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
|
||||
@@ -9,7 +9,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
hotkey_manager_windows
|
||||
os_media_controls
|
||||
screen_retriever_windows
|
||||
share_plus
|
||||
sqlite3_flutter_libs
|
||||
url_launcher_windows
|
||||
window_manager
|
||||
|
||||
Reference in New Issue
Block a user