Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3a35d56d9 | ||
|
|
2d706956da | ||
|
|
260681aa24 | ||
|
|
6228eb2690 | ||
|
|
0d4f7a9e9f | ||
|
|
fac7aed1e7 | ||
|
|
b6234120dd | ||
|
|
2eb33eb234 | ||
|
|
d744e783ac | ||
|
|
3e068b2bea | ||
|
|
36a843b43f | ||
|
|
3f40007f03 | ||
|
|
66941b06d4 | ||
|
|
47f5454f61 | ||
|
|
2a6098c3ba | ||
|
|
60a84380a6 | ||
|
|
e047c820ae | ||
|
|
e4e7911573 | ||
|
|
7fcf79045b | ||
|
|
40b3142d23 | ||
|
|
8f18a7c941 |
@@ -3,6 +3,10 @@
|
||||
<!-- Internet access permissions -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<!-- Media session permissions for OS media controls -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
|
||||
|
||||
<!-- Explicitly remove media permissions that media_kit may add -->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" tools:node="remove" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" tools:node="remove" />
|
||||
|
||||
|
Before Width: | Height: | Size: 582 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 724 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -8,7 +8,7 @@
|
||||
</foreground>
|
||||
<monochrome>
|
||||
<inset
|
||||
android:drawable="@drawable/ic_launcher_monochrome"
|
||||
android:drawable="@mipmap/ic_launcher_monochrome"
|
||||
android:inset="16%" />
|
||||
</monochrome>
|
||||
</adaptive-icon>
|
||||
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -4,6 +4,8 @@ PODS:
|
||||
- Flutter
|
||||
- media_kit_video (0.0.1):
|
||||
- Flutter
|
||||
- os_media_controls (0.0.1):
|
||||
- Flutter
|
||||
- package_info_plus (0.4.5):
|
||||
- Flutter
|
||||
- path_provider_foundation (0.0.1):
|
||||
@@ -26,6 +28,7 @@ DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
|
||||
- media_kit_video (from `.symlinks/plugins/media_kit_video/ios`)
|
||||
- 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`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
@@ -41,6 +44,8 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/media_kit_libs_ios_video/ios"
|
||||
media_kit_video:
|
||||
:path: ".symlinks/plugins/media_kit_video/ios"
|
||||
os_media_controls:
|
||||
:path: ".symlinks/plugins/os_media_controls/ios"
|
||||
package_info_plus:
|
||||
:path: ".symlinks/plugins/package_info_plus/ios"
|
||||
path_provider_foundation:
|
||||
@@ -60,9 +65,10 @@ SPEC CHECKSUMS:
|
||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||
media_kit_libs_ios_video: 5a18affdb97d1f5d466dc79988b13eff6c5e2854
|
||||
media_kit_video: 1746e198cb697d1ffb734b1d05ec429d1fcd1474
|
||||
os_media_controls: 86dceab6245a5325af90fc0fdebe243c42d789b4
|
||||
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
||||
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
|
||||
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
|
||||
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
|
||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
|
||||
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
|
||||
volume_controller: 3657a1f65bedb98fa41ff7dc5793537919f31b12
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Flutter
|
||||
import UIKit
|
||||
import AVFoundation
|
||||
|
||||
@main
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
@@ -8,6 +9,18 @@ import UIKit
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
|
||||
// Configure audio session for media playback
|
||||
do {
|
||||
let session = AVAudioSession.sharedInstance()
|
||||
try session.setCategory(.playback, mode: .default)
|
||||
try session.setActive(true)
|
||||
} catch {
|
||||
print("Failed to configure audio session: \(error)")
|
||||
}
|
||||
|
||||
application.beginReceivingRemoteControlEvents()
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
<string>This app needs to connect to your Plex Media Server on your local network.</string>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>audio</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
|
||||
@@ -38,7 +38,7 @@ class PlexClient {
|
||||
baseUrl: config.baseUrl,
|
||||
headers: config.headers,
|
||||
connectTimeout: const Duration(seconds: 10),
|
||||
receiveTimeout: const Duration(seconds: 30),
|
||||
receiveTimeout: const Duration(seconds: 120),
|
||||
validateStatus: (status) => status != null && status < 500,
|
||||
responseType: ResponseType.json,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
@@ -228,6 +228,7 @@ class PlexClient {
|
||||
int? start,
|
||||
int? size,
|
||||
Map<String, String>? filters,
|
||||
CancelToken? cancelToken,
|
||||
}) async {
|
||||
final queryParams = <String, dynamic>{};
|
||||
if (start != null) queryParams['X-Plex-Container-Start'] = start;
|
||||
@@ -241,6 +242,7 @@ class PlexClient {
|
||||
final response = await _dio.get(
|
||||
'/library/sections/$sectionId/all',
|
||||
queryParameters: queryParams,
|
||||
cancelToken: cancelToken,
|
||||
);
|
||||
|
||||
return _extractMetadataList(response);
|
||||
|
||||
@@ -77,6 +77,50 @@ class PlexSubtitleTrack {
|
||||
if (forced) parts.add('Forced');
|
||||
return parts.isEmpty ? 'Track ${index ?? id}' : parts.join(' · ');
|
||||
}
|
||||
|
||||
/// Returns true if this subtitle track is an external file (sidecar subtitle)
|
||||
/// External subtitles have a key property that points to /library/streams/{id}
|
||||
bool get isExternal => key != null && key!.isNotEmpty;
|
||||
|
||||
/// Constructs the full URL for fetching external subtitle files
|
||||
/// Returns null if this is not an external subtitle
|
||||
String? getSubtitleUrl(String baseUrl, String token) {
|
||||
if (!isExternal) return null;
|
||||
|
||||
// Determine file extension based on codec
|
||||
final ext = _getExtensionFromCodec(codec);
|
||||
|
||||
// Construct URL with authentication token
|
||||
return '$baseUrl$key.$ext?X-Plex-Token=$token';
|
||||
}
|
||||
|
||||
/// Maps Plex subtitle codec names to file extensions
|
||||
String _getExtensionFromCodec(String? codec) {
|
||||
if (codec == null) return 'srt';
|
||||
|
||||
switch (codec.toLowerCase()) {
|
||||
case 'subrip':
|
||||
case 'srt':
|
||||
return 'srt';
|
||||
case 'ass':
|
||||
return 'ass';
|
||||
case 'ssa':
|
||||
return 'ssa';
|
||||
case 'webvtt':
|
||||
case 'vtt':
|
||||
return 'vtt';
|
||||
case 'mov_text':
|
||||
return 'srt';
|
||||
case 'pgs':
|
||||
case 'hdmv_pgs_subtitle':
|
||||
return 'sup';
|
||||
case 'dvd_subtitle':
|
||||
case 'dvdsub':
|
||||
return 'sub';
|
||||
default:
|
||||
return 'srt'; // Default to SRT for unknown codecs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlexChapter {
|
||||
|
||||
@@ -25,7 +25,8 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
|
||||
/// Gets the next episode in the shuffle queue.
|
||||
/// Returns null if queue is exhausted or current episode is not in queue.
|
||||
PlexMetadata? getNextEpisode(String currentEpisodeKey) {
|
||||
/// [loopQueue] - If true, restart from beginning when queue is exhausted
|
||||
PlexMetadata? getNextEpisode(String currentEpisodeKey, {bool loopQueue = false}) {
|
||||
if (_shuffleQueue.isEmpty) return null;
|
||||
|
||||
// Find current episode in queue
|
||||
@@ -42,6 +43,11 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
// Check if there's a next episode
|
||||
if (currentIndex + 1 >= _shuffleQueue.length) {
|
||||
// Queue exhausted
|
||||
if (loopQueue && _shuffleQueue.isNotEmpty) {
|
||||
// Loop back to beginning
|
||||
_currentIndex = 0;
|
||||
return _shuffleQueue[_currentIndex];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,6 +55,31 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
return _shuffleQueue[_currentIndex];
|
||||
}
|
||||
|
||||
/// Gets the previous episode in the shuffle queue.
|
||||
/// Returns null if at the beginning of the queue or current episode is not in queue.
|
||||
PlexMetadata? getPreviousEpisode(String currentEpisodeKey) {
|
||||
if (_shuffleQueue.isEmpty) return null;
|
||||
|
||||
// Find current episode in queue
|
||||
final currentIndex = _shuffleQueue.indexWhere(
|
||||
(ep) => ep.ratingKey == currentEpisodeKey,
|
||||
);
|
||||
|
||||
if (currentIndex == -1) {
|
||||
// Current episode not in queue
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if there's a previous episode
|
||||
if (currentIndex <= 0) {
|
||||
// At the beginning of queue
|
||||
return null;
|
||||
}
|
||||
|
||||
_currentIndex = currentIndex - 1;
|
||||
return _shuffleQueue[_currentIndex];
|
||||
}
|
||||
|
||||
/// Clears the shuffle queue and exits shuffle mode
|
||||
void clearShuffle() {
|
||||
_shuffleQueue = [];
|
||||
|
||||
@@ -7,6 +7,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
ViewMode _viewMode = ViewMode.grid;
|
||||
bool _useSeasonPoster = false;
|
||||
bool _showHeroSection = true;
|
||||
bool _shuffleUnwatchedOnly = true;
|
||||
bool _shuffleOrderNavigation = true;
|
||||
bool _shuffleLoopQueue = false;
|
||||
|
||||
SettingsProvider() {
|
||||
_initializeSettings();
|
||||
@@ -18,6 +21,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_viewMode = _settingsService.getViewMode();
|
||||
_useSeasonPoster = _settingsService.getUseSeasonPoster();
|
||||
_showHeroSection = _settingsService.getShowHeroSection();
|
||||
_shuffleUnwatchedOnly = _settingsService.getShuffleUnwatchedOnly();
|
||||
_shuffleOrderNavigation = _settingsService.getShuffleOrderNavigation();
|
||||
_shuffleLoopQueue = _settingsService.getShuffleLoopQueue();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -25,6 +31,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
ViewMode get viewMode => _viewMode;
|
||||
bool get useSeasonPoster => _useSeasonPoster;
|
||||
bool get showHeroSection => _showHeroSection;
|
||||
bool get shuffleUnwatchedOnly => _shuffleUnwatchedOnly;
|
||||
bool get shuffleOrderNavigation => _shuffleOrderNavigation;
|
||||
bool get shuffleLoopQueue => _shuffleLoopQueue;
|
||||
|
||||
Future<void> setLibraryDensity(LibraryDensity density) async {
|
||||
if (_libraryDensity != density) {
|
||||
@@ -58,6 +67,30 @@ class SettingsProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setShuffleUnwatchedOnly(bool value) async {
|
||||
if (_shuffleUnwatchedOnly != value) {
|
||||
_shuffleUnwatchedOnly = value;
|
||||
await _settingsService.setShuffleUnwatchedOnly(value);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setShuffleOrderNavigation(bool value) async {
|
||||
if (_shuffleOrderNavigation != value) {
|
||||
_shuffleOrderNavigation = value;
|
||||
await _settingsService.setShuffleOrderNavigation(value);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setShuffleLoopQueue(bool value) async {
|
||||
if (_shuffleLoopQueue != value) {
|
||||
_shuffleLoopQueue = value;
|
||||
await _settingsService.setShuffleLoopQueue(value);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
String get libraryDensityDisplayName {
|
||||
switch (_libraryDensity) {
|
||||
case LibraryDensity.compact:
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import '../services/plex_auth_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import 'server_selection_screen.dart';
|
||||
@@ -18,6 +19,8 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
String? _errorMessage;
|
||||
late PlexAuthService _authService;
|
||||
bool _shouldCancelPolling = false;
|
||||
bool _useQrFlow = false; // whether current auth attempt is QR based
|
||||
String? _qrAuthUrl; // auth URL rendered as QR
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -34,6 +37,10 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
_isAuthenticating = true;
|
||||
_errorMessage = null;
|
||||
_shouldCancelPolling = false;
|
||||
// preserve _useQrFlow as chosen prior to calling
|
||||
if (!_useQrFlow) {
|
||||
_qrAuthUrl = null; // ensure stale QR cleared for browser flow
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -45,12 +52,19 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
// Construct auth URL
|
||||
final authUrl = _authService.getAuthUrl(pinCode);
|
||||
|
||||
// Open browser (in-app for mobile, external for desktop)
|
||||
final uri = Uri.parse(authUrl);
|
||||
if (await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri, mode: LaunchMode.inAppBrowserView);
|
||||
if (_useQrFlow) {
|
||||
// Display QR instead of launching browser
|
||||
setState(() {
|
||||
_qrAuthUrl = authUrl;
|
||||
});
|
||||
} else {
|
||||
throw Exception('Could not launch auth URL');
|
||||
// Open browser (in-app for mobile, external for desktop)
|
||||
final uri = Uri.parse(authUrl);
|
||||
if (await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri, mode: LaunchMode.inAppBrowserView);
|
||||
} else {
|
||||
throw Exception('Could not launch auth URL');
|
||||
}
|
||||
}
|
||||
|
||||
// Poll for authentication with cancellation support
|
||||
@@ -73,10 +87,12 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
}
|
||||
|
||||
// Auto-close the in-app browser on mobile (no-op on desktop)
|
||||
try {
|
||||
await closeInAppWebView();
|
||||
} catch (e) {
|
||||
// Ignore errors - browser might already be closed or on desktop
|
||||
if (!_useQrFlow) {
|
||||
try {
|
||||
await closeInAppWebView();
|
||||
} catch (e) {
|
||||
// Ignore errors - browser might already be closed or on desktop
|
||||
}
|
||||
}
|
||||
|
||||
// Store the token
|
||||
@@ -95,6 +111,11 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
// Clear QR URL after successful auth
|
||||
setState(() {
|
||||
_qrAuthUrl = null;
|
||||
_useQrFlow = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_isAuthenticating = false;
|
||||
@@ -107,6 +128,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
setState(() {
|
||||
_shouldCancelPolling = true;
|
||||
_isAuthenticating = false;
|
||||
_qrAuthUrl = null;
|
||||
});
|
||||
// Start new authentication after a brief delay to ensure cleanup
|
||||
Future.delayed(const Duration(milliseconds: 100), _startAuthentication);
|
||||
@@ -226,11 +248,30 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
if (_isAuthenticating) ...[
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Waiting for authentication...\nPlease complete sign-in in your browser.',
|
||||
Text(
|
||||
_useQrFlow
|
||||
? 'Scan this QR code with a device logged into Plex to authenticate.'
|
||||
: 'Waiting for authentication...\nPlease complete sign-in in your browser.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
),
|
||||
if (_useQrFlow && _qrAuthUrl != null) ...[
|
||||
const SizedBox(height: 24),
|
||||
Center(
|
||||
child: QrImageView(
|
||||
data: _qrAuthUrl!,
|
||||
size: 200,
|
||||
version: QrVersions.auto,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SelectableText(
|
||||
_qrAuthUrl!,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 10, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
OutlinedButton(
|
||||
onPressed: _retryAuthentication,
|
||||
@@ -242,7 +283,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
),
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
] else ...[
|
||||
] else ...[ // add QR button here
|
||||
ElevatedButton(
|
||||
onPressed: _startAuthentication,
|
||||
style: ElevatedButton.styleFrom(
|
||||
@@ -250,6 +291,19 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
),
|
||||
child: const Text('Sign in with Plex'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_useQrFlow = true;
|
||||
});
|
||||
_startAuthentication();
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
child: const Text('Show QR Code'),
|
||||
),
|
||||
if (kDebugMode) ...[
|
||||
const SizedBox(height: 12),
|
||||
OutlinedButton(
|
||||
|
||||
@@ -46,6 +46,13 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
bool _isSortDescending = false;
|
||||
bool _isInitialLoad = true;
|
||||
|
||||
// Pagination state
|
||||
int _currentPage = 0;
|
||||
bool _hasMoreItems = true;
|
||||
CancelToken? _cancelToken;
|
||||
int _requestId = 0;
|
||||
static const int _pageSize = 1000;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -201,7 +208,6 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
await storage.saveLibraryOrder(libraryKeys);
|
||||
}
|
||||
|
||||
|
||||
Future<void> _loadLibraryContent(String libraryKey) async {
|
||||
// Compute visible libraries based on current provider state
|
||||
final hiddenLibrariesProvider = Provider.of<HiddenLibrariesProvider>(
|
||||
@@ -257,6 +263,18 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
await storage.saveLibraryFilters({});
|
||||
}
|
||||
|
||||
// Cancel any existing requests
|
||||
_cancelToken?.cancel();
|
||||
_cancelToken = CancelToken();
|
||||
final currentRequestId = ++_requestId;
|
||||
|
||||
// Reset pagination state
|
||||
setState(() {
|
||||
_currentPage = 0;
|
||||
_hasMoreItems = true;
|
||||
_items = [];
|
||||
});
|
||||
|
||||
try {
|
||||
// Load filters and sort options for the new library
|
||||
_loadFilters(libraryKey);
|
||||
@@ -270,16 +288,19 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
);
|
||||
}
|
||||
|
||||
// Load content
|
||||
final items = await client.getLibraryContent(
|
||||
// Load pages sequentially
|
||||
await _loadAllPagesSequentially(
|
||||
libraryKey,
|
||||
filters: filtersWithSort,
|
||||
filtersWithSort,
|
||||
currentRequestId,
|
||||
client,
|
||||
);
|
||||
setState(() {
|
||||
_items = items;
|
||||
_isLoadingItems = false;
|
||||
});
|
||||
} catch (e) {
|
||||
// Ignore cancellation errors
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_errorMessage = _getErrorMessage(e, 'library content');
|
||||
_isLoadingItems = false;
|
||||
@@ -287,6 +308,54 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
}
|
||||
}
|
||||
|
||||
/// Load all pages sequentially until all items are fetched
|
||||
Future<void> _loadAllPagesSequentially(
|
||||
String libraryKey,
|
||||
Map<String, String> filtersWithSort,
|
||||
int requestId,
|
||||
PlexClient client,
|
||||
) async {
|
||||
while (_hasMoreItems && requestId == _requestId) {
|
||||
try {
|
||||
final items = await client.getLibraryContent(
|
||||
libraryKey,
|
||||
start: _currentPage * _pageSize,
|
||||
size: _pageSize,
|
||||
filters: filtersWithSort,
|
||||
cancelToken: _cancelToken,
|
||||
);
|
||||
|
||||
// Check if request is still valid
|
||||
if (requestId != _requestId) {
|
||||
return; // Request was superseded
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_items.addAll(items);
|
||||
_currentPage++;
|
||||
_hasMoreItems = items.length >= _pageSize;
|
||||
|
||||
// Mark as not loading if this is the last page
|
||||
if (!_hasMoreItems) {
|
||||
_isLoadingItems = false;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// Check if it's a cancellation
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For other errors, update state and rethrow
|
||||
setState(() {
|
||||
_isLoadingItems = false;
|
||||
_hasMoreItems = false;
|
||||
});
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadFilters(String libraryKey) async {
|
||||
try {
|
||||
final clientProvider = Provider.of<PlexClientProvider>(
|
||||
@@ -360,9 +429,17 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
}
|
||||
|
||||
Future<void> _applyFilters() async {
|
||||
// Cancel any existing requests
|
||||
_cancelToken?.cancel();
|
||||
_cancelToken = CancelToken();
|
||||
final currentRequestId = ++_requestId;
|
||||
|
||||
setState(() {
|
||||
_isLoadingItems = true;
|
||||
_errorMessage = null;
|
||||
_currentPage = 0;
|
||||
_hasMoreItems = true;
|
||||
_items = [];
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -383,15 +460,19 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
);
|
||||
}
|
||||
|
||||
final items = await client.getLibraryContent(
|
||||
// Load pages sequentially
|
||||
await _loadAllPagesSequentially(
|
||||
_selectedLibraryKey!,
|
||||
filters: filtersWithSort,
|
||||
filtersWithSort,
|
||||
currentRequestId,
|
||||
client,
|
||||
);
|
||||
setState(() {
|
||||
_items = items;
|
||||
_isLoadingItems = false;
|
||||
});
|
||||
} catch (e) {
|
||||
// Ignore cancellation errors
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_errorMessage = 'Failed to load library content: $e';
|
||||
_isLoadingItems = false;
|
||||
@@ -912,7 +993,7 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
),
|
||||
|
||||
// Content grid
|
||||
if (_isLoadingItems)
|
||||
if (_isLoadingItems && _items.isEmpty)
|
||||
const SliverFillRemaining(
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
@@ -952,24 +1033,21 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
else ...[
|
||||
Consumer<SettingsProvider>(
|
||||
builder: (context, settingsProvider, child) {
|
||||
if (settingsProvider.viewMode == ViewMode.list) {
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final item = _items[index];
|
||||
return MediaCard(
|
||||
key: Key(item.ratingKey),
|
||||
item: item,
|
||||
onRefresh: updateItem,
|
||||
);
|
||||
},
|
||||
childCount: _items.length,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final item = _items[index];
|
||||
return MediaCard(
|
||||
key: Key(item.ratingKey),
|
||||
item: item,
|
||||
onRefresh: updateItem,
|
||||
);
|
||||
}, childCount: _items.length),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
@@ -998,6 +1076,24 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
}
|
||||
},
|
||||
),
|
||||
// Show loading indicator if there are more items to load
|
||||
if (_hasMoreItems && _isLoadingItems)
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Loading library... (${_items.length} items loaded)',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
@@ -1450,7 +1546,9 @@ class _SortBottomSheetState extends State<_SortBottomSheet> {
|
||||
child: RadioGroup<String>(
|
||||
groupValue: _tempSelectedSort?.key,
|
||||
onChanged: (value) {
|
||||
final sort = widget.sortOptions.firstWhere((s) => s.key == value);
|
||||
final sort = widget.sortOptions.firstWhere(
|
||||
(s) => s.key == value,
|
||||
);
|
||||
setState(() {
|
||||
_tempSelectedSort = sort;
|
||||
// Use default direction for newly selected sort
|
||||
@@ -1483,7 +1581,10 @@ class _SortBottomSheetState extends State<_SortBottomSheet> {
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: Icon(Icons.arrow_downward, size: 16),
|
||||
icon: Icon(
|
||||
Icons.arrow_downward,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
selected: {_tempDescending},
|
||||
@@ -1717,9 +1818,11 @@ class _LibraryManagementSheetState extends State<_LibraryManagementSheet> {
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Icon(
|
||||
Icons.drag_indicator,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.color?.withValues(alpha: 0.5),
|
||||
color: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.color
|
||||
?.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -75,6 +75,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
const SizedBox(height: 24),
|
||||
_buildVideoPlaybackSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildShufflePlaySection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildKeyboardShortcutsSection(),
|
||||
const SizedBox(height: 24),
|
||||
_buildAdvancedSection(),
|
||||
@@ -248,6 +250,70 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShufflePlaySection() {
|
||||
return Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
'Shuffle Play',
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Consumer<SettingsProvider>(
|
||||
builder: (context, settingsProvider, child) {
|
||||
return SwitchListTile(
|
||||
secondary: const Icon(Icons.visibility_off),
|
||||
title: const Text('Unwatched Only'),
|
||||
subtitle: const Text(
|
||||
'Only include unwatched episodes in shuffle queue',
|
||||
),
|
||||
value: settingsProvider.shuffleUnwatchedOnly,
|
||||
onChanged: (value) async {
|
||||
await settingsProvider.setShuffleUnwatchedOnly(value);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Consumer<SettingsProvider>(
|
||||
builder: (context, settingsProvider, child) {
|
||||
return SwitchListTile(
|
||||
secondary: const Icon(Icons.shuffle),
|
||||
title: const Text('Shuffle Order Navigation'),
|
||||
subtitle: const Text(
|
||||
'Next/previous buttons follow shuffled order',
|
||||
),
|
||||
value: settingsProvider.shuffleOrderNavigation,
|
||||
onChanged: (value) async {
|
||||
await settingsProvider.setShuffleOrderNavigation(value);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Consumer<SettingsProvider>(
|
||||
builder: (context, settingsProvider, child) {
|
||||
return SwitchListTile(
|
||||
secondary: const Icon(Icons.loop),
|
||||
title: const Text('Loop Shuffle Queue'),
|
||||
subtitle: const Text(
|
||||
'Restart queue when reaching the end',
|
||||
),
|
||||
value: settingsProvider.shuffleLoopQueue,
|
||||
onChanged: (value) async {
|
||||
await settingsProvider.setShuffleLoopQueue(value);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildKeyboardShortcutsSection() {
|
||||
return Card(
|
||||
child: Column(
|
||||
|
||||
@@ -4,10 +4,12 @@ import 'package:flutter/services.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:media_kit_video/media_kit_video.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:os_media_controls/os_media_controls.dart';
|
||||
import '../models/plex_metadata.dart';
|
||||
import '../models/plex_user_profile.dart';
|
||||
import '../providers/plex_client_provider.dart';
|
||||
import '../providers/playback_state_provider.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../widgets/video_controls/video_controls.dart';
|
||||
import '../utils/language_codes.dart';
|
||||
@@ -54,7 +56,10 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
StreamSubscription<String>? _errorSubscription;
|
||||
StreamSubscription<bool>? _playingSubscription;
|
||||
StreamSubscription<bool>? _completedSubscription;
|
||||
bool _isReplacingWithVideo = false; // Flag to skip orientation restoration during video-to-video navigation
|
||||
StreamSubscription<Duration>? _positionSubscription;
|
||||
StreamSubscription<dynamic>? _mediaControlSubscription;
|
||||
bool _isReplacingWithVideo =
|
||||
false; // Flag to skip orientation restoration during video-to-video navigation
|
||||
|
||||
// BoxFit mode state: 0=contain (letterbox), 1=cover (fill screen), 2=fill (stretch)
|
||||
int _boxFitMode = 0;
|
||||
@@ -123,10 +128,13 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
mpvConfiguration: {
|
||||
'sub-font-size': settingsService.getSubtitleFontSize().toString(),
|
||||
'sub-color': settingsService.getSubtitleTextColor(),
|
||||
'sub-border-size': settingsService.getSubtitleBorderSize().toString(),
|
||||
'sub-border-size': settingsService
|
||||
.getSubtitleBorderSize()
|
||||
.toString(),
|
||||
'sub-border-color': settingsService.getSubtitleBorderColor(),
|
||||
'sub-back-color': '#${(settingsService.getSubtitleBackgroundOpacity() * 255 / 100).toInt().toRadixString(16).padLeft(2, '0').toUpperCase()}${settingsService.getSubtitleBackgroundColor().replaceFirst('#', '')}',
|
||||
}
|
||||
'sub-back-color':
|
||||
'#${(settingsService.getSubtitleBackgroundOpacity() * 255 / 100).toInt().toRadixString(16).padLeft(2, '0').toUpperCase()}${settingsService.getSubtitleBackgroundColor().replaceFirst('#', '')}',
|
||||
},
|
||||
),
|
||||
);
|
||||
controller = VideoController(
|
||||
@@ -194,10 +202,14 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
}
|
||||
|
||||
// Listen to playback state changes
|
||||
_playingSubscription = player!.stream.playing.listen(_onPlayingStateChanged);
|
||||
_playingSubscription = player!.stream.playing.listen(
|
||||
_onPlayingStateChanged,
|
||||
);
|
||||
|
||||
// Listen to completion
|
||||
_completedSubscription = player!.stream.completed.listen(_onVideoCompleted);
|
||||
_completedSubscription = player!.stream.completed.listen(
|
||||
_onVideoCompleted,
|
||||
);
|
||||
|
||||
// Listen to MPV logs
|
||||
_logSubscription = player!.stream.log.listen(_onPlayerLog);
|
||||
@@ -205,6 +217,14 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
// Listen to MPV errors
|
||||
_errorSubscription = player!.stream.error.listen(_onPlayerError);
|
||||
|
||||
// Listen to position updates for media controls
|
||||
_positionSubscription = player!.stream.position.listen((_) {
|
||||
_updateMediaControlsPosition();
|
||||
});
|
||||
|
||||
// Initialize OS media controls
|
||||
_initializeMediaControls();
|
||||
|
||||
// Start periodic progress updates
|
||||
_startProgressTracking();
|
||||
|
||||
@@ -220,6 +240,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _loadAdjacentEpisodes() async {
|
||||
if (widget.metadata.type.toLowerCase() != 'episode') {
|
||||
return;
|
||||
@@ -231,16 +252,29 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
if (client == null) return;
|
||||
|
||||
final playbackState = context.read<PlaybackStateProvider>();
|
||||
final settingsProvider = context.read<SettingsProvider>();
|
||||
|
||||
PlexMetadata? next;
|
||||
PlexMetadata? previous;
|
||||
|
||||
// Check if shuffle mode is active
|
||||
if (playbackState.isShuffleActive) {
|
||||
// Get next episode from shuffle queue
|
||||
next = playbackState.getNextEpisode(widget.metadata.ratingKey);
|
||||
// No previous episode in shuffle mode
|
||||
previous = null;
|
||||
// Get settings
|
||||
final shuffleOrderNavigation = settingsProvider.shuffleOrderNavigation;
|
||||
final loopQueue = settingsProvider.shuffleLoopQueue;
|
||||
|
||||
if (shuffleOrderNavigation) {
|
||||
// Use shuffled order for next/previous
|
||||
next = playbackState.getNextEpisode(
|
||||
widget.metadata.ratingKey,
|
||||
loopQueue: loopQueue,
|
||||
);
|
||||
previous = playbackState.getPreviousEpisode(widget.metadata.ratingKey);
|
||||
} else {
|
||||
// Use chronological order even in shuffle mode
|
||||
next = await client.findAdjacentEpisode(widget.metadata, 1);
|
||||
previous = await client.findAdjacentEpisode(widget.metadata, -1);
|
||||
}
|
||||
} else {
|
||||
// Use normal sequential episode loading
|
||||
next = await client.findAdjacentEpisode(widget.metadata, 1);
|
||||
@@ -273,7 +307,63 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
);
|
||||
|
||||
if (videoUrl != null) {
|
||||
// Open video without auto-playing
|
||||
// Fetch media info to check for external subtitle tracks
|
||||
final mediaInfo = await client.getMediaInfo(
|
||||
widget.metadata.ratingKey,
|
||||
mediaIndex: widget.selectedMediaIndex,
|
||||
);
|
||||
|
||||
// Build list of external subtitle tracks for media_kit
|
||||
final externalSubtitles = <SubtitleTrack>[];
|
||||
if (mediaInfo != null) {
|
||||
final externalTracks = mediaInfo.subtitleTracks
|
||||
.where((track) => track.isExternal)
|
||||
.toList();
|
||||
|
||||
if (externalTracks.isNotEmpty) {
|
||||
appLogger.d(
|
||||
'Found ${externalTracks.length} external subtitle track(s)',
|
||||
);
|
||||
}
|
||||
|
||||
for (final plexTrack in externalTracks) {
|
||||
try {
|
||||
// Skip if no auth token is available
|
||||
final token = client.config.token;
|
||||
if (token == null) {
|
||||
appLogger.w('No auth token available for external subtitles');
|
||||
continue;
|
||||
}
|
||||
|
||||
final url = plexTrack.getSubtitleUrl(
|
||||
client.config.baseUrl,
|
||||
token,
|
||||
);
|
||||
|
||||
// Skip if URL couldn't be constructed
|
||||
if (url == null) continue;
|
||||
|
||||
externalSubtitles.add(
|
||||
SubtitleTrack.uri(
|
||||
url,
|
||||
title:
|
||||
plexTrack.displayTitle ??
|
||||
plexTrack.language ??
|
||||
'Track ${plexTrack.id}',
|
||||
language: plexTrack.languageCode,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
// Silent fallback - log error but continue with other subtitles
|
||||
appLogger.w(
|
||||
'Failed to add external subtitle track ${plexTrack.id}',
|
||||
error: e,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Open video (without external subtitles in Media constructor)
|
||||
await player!.open(Media(videoUrl), play: false);
|
||||
|
||||
// Wait for media to be ready (duration > 0)
|
||||
@@ -283,6 +373,33 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
attempts++;
|
||||
}
|
||||
|
||||
// Add external subtitle tracks without auto-selecting them
|
||||
if (externalSubtitles.isNotEmpty) {
|
||||
appLogger.d(
|
||||
'Adding ${externalSubtitles.length} external subtitle(s) to player',
|
||||
);
|
||||
|
||||
final nativePlayer = player!.platform as dynamic;
|
||||
|
||||
for (final subtitleTrack in externalSubtitles) {
|
||||
try {
|
||||
// Use mpv's sub-add with 'auto' flag to avoid auto-selection
|
||||
await nativePlayer.command([
|
||||
'sub-add',
|
||||
subtitleTrack.id,
|
||||
'auto',
|
||||
subtitleTrack.title ?? 'external',
|
||||
subtitleTrack.language ?? 'auto',
|
||||
]);
|
||||
} catch (e) {
|
||||
appLogger.w(
|
||||
'Failed to add external subtitle: ${subtitleTrack.title}',
|
||||
error: e,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set up playback position if resuming
|
||||
if (widget.metadata.viewOffset != null &&
|
||||
widget.metadata.viewOffset! > 0) {
|
||||
@@ -336,21 +453,13 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
setState(() {
|
||||
_boxFitMode = (_boxFitMode + 1) % 3;
|
||||
});
|
||||
final modes = [
|
||||
'contain (letterbox)',
|
||||
'cover (fill screen)',
|
||||
'fill (stretch)',
|
||||
];
|
||||
appLogger.d('BoxFit mode: ${modes[_boxFitMode]}');
|
||||
}
|
||||
|
||||
/// Toggle between contain and cover modes only (for pinch gesture)
|
||||
void _toggleContainCover() {
|
||||
setState(() {
|
||||
_boxFitMode = _boxFitMode == 0 ? 1 : 0; // Toggle between 0 and 1
|
||||
_boxFitMode = _boxFitMode == 0 ? 1 : 0;
|
||||
});
|
||||
final modes = ['contain (letterbox)', 'cover (fill screen)'];
|
||||
appLogger.d('BoxFit mode toggled: ${modes[_boxFitMode]}');
|
||||
}
|
||||
|
||||
/// Get current BoxFit based on mode
|
||||
@@ -377,6 +486,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
_completedSubscription?.cancel();
|
||||
_logSubscription?.cancel();
|
||||
_errorSubscription?.cancel();
|
||||
_positionSubscription?.cancel();
|
||||
_mediaControlSubscription?.cancel();
|
||||
|
||||
// Clear OS media controls completely
|
||||
OsMediaControls.clear();
|
||||
|
||||
// Send final stopped state
|
||||
_sendProgress('stopped');
|
||||
@@ -970,6 +1084,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
void _onPlayingStateChanged(bool isPlaying) {
|
||||
// Send timeline update when playback state changes
|
||||
_sendProgress(isPlaying ? 'playing' : 'paused');
|
||||
|
||||
// Update OS media controls playback state
|
||||
_updateMediaControlsPlaybackState();
|
||||
}
|
||||
|
||||
void _sendProgress(String state) {
|
||||
@@ -1032,6 +1149,129 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> {
|
||||
appLogger.e('[MPV ERROR] $error');
|
||||
}
|
||||
|
||||
// OS Media Controls Integration
|
||||
|
||||
void _initializeMediaControls() async {
|
||||
// Listen to media control events
|
||||
_mediaControlSubscription = OsMediaControls.controlEvents.listen((event) {
|
||||
if (event is PlayEvent) {
|
||||
player?.play();
|
||||
} else if (event is PauseEvent) {
|
||||
player?.pause();
|
||||
} else if (event is SeekEvent) {
|
||||
player?.seek(event.position);
|
||||
} else if (event is NextTrackEvent) {
|
||||
if (_nextEpisode != null) {
|
||||
_playNext();
|
||||
}
|
||||
} else if (event is PreviousTrackEvent) {
|
||||
if (_previousEpisode != null) {
|
||||
_playPrevious();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Enable/disable next/previous track controls based on content type
|
||||
final isEpisode = widget.metadata.type.toLowerCase() == 'episode';
|
||||
if (isEpisode) {
|
||||
// Enable next/previous track controls for episodes
|
||||
await OsMediaControls.enableControls([
|
||||
MediaControl.next,
|
||||
MediaControl.previous,
|
||||
]);
|
||||
} else {
|
||||
// Disable next/previous track controls for movies
|
||||
await OsMediaControls.disableControls([
|
||||
MediaControl.next,
|
||||
MediaControl.previous,
|
||||
]);
|
||||
}
|
||||
|
||||
// Set initial metadata
|
||||
await _updateMediaMetadata();
|
||||
}
|
||||
|
||||
Future<void> _updateMediaMetadata() async {
|
||||
if (!mounted) {
|
||||
appLogger.w('Cannot update media metadata: widget not mounted');
|
||||
return;
|
||||
}
|
||||
|
||||
final metadata = widget.metadata;
|
||||
final clientProvider = context.plexClient;
|
||||
final client = clientProvider.client;
|
||||
|
||||
// Get artwork URL
|
||||
String? artworkUrl;
|
||||
if (client == null) {
|
||||
appLogger.w('Cannot get artwork URL for media controls: Plex client is null');
|
||||
} else {
|
||||
final thumbUrl = metadata.type.toLowerCase() == 'episode'
|
||||
? metadata.grandparentThumb ?? metadata.thumb
|
||||
: metadata.thumb;
|
||||
|
||||
if (thumbUrl != null) {
|
||||
try {
|
||||
artworkUrl = client.getThumbnailUrl(thumbUrl);
|
||||
appLogger.d('Artwork URL for media controls: $artworkUrl');
|
||||
} catch (e) {
|
||||
appLogger.w('Failed to get artwork URL for media controls', error: e);
|
||||
}
|
||||
} else {
|
||||
appLogger.d('No thumbnail URL available for media controls');
|
||||
}
|
||||
}
|
||||
|
||||
// Build title/artist based on content type
|
||||
String title = metadata.title;
|
||||
String? artist;
|
||||
String? album;
|
||||
|
||||
if (metadata.type.toLowerCase() == 'episode') {
|
||||
title = metadata.title;
|
||||
artist = metadata.grandparentTitle; // Show name
|
||||
if (metadata.parentIndex != null) {
|
||||
album = 'Season ${metadata.parentIndex}';
|
||||
}
|
||||
}
|
||||
|
||||
await OsMediaControls.setMetadata(MediaMetadata(
|
||||
title: title,
|
||||
artist: artist,
|
||||
album: album,
|
||||
duration: metadata.duration != null
|
||||
? Duration(milliseconds: metadata.duration!)
|
||||
: null,
|
||||
artworkUrl: artworkUrl,
|
||||
));
|
||||
|
||||
// Set initial playback state
|
||||
_updateMediaControlsPlaybackState();
|
||||
}
|
||||
|
||||
void _updateMediaControlsPlaybackState() {
|
||||
if (player == null) return;
|
||||
|
||||
OsMediaControls.setPlaybackState(MediaPlaybackState(
|
||||
state: player!.state.playing ? PlaybackState.playing : PlaybackState.paused,
|
||||
position: player!.state.position,
|
||||
speed: player!.state.rate,
|
||||
));
|
||||
}
|
||||
|
||||
void _updateMediaControlsPosition() {
|
||||
if (player == null) return;
|
||||
|
||||
// Only update if playing to avoid excessive updates
|
||||
if (player!.state.playing) {
|
||||
OsMediaControls.setPlaybackState(MediaPlaybackState(
|
||||
state: PlaybackState.playing,
|
||||
position: player!.state.position,
|
||||
speed: player!.state.rate,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _playNext() async {
|
||||
if (_nextEpisode == null || _isLoadingNext) return;
|
||||
|
||||
|
||||
@@ -250,9 +250,18 @@ class PlexServer {
|
||||
|
||||
factory PlexServer.fromJson(Map<String, dynamic> json) {
|
||||
final List<dynamic> connectionsJson = json['connections'] as List<dynamic>;
|
||||
final connections = connectionsJson
|
||||
.map((c) => PlexConnection.fromJson(c as Map<String, dynamic>))
|
||||
.toList();
|
||||
final connections = <PlexConnection>[];
|
||||
|
||||
// Parse connections and generate HTTP fallbacks for HTTPS connections
|
||||
for (final c in connectionsJson) {
|
||||
final connection = PlexConnection.fromJson(c as Map<String, dynamic>);
|
||||
connections.add(connection);
|
||||
|
||||
// Generate HTTP fallback for HTTPS connections
|
||||
if (connection.protocol == 'https') {
|
||||
connections.add(connection.toHttpFallback());
|
||||
}
|
||||
}
|
||||
|
||||
DateTime? lastSeenAt;
|
||||
if (json['lastSeenAt'] != null) {
|
||||
@@ -317,18 +326,33 @@ class PlexServer {
|
||||
/// Returns a Stream that emits connections progressively:
|
||||
/// 1. First emission: The first connection that responds successfully
|
||||
/// 2. Second emission (optional): The best connection after latency testing
|
||||
/// Priority: local > remote > relay (from successful connections)
|
||||
/// Priority: local > remote > relay, then HTTPS > HTTP, then lowest latency
|
||||
/// Tests both plex.direct URI and direct IP for each connection
|
||||
/// HTTPS connections are tested first, with HTTP as fallback
|
||||
Stream<PlexConnection> findBestWorkingConnection() async* {
|
||||
if (connections.isEmpty) return;
|
||||
|
||||
// Create candidates: test both uri and directUrl for each connection
|
||||
final candidates = <_ConnectionCandidate>[];
|
||||
// Separate HTTPS and HTTP candidates to prioritize HTTPS first
|
||||
final httpsCandidates = <_ConnectionCandidate>[];
|
||||
final httpCandidates = <_ConnectionCandidate>[];
|
||||
|
||||
for (final connection in connections) {
|
||||
candidates.add(_ConnectionCandidate(connection, connection.uri, true));
|
||||
candidates.add(_ConnectionCandidate(connection, connection.directUrl, false));
|
||||
final uriCandidate = _ConnectionCandidate(connection, connection.uri, true);
|
||||
final directCandidate = _ConnectionCandidate(connection, connection.directUrl, false);
|
||||
|
||||
if (connection.protocol == 'https') {
|
||||
httpsCandidates.add(uriCandidate);
|
||||
httpsCandidates.add(directCandidate);
|
||||
} else {
|
||||
httpCandidates.add(uriCandidate);
|
||||
httpCandidates.add(directCandidate);
|
||||
}
|
||||
}
|
||||
|
||||
// Combine candidates with HTTPS first, then HTTP
|
||||
final candidates = [...httpsCandidates, ...httpCandidates];
|
||||
|
||||
// Phase 1: Race to find first working connection
|
||||
final completer = Completer<_ConnectionCandidate?>();
|
||||
_ConnectionCandidate? firstCandidate;
|
||||
@@ -444,18 +468,24 @@ class PlexServer {
|
||||
_findLowestLatencyCandidate(relayCandidates);
|
||||
}
|
||||
|
||||
/// Find the candidate with lowest latency, preferring plex.direct URI on tie
|
||||
/// Find the candidate with lowest latency, preferring HTTPS and plex.direct URI on tie
|
||||
_ConnectionCandidate? _findLowestLatencyCandidate(
|
||||
List<MapEntry<_ConnectionCandidate, ConnectionTestResult>> entries,
|
||||
) {
|
||||
if (entries.isEmpty) return null;
|
||||
|
||||
// Sort by latency first, then by URL type (prefer plex.direct)
|
||||
// Sort by latency first, then by protocol (HTTPS > HTTP), then by URL type (prefer plex.direct)
|
||||
entries.sort((a, b) {
|
||||
final latencyCompare = a.value.latencyMs.compareTo(b.value.latencyMs);
|
||||
if (latencyCompare != 0) return latencyCompare;
|
||||
|
||||
// If latencies are equal, prefer plex.direct URI (isPlexDirectUri = true)
|
||||
// If latencies are equal, prefer HTTPS over HTTP
|
||||
final aIsHttps = a.key.connection.protocol == 'https';
|
||||
final bIsHttps = b.key.connection.protocol == 'https';
|
||||
if (aIsHttps && !bIsHttps) return -1;
|
||||
if (!aIsHttps && bIsHttps) return 1;
|
||||
|
||||
// If latencies and protocols are equal, prefer plex.direct URI (isPlexDirectUri = true)
|
||||
if (a.key.isPlexDirectUri && !b.key.isPlexDirectUri) return -1;
|
||||
if (!a.key.isPlexDirectUri && b.key.isPlexDirectUri) return 1;
|
||||
return 0;
|
||||
@@ -518,4 +548,20 @@ class PlexConnection {
|
||||
if (local) return 'Local';
|
||||
return 'Remote';
|
||||
}
|
||||
|
||||
/// Create an HTTP fallback version of this HTTPS connection
|
||||
/// This allows testing HTTP when HTTPS is unavailable (e.g., certificate issues)
|
||||
PlexConnection toHttpFallback() {
|
||||
assert(protocol == 'https', 'Can only create HTTP fallback for HTTPS connections');
|
||||
|
||||
return PlexConnection(
|
||||
protocol: 'http',
|
||||
address: address,
|
||||
port: port,
|
||||
uri: uri.replaceFirst('https://', 'http://'),
|
||||
local: local,
|
||||
relay: relay,
|
||||
ipv6: ipv6,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ class SettingsService {
|
||||
static const String _keySubtitleBorderColor = 'subtitle_border_color';
|
||||
static const String _keySubtitleBackgroundColor = 'subtitle_background_color';
|
||||
static const String _keySubtitleBackgroundOpacity = 'subtitle_background_opacity';
|
||||
static const String _keyShuffleUnwatchedOnly = 'shuffle_unwatched_only';
|
||||
static const String _keyShuffleOrderNavigation = 'shuffle_order_navigation';
|
||||
static const String _keyShuffleLoopQueue = 'shuffle_loop_queue';
|
||||
|
||||
static SettingsService? _instance;
|
||||
late SharedPreferences _prefs;
|
||||
@@ -777,6 +780,35 @@ class SettingsService {
|
||||
}
|
||||
}
|
||||
|
||||
// Shuffle Play Settings
|
||||
|
||||
/// Shuffle Unwatched Only - Filter shuffle queue to unwatched episodes only
|
||||
Future<void> setShuffleUnwatchedOnly(bool enabled) async {
|
||||
await _prefs.setBool(_keyShuffleUnwatchedOnly, enabled);
|
||||
}
|
||||
|
||||
bool getShuffleUnwatchedOnly() {
|
||||
return _prefs.getBool(_keyShuffleUnwatchedOnly) ?? true; // Default: true
|
||||
}
|
||||
|
||||
/// Shuffle Order Navigation - Next/previous buttons follow shuffled order
|
||||
Future<void> setShuffleOrderNavigation(bool enabled) async {
|
||||
await _prefs.setBool(_keyShuffleOrderNavigation, enabled);
|
||||
}
|
||||
|
||||
bool getShuffleOrderNavigation() {
|
||||
return _prefs.getBool(_keyShuffleOrderNavigation) ?? true; // Default: true
|
||||
}
|
||||
|
||||
/// Shuffle Loop Queue - Restart queue when reaching the end
|
||||
Future<void> setShuffleLoopQueue(bool enabled) async {
|
||||
await _prefs.setBool(_keyShuffleLoopQueue, enabled);
|
||||
}
|
||||
|
||||
bool getShuffleLoopQueue() {
|
||||
return _prefs.getBool(_keyShuffleLoopQueue) ?? false; // Default: false
|
||||
}
|
||||
|
||||
// Reset all settings to defaults
|
||||
Future<void> resetAllSettings() async {
|
||||
await Future.wait([
|
||||
@@ -805,6 +837,9 @@ class SettingsService {
|
||||
_prefs.remove(_keySubtitleBorderColor),
|
||||
_prefs.remove(_keySubtitleBackgroundColor),
|
||||
_prefs.remove(_keySubtitleBackgroundOpacity),
|
||||
_prefs.remove(_keyShuffleUnwatchedOnly),
|
||||
_prefs.remove(_keyShuffleOrderNavigation),
|
||||
_prefs.remove(_keyShuffleLoopQueue),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/plex_metadata.dart';
|
||||
import '../providers/playback_state_provider.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../utils/video_player_navigation.dart';
|
||||
|
||||
/// Handle shuffle play action for shows and seasons
|
||||
///
|
||||
/// Fetches all unwatched episodes, shuffles them, and starts playback
|
||||
/// from the first shuffled episode. The shuffle queue is stored in the
|
||||
/// PlaybackStateProvider for continuous shuffle playback.
|
||||
/// Fetches episodes based on user settings (unwatched only or including watched),
|
||||
/// shuffles them, and starts playback from the first shuffled episode.
|
||||
/// The shuffle queue is stored in the PlaybackStateProvider for continuous shuffle playback.
|
||||
Future<void> handleShufflePlay(
|
||||
BuildContext context,
|
||||
PlexMetadata metadata,
|
||||
@@ -18,8 +19,12 @@ Future<void> handleShufflePlay(
|
||||
if (client == null) return;
|
||||
|
||||
final playbackState = context.read<PlaybackStateProvider>();
|
||||
final settingsProvider = context.read<SettingsProvider>();
|
||||
final itemType = metadata.type.toLowerCase();
|
||||
|
||||
// Get shuffle setting
|
||||
final unwatchedOnly = settingsProvider.shuffleUnwatchedOnly;
|
||||
|
||||
try {
|
||||
// Show loading indicator
|
||||
if (context.mounted) {
|
||||
@@ -31,17 +36,44 @@ Future<void> handleShufflePlay(
|
||||
);
|
||||
}
|
||||
|
||||
// Get unwatched episodes based on type
|
||||
// Get episodes based on type and settings
|
||||
List<PlexMetadata> episodes;
|
||||
if (itemType == 'show') {
|
||||
episodes = await client.getAllUnwatchedEpisodes(
|
||||
metadata.ratingKey,
|
||||
);
|
||||
if (unwatchedOnly) {
|
||||
// Get only unwatched episodes
|
||||
episodes = await client.getAllUnwatchedEpisodes(
|
||||
metadata.ratingKey,
|
||||
);
|
||||
} else {
|
||||
// Get all episodes from all seasons
|
||||
final allEpisodes = <PlexMetadata>[];
|
||||
final seasons = await client.getChildren(metadata.ratingKey);
|
||||
|
||||
for (final season in seasons) {
|
||||
if (season.type == 'season') {
|
||||
final seasonEpisodes = await client.getChildren(season.ratingKey);
|
||||
final episodesOnly = seasonEpisodes
|
||||
.where((ep) => ep.type == 'episode')
|
||||
.toList();
|
||||
allEpisodes.addAll(episodesOnly);
|
||||
}
|
||||
}
|
||||
episodes = allEpisodes;
|
||||
}
|
||||
} else {
|
||||
// season
|
||||
episodes = await client.getUnwatchedEpisodesInSeason(
|
||||
metadata.ratingKey,
|
||||
);
|
||||
if (unwatchedOnly) {
|
||||
// Get only unwatched episodes
|
||||
episodes = await client.getUnwatchedEpisodesInSeason(
|
||||
metadata.ratingKey,
|
||||
);
|
||||
} else {
|
||||
// Get all episodes in season
|
||||
final seasonEpisodes = await client.getChildren(metadata.ratingKey);
|
||||
episodes = seasonEpisodes
|
||||
.where((ep) => ep.type == 'episode')
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
// Close loading indicator
|
||||
@@ -52,7 +84,7 @@ Future<void> handleShufflePlay(
|
||||
if (episodes.isEmpty) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('No unwatched episodes found')),
|
||||
const SnackBar(content: Text('No episodes found')),
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -40,7 +40,7 @@ class VideoControlButton extends StatelessWidget {
|
||||
icon: Icon(icon, color: effectiveColor),
|
||||
onPressed: onPressed,
|
||||
tooltip: tooltip,
|
||||
constraints: const BoxConstraints(minWidth: 40, minHeight: 56),
|
||||
constraints: const BoxConstraints(minWidth: 40, minHeight: 40),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
double _doubleTapFeedbackOpacity = 0.0;
|
||||
bool _lastDoubleTapWasForward = true;
|
||||
Timer? _feedbackTimer;
|
||||
// Seek throttle state
|
||||
Timer? _seekThrottleTimer;
|
||||
Duration? _pendingSeekPosition;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -168,6 +171,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
void dispose() {
|
||||
_hideTimer?.cancel();
|
||||
_feedbackTimer?.cancel();
|
||||
_seekThrottleTimer?.cancel();
|
||||
_focusNode.dispose();
|
||||
// Remove lifecycle observer
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
@@ -358,11 +362,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
|
||||
// Only apply SafeArea in portrait mode
|
||||
if (isPortrait) {
|
||||
return SafeArea(
|
||||
top: top,
|
||||
bottom: bottom,
|
||||
child: child,
|
||||
);
|
||||
return SafeArea(top: top, bottom: bottom, child: child);
|
||||
}
|
||||
|
||||
// In landscape, return child without SafeArea
|
||||
@@ -380,83 +380,90 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Unified settings button (speed, sleep timer, audio sync, subtitle sync)
|
||||
ListenableBuilder(
|
||||
listenable: SleepTimerService(),
|
||||
builder: (context, _) {
|
||||
final sleepTimer = SleepTimerService();
|
||||
final isActive =
|
||||
sleepTimer.isActive ||
|
||||
_audioSyncOffset != 0 ||
|
||||
_subtitleSyncOffset != 0;
|
||||
return VideoControlButton(
|
||||
icon: Icons.tune,
|
||||
isActive: isActive,
|
||||
onPressed: () async {
|
||||
await VideoSettingsSheet.show(
|
||||
context,
|
||||
widget.player,
|
||||
_audioSyncOffset,
|
||||
_subtitleSyncOffset,
|
||||
);
|
||||
// Sheet is now closed, reload immediately
|
||||
if (mounted) {
|
||||
await _loadSeekTimes();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (_hasMultipleAudioTracks(tracks))
|
||||
VideoControlButton(
|
||||
icon: Icons.audiotrack,
|
||||
onPressed: () => AudioTrackSheet.show(context, widget.player),
|
||||
// Unified settings button (speed, sleep timer, audio sync, subtitle sync)
|
||||
ListenableBuilder(
|
||||
listenable: SleepTimerService(),
|
||||
builder: (context, _) {
|
||||
final sleepTimer = SleepTimerService();
|
||||
final isActive =
|
||||
sleepTimer.isActive ||
|
||||
_audioSyncOffset != 0 ||
|
||||
_subtitleSyncOffset != 0;
|
||||
return VideoControlButton(
|
||||
icon: Icons.tune,
|
||||
isActive: isActive,
|
||||
onPressed: () async {
|
||||
await VideoSettingsSheet.show(
|
||||
context,
|
||||
widget.player,
|
||||
_audioSyncOffset,
|
||||
_subtitleSyncOffset,
|
||||
);
|
||||
// Sheet is now closed, reload immediately
|
||||
if (mounted) {
|
||||
await _loadSeekTimes();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (_hasSubtitles(tracks))
|
||||
VideoControlButton(
|
||||
icon: Icons.subtitles,
|
||||
onPressed: () => SubtitleTrackSheet.show(context, widget.player),
|
||||
),
|
||||
if (_chapters.isNotEmpty)
|
||||
VideoControlButton(
|
||||
icon: Icons.video_library,
|
||||
onPressed: () => ChapterSheet.show(
|
||||
context,
|
||||
widget.player,
|
||||
_chapters,
|
||||
_chaptersLoaded,
|
||||
if (_hasMultipleAudioTracks(tracks))
|
||||
VideoControlButton(
|
||||
icon: Icons.audiotrack,
|
||||
onPressed: () => AudioTrackSheet.show(context, widget.player),
|
||||
),
|
||||
),
|
||||
if (widget.availableVersions.length > 1)
|
||||
VideoControlButton(
|
||||
icon: Icons.video_file,
|
||||
onPressed: () => VersionSheet.show(
|
||||
context,
|
||||
widget.availableVersions,
|
||||
widget.selectedMediaIndex,
|
||||
_switchMediaVersion,
|
||||
if (_hasSubtitles(tracks))
|
||||
VideoControlButton(
|
||||
icon: Icons.subtitles,
|
||||
onPressed: () =>
|
||||
SubtitleTrackSheet.show(context, widget.player),
|
||||
),
|
||||
if (_chapters.isNotEmpty)
|
||||
VideoControlButton(
|
||||
icon: Icons.video_library,
|
||||
onPressed: () => ChapterSheet.show(
|
||||
context,
|
||||
widget.player,
|
||||
_chapters,
|
||||
_chaptersLoaded,
|
||||
),
|
||||
),
|
||||
if (widget.availableVersions.length > 1)
|
||||
VideoControlButton(
|
||||
icon: Icons.video_file,
|
||||
onPressed: () => VersionSheet.show(
|
||||
context,
|
||||
widget.availableVersions,
|
||||
widget.selectedMediaIndex,
|
||||
_switchMediaVersion,
|
||||
),
|
||||
),
|
||||
// BoxFit mode cycle button
|
||||
if (widget.onCycleBoxFitMode != null)
|
||||
VideoControlButton(
|
||||
icon: _getBoxFitIcon(widget.boxFitMode),
|
||||
tooltip: _getBoxFitTooltip(widget.boxFitMode),
|
||||
onPressed: widget.onCycleBoxFitMode,
|
||||
),
|
||||
// Rotation lock toggle (mobile only)
|
||||
if (PlatformDetector.isMobile(context))
|
||||
VideoControlButton(
|
||||
icon: _isRotationLocked
|
||||
? Icons.screen_lock_rotation
|
||||
: Icons.screen_rotation,
|
||||
tooltip: _isRotationLocked
|
||||
? 'Unlock rotation'
|
||||
: 'Lock rotation',
|
||||
onPressed: _toggleRotationLock,
|
||||
),
|
||||
// Fullscreen toggle (desktop only)
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS)
|
||||
VideoControlButton(
|
||||
icon: _isFullscreen
|
||||
? Icons.fullscreen_exit
|
||||
: Icons.fullscreen,
|
||||
onPressed: _toggleFullscreen,
|
||||
),
|
||||
),
|
||||
// BoxFit mode cycle button
|
||||
if (widget.onCycleBoxFitMode != null)
|
||||
VideoControlButton(
|
||||
icon: _getBoxFitIcon(widget.boxFitMode),
|
||||
tooltip: _getBoxFitTooltip(widget.boxFitMode),
|
||||
onPressed: widget.onCycleBoxFitMode,
|
||||
),
|
||||
// Rotation lock toggle (mobile only)
|
||||
if (PlatformDetector.isMobile(context))
|
||||
VideoControlButton(
|
||||
icon: _isRotationLocked ? Icons.screen_lock_rotation : Icons.screen_rotation,
|
||||
tooltip: _isRotationLocked ? 'Unlock rotation' : 'Lock rotation',
|
||||
onPressed: _toggleRotationLock,
|
||||
),
|
||||
// Fullscreen toggle (desktop only)
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS)
|
||||
VideoControlButton(
|
||||
icon: _isFullscreen ? Icons.fullscreen_exit : Icons.fullscreen,
|
||||
onPressed: _toggleFullscreen,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -521,6 +528,40 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
widget.player.seek(clampedPosition);
|
||||
}
|
||||
|
||||
/// Throttled seek for timeline slider - only sends seek events at most every 100ms
|
||||
void _throttledSeek(Duration position) {
|
||||
// Store the pending position
|
||||
_pendingSeekPosition = position;
|
||||
|
||||
// If timer is already active, just update the pending position
|
||||
if (_seekThrottleTimer?.isActive ?? false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute the seek immediately for the first call
|
||||
widget.player.seek(position);
|
||||
|
||||
// Start a timer to throttle subsequent seeks
|
||||
_seekThrottleTimer = Timer(const Duration(milliseconds: 200), () {
|
||||
// If there's a pending position that's different, execute it
|
||||
if (_pendingSeekPosition != null && _pendingSeekPosition != position) {
|
||||
widget.player.seek(_pendingSeekPosition!);
|
||||
}
|
||||
_pendingSeekPosition = null;
|
||||
});
|
||||
}
|
||||
|
||||
/// Finalizes the seek when user stops scrubbing the timeline
|
||||
void _finalizeSeek(Duration position) {
|
||||
// Cancel any pending throttled seek
|
||||
_seekThrottleTimer?.cancel();
|
||||
_seekThrottleTimer = null;
|
||||
|
||||
// Execute the final position immediately to ensure accuracy
|
||||
widget.player.seek(position);
|
||||
_pendingSeekPosition = null;
|
||||
}
|
||||
|
||||
/// Get the replay icon based on the duration
|
||||
/// Returns numbered icons (replay_5, replay_10, replay_30) when available,
|
||||
/// otherwise returns generic replay icon
|
||||
@@ -878,7 +919,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
widget.metadata.index != null)
|
||||
Text(
|
||||
'S${widget.metadata.parentIndex} · E${widget.metadata.index} · ${widget.metadata.title}',
|
||||
style: const TextStyle(color: Colors.white70, fontSize: 14),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
@@ -1310,7 +1354,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
min: 0.0,
|
||||
max: duration.inMilliseconds.toDouble(),
|
||||
onChanged: (value) {
|
||||
widget.player.seek(Duration(milliseconds: value.toInt()));
|
||||
_throttledSeek(Duration(milliseconds: value.toInt()));
|
||||
},
|
||||
onChangeEnd: (value) {
|
||||
_finalizeSeek(Duration(milliseconds: value.toInt()));
|
||||
},
|
||||
activeColor: Colors.white,
|
||||
inactiveColor: Colors.white.withValues(alpha: 0.3),
|
||||
@@ -1407,7 +1454,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
final currentPosition = widget.player.state.position;
|
||||
|
||||
// Get state reference before async operations
|
||||
final videoPlayerState = context.findAncestorStateOfType<VideoPlayerScreenState>();
|
||||
final videoPlayerState = context
|
||||
.findAncestorStateOfType<VideoPlayerScreenState>();
|
||||
|
||||
// Save the preference
|
||||
final settingsService = await SettingsService.getInstance();
|
||||
|
||||
@@ -9,6 +9,7 @@ import hotkey_manager_macos
|
||||
import macos_window_utils
|
||||
import media_kit_libs_macos_video
|
||||
import media_kit_video
|
||||
import os_media_controls
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import screen_retriever_macos
|
||||
@@ -24,6 +25,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
|
||||
MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin"))
|
||||
MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin"))
|
||||
OsMediaControlsPlugin.register(with: registry.registrar(forPlugin: "OsMediaControlsPlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
|
||||
@@ -10,6 +10,8 @@ PODS:
|
||||
- FlutterMacOS
|
||||
- media_kit_video (0.0.1):
|
||||
- FlutterMacOS
|
||||
- os_media_controls (0.0.1):
|
||||
- FlutterMacOS
|
||||
- package_info_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- path_provider_foundation (0.0.1):
|
||||
@@ -38,6 +40,7 @@ DEPENDENCIES:
|
||||
- macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`)
|
||||
- media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`)
|
||||
- media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`)
|
||||
- os_media_controls (from `Flutter/ephemeral/.symlinks/plugins/os_media_controls/macos`)
|
||||
- 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`)
|
||||
@@ -63,6 +66,8 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos
|
||||
media_kit_video:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos
|
||||
os_media_controls:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/os_media_controls/macos
|
||||
package_info_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
|
||||
path_provider_foundation:
|
||||
@@ -89,10 +94,11 @@ SPEC CHECKSUMS:
|
||||
macos_window_utils: 23f54331a0fd51eea9e0ed347253bf48fd379d1d
|
||||
media_kit_libs_macos_video: 85a23e549b5f480e72cae3e5634b5514bc692f65
|
||||
media_kit_video: fa6564e3799a0a28bff39442334817088b7ca758
|
||||
os_media_controls: c07c04c4afdf59dda0a3f398457a46823c4ce0ed
|
||||
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
|
||||
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
|
||||
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
|
||||
screen_retriever_macos: 452e51764a9e1cdb74b3c541238795849f21557f
|
||||
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
|
||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
|
||||
url_launcher_macos: f87a979182d112f911de6820aefddaf56ee9fbfd
|
||||
volume_controller: 5c068e6d085c80dadd33fc2c918d2114b775b3dd
|
||||
|
||||
@@ -5,18 +5,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: f0bb5d1648339c8308cc0b9838d8456b3cfe5c91f9dc1a735b4d003269e5da9a
|
||||
sha256: c209688d9f5a5f26b2fb47a188131a6fb9e876ae9e47af3737c0b4f58a93470d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "88.0.0"
|
||||
version: "91.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: "0b7b9c329d2879f8f05d6c05b32ee9ec025f39b077864bdb5ac9a7b63418a98f"
|
||||
sha256: f51c8499b35f9b26820cfe914828a6a98a94efd5cc78b37bb7d03debae3a1d08
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.1.1"
|
||||
version: "8.4.1"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -69,18 +69,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build_daemon
|
||||
sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa"
|
||||
sha256: "409002f1adeea601018715d613115cfaf0e31f512cb80ae4534c79867ae2363d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.4"
|
||||
version: "4.1.0"
|
||||
build_runner:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: build_runner
|
||||
sha256: "4e54dbeefdc70691ba80b3bce3976af63b5425c8c07dface348dfee664a0edc1"
|
||||
sha256: a9461b8e586bf018dd4afd2e13b49b08c6a844a4b226c8d1d10f3a723cdd78c3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.9.0"
|
||||
version: "2.10.1"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -181,10 +181,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.6"
|
||||
version: "3.0.7"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -492,59 +492,65 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: media_kit
|
||||
ref: custom-mpv-config
|
||||
resolved-ref: fd7bd79a9ba691306038c61791ea5754a5287d8a
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.2.1"
|
||||
media_kit_libs_android_video:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_android_video
|
||||
sha256: "3f6274e5ab2de512c286a25c327288601ee445ed8ac319e0ef0b66148bd8f76c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.8"
|
||||
path: "libs/android/media_kit_libs_android_video"
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.3.9"
|
||||
media_kit_libs_ios_video:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_ios_video
|
||||
sha256: b5382994eb37a4564c368386c154ad70ba0cc78dacdd3fb0cd9f30db6d837991
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/ios/media_kit_libs_ios_video"
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.1.4"
|
||||
media_kit_libs_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_linux
|
||||
sha256: "2b473399a49ec94452c4d4ae51cfc0f6585074398d74216092bf3d54aac37ecf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/linux/media_kit_libs_linux"
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.2.1"
|
||||
media_kit_libs_macos_video:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_macos_video
|
||||
sha256: f26aa1452b665df288e360393758f84b911f70ffb3878032e1aabba23aa1032d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.4"
|
||||
path: "libs/macos/media_kit_libs_macos_video"
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.1.5"
|
||||
media_kit_libs_video:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: media_kit_libs_video
|
||||
sha256: "2b235b5dac79c6020e01eef5022c6cc85fedc0df1738aadc6ea489daa12a92a9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/universal/media_kit_libs_video"
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.0.7"
|
||||
media_kit_libs_windows_video:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_windows_video
|
||||
sha256: dff76da2778729ab650229e6b4ec6ec111eb5151431002cbd7ea304ff1f112ab
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.11"
|
||||
path: "libs/windows/media_kit_libs_windows_video"
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
resolved-ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
url: "https://github.com/edde746/media-kit"
|
||||
source: git
|
||||
version: "1.0.12"
|
||||
media_kit_video:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -585,6 +591,15 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
os_media_controls:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: ae75b6f514c6ca81499c6b25db2164d99d7473b1
|
||||
resolved-ref: ae75b6f514c6ca81499c6b25db2164d99d7473b1
|
||||
url: "https://github.com/edde746/os-media-controls"
|
||||
source: git
|
||||
version: "0.0.2"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -637,10 +652,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd"
|
||||
sha256: efaec349ddfc181528345c56f8eda9d6cccd71c177511b132c6a0ddaefaa2738
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
version: "2.4.3"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -729,14 +744,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: qr
|
||||
sha256: "5a1d2586170e172b8a8c8470bbbffd5eb0cd38a66c0d77155ea138d3af3a4445"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
qr_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: qr_flutter
|
||||
sha256: "5095f0fc6e3f71d08adef8feccc8cea4f12eec18a2e31c2e8d82cb6019f4b097"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rxdart
|
||||
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
|
||||
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.28.0"
|
||||
version: "0.27.7"
|
||||
safe_local_storage:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -813,18 +844,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: bd14436108211b0d4ee5038689a56d4ae3620fd72fd6036e113bf1345bc74d9e
|
||||
sha256: "34266009473bf71d748912da4bf62d439185226c03e01e2d9687bc65bbfcb713"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.13"
|
||||
version: "2.4.15"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_foundation
|
||||
sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
|
||||
sha256: "1c33a907142607c40a7542768ec9badfd16293bac51da3a4482623d15845f88b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.4"
|
||||
version: "2.5.5"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -902,14 +933,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.1"
|
||||
sprintf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sprintf
|
||||
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
sqflite:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1106,10 +1129,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: uuid
|
||||
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
|
||||
sha256: a11b666489b1954e01d992f3d601b1804a33937b5a8fe677bd26b8a9f96f96e8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.5.1"
|
||||
version: "4.5.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1122,10 +1145,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
|
||||
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "15.0.0"
|
||||
version: "15.0.2"
|
||||
volume_controller:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1223,5 +1246,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.9.0 <4.0.0"
|
||||
dart: ">=3.9.2 <4.0.0"
|
||||
flutter: ">=3.35.0"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: plezy
|
||||
description: "A beautiful Plex client for Flutter"
|
||||
publish_to: "none"
|
||||
version: 1.5.0+12
|
||||
version: 1.6.1+15
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
@@ -25,13 +25,23 @@ dependencies:
|
||||
provider: ^6.1.2
|
||||
hotkey_manager: ^0.2.3
|
||||
flex_color_picker: ^3.6.0
|
||||
qr_flutter: ^4.1.0
|
||||
os_media_controls:
|
||||
git:
|
||||
url: https://github.com/edde746/os-media-controls
|
||||
ref: ae75b6f514c6ca81499c6b25db2164d99d7473b1
|
||||
|
||||
dependency_overrides:
|
||||
media_kit:
|
||||
git:
|
||||
url: https://github.com/edde746/media-kit
|
||||
ref: custom-mpv-config
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
path: media_kit
|
||||
media_kit_libs_video:
|
||||
git:
|
||||
url: https://github.com/edde746/media-kit
|
||||
ref: b6de7e44148043bd26f2569e8062dc8bce4f11b9
|
||||
path: libs/universal/media_kit_libs_video
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Android Icon Generator Script
|
||||
# Generates notification icons and monochrome launcher icons from SVG source
|
||||
# Usage: ./generate_android_icons.sh
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
SVG_SOURCE="assets/plezy.svg"
|
||||
ANDROID_RES="android/app/src/main/res"
|
||||
TEMP_DIR="/tmp/android_icons_$$"
|
||||
|
||||
# Check if source SVG exists
|
||||
if [ ! -f "$SVG_SOURCE" ]; then
|
||||
echo "Error: $SVG_SOURCE not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for required tools
|
||||
if ! command -v rsvg-convert &> /dev/null; then
|
||||
echo "Error: rsvg-convert not found. Install with: brew install librsvg"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v magick &> /dev/null && ! command -v convert &> /dev/null; then
|
||||
echo "Error: ImageMagick not found. Install with: brew install imagemagick"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temp directory
|
||||
mkdir -p "$TEMP_DIR"
|
||||
|
||||
echo "🎨 Generating Android icons from $SVG_SOURCE..."
|
||||
|
||||
# Function to generate white silhouette icon
|
||||
generate_white_icon() {
|
||||
local size=$1
|
||||
local output=$2
|
||||
|
||||
# Get SVG dimensions to detect if it's non-square
|
||||
local svg_viewbox=$(grep -o 'viewBox="[^"]*"' "$SVG_SOURCE" | sed 's/viewBox="//;s/"//')
|
||||
local svg_width=$(echo "$svg_viewbox" | awk '{print $3}')
|
||||
local svg_height=$(echo "$svg_viewbox" | awk '{print $4}')
|
||||
|
||||
# Convert SVG to PNG, preserving aspect ratio
|
||||
if (( $(echo "$svg_width != $svg_height" | bc -l) )); then
|
||||
# Non-square SVG: render at size and add padding to center it
|
||||
rsvg-convert --keep-aspect-ratio --background-color=transparent "$SVG_SOURCE" -o "$TEMP_DIR/temp_unpadded.png"
|
||||
|
||||
# Center the image in a square canvas with transparent padding
|
||||
magick "$TEMP_DIR/temp_unpadded.png" \
|
||||
-resize "${size}x${size}" \
|
||||
-gravity center \
|
||||
-background transparent \
|
||||
-extent "${size}x${size}" \
|
||||
"$TEMP_DIR/temp.png"
|
||||
else
|
||||
# Square SVG: convert directly
|
||||
rsvg-convert -w "$size" -h "$size" --background-color=transparent "$SVG_SOURCE" -o "$TEMP_DIR/temp.png"
|
||||
fi
|
||||
|
||||
# Convert to white silhouette: extract alpha, fill with white, apply alpha
|
||||
magick "$TEMP_DIR/temp.png" \
|
||||
-alpha extract \
|
||||
"$TEMP_DIR/alpha_mask.png"
|
||||
|
||||
magick -size "${size}x${size}" xc:white \
|
||||
"$TEMP_DIR/alpha_mask.png" \
|
||||
-alpha off \
|
||||
-compose copy-opacity \
|
||||
-composite \
|
||||
-define png:color-type=6 \
|
||||
"$output"
|
||||
|
||||
echo " ✓ Generated $(basename $output) (${size}x${size}px)"
|
||||
}
|
||||
|
||||
# Generate Notification Icons (24dp base)
|
||||
echo ""
|
||||
echo "📱 Generating notification icons (ic_stat_notification.png)..."
|
||||
|
||||
# Notification icon densities: 24dp base
|
||||
# mdpi=1x, hdpi=1.5x, xhdpi=2x, xxhdpi=3x, xxxhdpi=4x
|
||||
declare -A NOTIF_SIZES=(
|
||||
["mdpi"]=24
|
||||
["hdpi"]=36
|
||||
["xhdpi"]=48
|
||||
["xxhdpi"]=72
|
||||
["xxxhdpi"]=96
|
||||
)
|
||||
|
||||
for density in "${!NOTIF_SIZES[@]}"; do
|
||||
size=${NOTIF_SIZES[$density]}
|
||||
output_dir="$ANDROID_RES/drawable-$density"
|
||||
mkdir -p "$output_dir"
|
||||
generate_white_icon "$size" "$output_dir/ic_stat_notification.png"
|
||||
done
|
||||
|
||||
# Generate Monochrome Launcher Icons (108dp base)
|
||||
echo ""
|
||||
echo "🚀 Generating monochrome launcher icons (ic_launcher_monochrome.png)..."
|
||||
|
||||
# Monochrome launcher icon densities: 108dp base
|
||||
# mdpi=1x, hdpi=1.5x, xhdpi=2x, xxhdpi=3x, xxxhdpi=4x
|
||||
declare -A MONO_SIZES=(
|
||||
["mdpi"]=108
|
||||
["hdpi"]=162
|
||||
["xhdpi"]=216
|
||||
["xxhdpi"]=324
|
||||
["xxxhdpi"]=432
|
||||
)
|
||||
|
||||
for density in "${!MONO_SIZES[@]}"; do
|
||||
size=${MONO_SIZES[$density]}
|
||||
output_dir="$ANDROID_RES/mipmap-$density"
|
||||
mkdir -p "$output_dir"
|
||||
generate_white_icon "$size" "$output_dir/ic_launcher_monochrome.png"
|
||||
done
|
||||
|
||||
# Clean up
|
||||
rm -rf "$TEMP_DIR"
|
||||
|
||||
echo ""
|
||||
echo "✅ All icons generated successfully!"
|
||||
echo ""
|
||||
echo "Icon locations:"
|
||||
echo " • Notification icons: $ANDROID_RES/drawable-*/ic_stat_notification.png"
|
||||
echo " • Monochrome icons: $ANDROID_RES/mipmap-*/ic_launcher_monochrome.png"
|
||||
echo ""
|
||||
echo "To apply changes, rebuild the app: flutter clean && flutter build apk"
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <hotkey_manager_windows/hotkey_manager_windows_plugin_c_api.h>
|
||||
#include <media_kit_libs_windows_video/media_kit_libs_windows_video_plugin_c_api.h>
|
||||
#include <media_kit_video/media_kit_video_plugin_c_api.h>
|
||||
#include <os_media_controls/os_media_controls_plugin.h>
|
||||
#include <screen_retriever_windows/screen_retriever_windows_plugin_c_api.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <volume_controller/volume_controller_plugin_c_api.h>
|
||||
@@ -21,6 +22,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("MediaKitLibsWindowsVideoPluginCApi"));
|
||||
MediaKitVideoPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi"));
|
||||
OsMediaControlsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("OsMediaControlsPlugin"));
|
||||
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
|
||||
@@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
hotkey_manager_windows
|
||||
media_kit_libs_windows_video
|
||||
media_kit_video
|
||||
os_media_controls
|
||||
screen_retriever_windows
|
||||
url_launcher_windows
|
||||
volume_controller
|
||||
|
||||