Compare commits

..
9 Commits
Author SHA1 Message Date
github-actions[bot] 3b15715669 chore: bump version to 1.16.1 2026-02-06 20:48:53 +00:00
edde746 e498cc7912 fix: actor image quality
close #395
2026-02-06 21:48:05 +01:00
edde746 cc8bd55e23 fix: alpha jump bar focus
close #394
2026-02-06 21:41:42 +01:00
edde746 dbcfc25a7c fix(tv): double back from video player 2026-02-06 21:31:24 +01:00
edde746 09337f50ee fix: broken video player focus
close #393
2026-02-06 21:10:31 +01:00
edde746 ff75cf8ddb fix: account for playback speed in "Ends at" calculation
close #392
2026-02-06 19:32:27 +01:00
edde746 44eae4ef84 refactor: extract BaseNotifier and HierarchicalEventMixin 2026-02-06 17:01:56 +01:00
edde746 8eca2051e5 chore: update cask to 1.16.0 2026-02-06 14:14:02 +01:00
edde746 d16dee4dd5 fix: homebrew cask job 2026-02-06 14:11:47 +01:00
18 changed files with 238 additions and 209 deletions
+10 -2
View File
@@ -12,6 +12,9 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0
- name: Download and hash release
id: release
@@ -30,8 +33,13 @@ jobs:
- name: Commit
run: |
BRANCH="${{ github.event.repository.default_branch }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Casks/plezy.rb
git diff --staged --quiet || git commit -m "chore: update cask to ${{ steps.release.outputs.version }}"
git push
if ! git diff --staged --quiet; then
git commit -m "chore: update cask to ${{ steps.release.outputs.version }}"
git push origin "HEAD:$BRANCH"
else
echo "No cask changes to commit."
fi
+2 -2
View File
@@ -1,6 +1,6 @@
cask "plezy" do
version "1.15.0"
sha256 "f6925cdbccd98651ddbbfb059e823e31cef7990e94d753c3b2b501a413404507"
version "1.16.0"
sha256 "65f4d629dd98e90dace71166a279a5b58334182ca7f60f85a79b3a4e2e2f8a02"
url "https://github.com/edde746/plezy/releases/download/#{version}/plezy-macos.dmg"
name "Plezy"
-10
View File
@@ -6,9 +6,6 @@ PODS:
- file_picker (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_webrtc (1.2.0):
- Flutter
- WebRTC-SDK (= 137.7151.04)
- in_app_review (2.0.0):
- Flutter
- os_media_controls (0.0.1):
@@ -55,7 +52,6 @@ PODS:
- Flutter
- wakelock_plus (0.0.1):
- Flutter
- WebRTC-SDK (137.7151.04)
- workmanager_apple (0.0.1):
- Flutter
@@ -64,7 +60,6 @@ DEPENDENCIES:
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`)
- in_app_review (from `.symlinks/plugins/in_app_review/ios`)
- os_media_controls (from `.symlinks/plugins/os_media_controls/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
@@ -80,7 +75,6 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- sqlite3
- WebRTC-SDK
EXTERNAL SOURCES:
connectivity_plus:
@@ -91,8 +85,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/file_picker/ios"
Flutter:
:path: Flutter
flutter_webrtc:
:path: ".symlinks/plugins/flutter_webrtc/ios"
in_app_review:
:path: ".symlinks/plugins/in_app_review/ios"
os_media_controls:
@@ -121,7 +113,6 @@ SPEC CHECKSUMS:
device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
file_picker: 8fc6fe5e42585a217d44d22f79ec046cb8d81140
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_webrtc: c3e21fc0dcd9d8eb246ae4d5256fcbeb2f5ecd22
in_app_review: 7dd1ea365263f834b8464673f9df72c80c17c937
os_media_controls: 86dceab6245a5325af90fc0fdebe243c42d789b4
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
@@ -133,7 +124,6 @@ SPEC CHECKSUMS:
universal_gamepad: e10172778a8a399cce234494968f38724974919e
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556
WebRTC-SDK: 40d4f5ba05cadff14e4db5614aec402a633f007e
workmanager_apple: 904529ae31e97fc5be632cf628507652294a0778
PODFILE CHECKSUM: faeab82d8b6e3c9d039ddf62b7666988a3dea540
@@ -612,6 +612,23 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
}
}
/// Navigate from the alpha jump bar to the nearest visible grid item.
/// After a jump-scroll the previously focused item is off-screen (and its
/// FocusNode detached), so we target the last-column item in the first
/// visible row — the grid cell closest to the alpha bar.
void _navigateToGridNearScroll() {
if (items.isEmpty || _currentColumnCount < 1) return;
final row = _currentFirstVisibleIndex ~/ _currentColumnCount;
final targetIndex = ((row + 1) * _currentColumnCount - 1).clamp(0, items.length - 1);
if (targetIndex == 0) {
firstItemFocusNode.requestFocus();
} else {
getGridItemFocusNode(targetIndex, prefix: 'browse_grid_item').requestFocus();
}
}
/// Navigate focus from grid up to the grouping chip
void _navigateToChips() {
_groupingChipFocusNode.requestFocus();
@@ -848,8 +865,8 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
onJump: _jumpToIndex,
currentFirstVisibleIndex: _currentFirstVisibleIndex,
focusNode: _alphaJumpBarFocusNode,
onNavigateLeft: _navigateToGrid,
onBack: widget.onBack,
onNavigateLeft: _navigateToGridNearScroll,
onBack: _navigateToGridNearScroll,
),
),
],
+9 -29
View File
@@ -1629,35 +1629,15 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
children: [
ClipRRect(
borderRadius: BorderRadius.circular(tokens(context).radiusSm),
child: actor.thumb != null
? CachedNetworkImage(
imageUrl: actor.thumb!,
width: 120,
height: 120,
fit: BoxFit.cover,
placeholder: (context, url) => Container(
width: 120,
height: 120,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
child: const Center(
child: AppIcon(Symbols.person_rounded, fill: 1),
),
),
errorWidget: (context, url, error) => Container(
width: 120,
height: 120,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
child: const Center(
child: AppIcon(Symbols.person_rounded, fill: 1),
),
),
)
: Container(
width: 120,
height: 120,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
child: const Center(child: AppIcon(Symbols.person_rounded, fill: 1)),
),
child: PlexOptimizedImage(
client: _getClientForMetadata(context),
imagePath: actor.thumb,
width: 120,
height: 120,
fit: BoxFit.cover,
imageType: ImageType.avatar,
fallbackIcon: Symbols.person_rounded,
),
),
const SizedBox(height: 8),
SizedBox(
@@ -177,6 +177,19 @@ class _PlaylistDetailScreenState extends BaseMediaListDetailScreen<PlaylistDetai
}
}
/// Get the afterPlaylistItemId for reordering at the given index.
/// Returns null if validation fails, showing an error if [showError] is true.
int? _getAfterPlaylistItemId(int newIndex, {bool showError = true}) {
if (newIndex == 0) return 0;
final afterItem = items[newIndex - 1];
if (afterItem.playlistItemID == null) {
appLogger.e('Cannot reorder: after item missing playlistItemID');
if (showError && mounted) showErrorSnackBar(context, t.playlists.errorReordering);
return null;
}
return afterItem.playlistItemID!;
}
Future<void> _onReorder(int oldIndex, int newIndex) async {
// Adjust newIndex if moving down in the list
if (newIndex > oldIndex) {
@@ -198,22 +211,8 @@ class _PlaylistDetailScreenState extends BaseMediaListDetailScreen<PlaylistDetai
}
// Determine the "after" item ID
// If moving to position 0, afterPlaylistItemId should be 0 (move to top)
// Otherwise, use the playlistItemID of the item before the new position
final int afterPlaylistItemId;
if (newIndex == 0) {
afterPlaylistItemId = 0; // Move to top
} else {
final afterItem = items[newIndex - 1];
if (afterItem.playlistItemID == null) {
appLogger.e('Cannot reorder: after item missing playlistItemID');
if (mounted) {
showErrorSnackBar(context, t.playlists.errorReordering);
}
return;
}
afterPlaylistItemId = afterItem.playlistItemID!;
}
final afterPlaylistItemId = _getAfterPlaylistItemId(newIndex);
if (afterPlaylistItemId == null) return;
appLogger.d('Reordering item from $oldIndex to $newIndex (after ID: $afterPlaylistItemId)');
@@ -255,36 +254,19 @@ class _PlaylistDetailScreenState extends BaseMediaListDetailScreen<PlaylistDetai
appLogger.e('Cannot persist move: item missing playlistItemID');
if (mounted) {
showErrorSnackBar(context, t.playlists.errorReordering);
// Revert the UI change
setState(() {
final item = items.removeAt(newIndex);
items.insert(originalIndex, item);
_focusedIndex = originalIndex;
});
_revertMove(newIndex, originalIndex);
}
return;
}
// Determine the "after" item ID based on where the item is now
final int afterPlaylistItemId;
if (newIndex == 0) {
afterPlaylistItemId = 0; // Move to top
} else {
final afterItem = items[newIndex - 1];
if (afterItem.playlistItemID == null) {
appLogger.e('Cannot persist move: after item missing playlistItemID');
if (mounted) {
showErrorSnackBar(context, t.playlists.errorReordering);
// Revert the UI change
setState(() {
final item = items.removeAt(newIndex);
items.insert(originalIndex, item);
_focusedIndex = originalIndex;
});
}
return;
final afterPlaylistItemId = _getAfterPlaylistItemId(newIndex, showError: false);
if (afterPlaylistItemId == null) {
if (mounted) {
showErrorSnackBar(context, t.playlists.errorReordering);
_revertMove(newIndex, originalIndex);
}
afterPlaylistItemId = afterItem.playlistItemID!;
return;
}
appLogger.d('Persisting move from $originalIndex to $newIndex (after ID: $afterPlaylistItemId)');
@@ -300,16 +282,21 @@ class _PlaylistDetailScreenState extends BaseMediaListDetailScreen<PlaylistDetai
// Revert on failure
appLogger.e('Failed to persist move, reverting UI');
if (mounted) {
setState(() {
final item = items.removeAt(newIndex);
items.insert(originalIndex, item);
_focusedIndex = originalIndex;
});
_revertMove(newIndex, originalIndex);
showErrorSnackBar(context, t.playlists.errorReordering);
}
}
}
/// Revert a move in the UI by moving item from [fromIndex] back to [toIndex].
void _revertMove(int fromIndex, int toIndex) {
setState(() {
final item = items.removeAt(fromIndex);
items.insert(toIndex, item);
_focusedIndex = toIndex;
});
}
Future<void> _removeItem(int index) async {
final item = items[index];
+34 -4
View File
@@ -46,6 +46,7 @@ import '../utils/video_player_navigation.dart';
import '../widgets/video_controls/video_controls.dart';
import '../focus/focusable_wrapper.dart';
import '../focus/input_mode_tracker.dart';
import '../focus/dpad_navigator.dart';
import '../focus/key_event_utils.dart';
import '../i18n/strings.g.dart';
import '../watch_together/providers/watch_together_provider.dart';
@@ -1138,6 +1139,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
}
if (!mounted) return;
_isExiting.value = true;
BackKeyUpSuppressor.suppressBackUntilKeyUp();
Navigator.of(context).pop(true);
}
}
@@ -1158,6 +1160,12 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
// Default behavior for hosts or non-session users
if (!mounted) return;
_isExiting.value = true;
// Suppress stray BACK KeyUp on the previous route: on Android TV the
// system back gesture pops the route around KeyDown, so the KeyUp arrives
// at the previous route and would be misinterpreted as a new BACK press.
// markClosedViaBackKey() (set by handleBackKeyAction for key-triggered
// pops) makes this a no-op, so it only activates for system-back pops.
BackKeyUpSuppressor.suppressBackUntilKeyUp();
Navigator.of(context).pop(true);
} finally {
_isHandlingBack = false;
@@ -1726,7 +1734,27 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
focusNode: _screenFocusNode,
autofocus: isCurrentRoute,
canRequestFocus: isCurrentRoute,
onKeyEvent: (node, event) => isCurrentRoute ? KeyEventResult.handled : KeyEventResult.ignored,
onKeyEvent: (node, event) {
if (!isCurrentRoute) return KeyEventResult.ignored;
// Safety net: if this screen-level node itself has primary focus
// (no descendant focused, e.g. after controls auto-hide), self-heal.
// BACK is excluded: on Android TV the BACK button fires both a key event
// and a system back gesture. Handling it here would double-pop because
// PopScope.onPopInvokedWithResult also processes the system back gesture.
// PopScope handles BACK navigation exclusively.
if (node.hasPrimaryFocus && !event.logicalKey.isBackKey) {
// Redirect focus to the first traversable descendant (video controls)
// and show controls immediately so the first key press isn't swallowed.
if (event.isActionable) {
_controlsVisible.value = true;
final descendants = node.traversalDescendants;
if (descendants.isNotEmpty) {
descendants.first.requestFocus();
}
}
}
return KeyEventResult.handled;
},
child: _isPlayerInitialized && player != null ? _buildVideoPlayer(context) : _buildLoadingSpinner(),
);
}
@@ -1738,10 +1766,12 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
return PopScope(
canPop: false, // Disable swipe-back gesture to prevent interference with timeline scrubbing
onPopInvokedWithResult: (didPop, result) {
if (BackKeyCoordinator.consumeIfHandled()) return;
// Allow programmatic back navigation from UI controls
// Only process system-initiated back gestures (didPop: false).
// Programmatic Navigator.pop() triggers didPop: true — ignore it here
// to avoid consuming the BackKeyCoordinator flag before the system back
// gesture arrives (which would cause a double-pop on Android TV).
if (!didPop) {
// Mark handled to prevent the same BACK press from reaching the next route.
if (BackKeyCoordinator.consumeIfHandled()) return;
BackKeyCoordinator.markHandled();
_handleBackButton();
}
+29
View File
@@ -0,0 +1,29 @@
import 'dart:async';
/// Base class for singleton notifiers with broadcast stream support.
///
/// Provides reusable stream controller management with lazy initialization
/// and automatic recreation if disposed. Subclasses define the event type [T].
abstract class BaseNotifier<T> {
StreamController<T>? _controller;
/// Ensure controller exists (creates if null or closed).
StreamController<T> get _ensureController {
if (_controller == null || _controller!.isClosed) {
_controller = StreamController<T>.broadcast();
}
return _controller!;
}
/// Stream of all events.
Stream<T> get stream => _ensureController.stream;
/// Emit an event to all listeners.
void notify(T event) => _ensureController.add(event);
/// Dispose controller (can be reinitialized later by accessing stream).
void dispose() {
_controller?.close();
_controller = null;
}
}
+11 -35
View File
@@ -1,22 +1,27 @@
import 'dart:async';
import '../models/plex_metadata.dart';
import 'app_logger.dart';
import 'base_notifier.dart';
import 'hierarchical_event_mixin.dart';
/// Event representing a media item deletion with parent chain for hierarchical invalidation
class DeletionEvent {
class DeletionEvent with HierarchicalEventMixin {
/// The ratingKey of the deleted item
@override
final String ratingKey;
/// Composite key: serverId:ratingKey
@override
final String globalKey;
/// Server this item belongs to
@override
final String serverId;
/// Parent chain for hierarchical invalidation
/// For an episode: [seasonRatingKey, showRatingKey]
/// For a season: [showRatingKey]
/// For a movie: []
@override
final List<String> parentChain;
/// Media type of the deleted item
@@ -34,19 +39,6 @@ class DeletionEvent {
this.leafCount = 1,
}) : globalKey = '$serverId:$ratingKey';
/// Check if this event affects a specific item by ratingKey
bool affectsItem(String ratingKey) => this.ratingKey == ratingKey || parentChain.contains(ratingKey);
/// Check if this event affects a specific globalKey
bool affectsGlobalKey(String globalKey) =>
this.globalKey == globalKey || parentChain.any((pk) => '$serverId:$pk' == globalKey);
/// Check if this event affects any item in a collection
bool affectsAnyOf(Iterable<String> ratingKeys) => ratingKeys.any(affectsItem);
/// Check if this event affects any item in a global-key collection
bool affectsAnyGlobalKey(Iterable<String> globalKeys) => globalKeys.any(affectsGlobalKey);
@override
String toString() => 'DeletionEvent(deleted: $globalKey, type: $mediaType, parents: $parentChain)';
}
@@ -55,35 +47,24 @@ class DeletionEvent {
///
/// Singleton pattern following [WatchStateNotifier]. Screens subscribe
/// to receive events when items are deleted from the server.
class DeletionNotifier {
class DeletionNotifier extends BaseNotifier<DeletionEvent> {
static final DeletionNotifier _instance = DeletionNotifier._internal();
factory DeletionNotifier() => _instance;
DeletionNotifier._internal();
StreamController<DeletionEvent>? _controller;
StreamController<DeletionEvent> get _ensureController {
if (_controller == null || _controller!.isClosed) {
_controller = StreamController<DeletionEvent>.broadcast();
}
return _controller!;
}
/// Stream of all deletion events
Stream<DeletionEvent> get stream => _ensureController.stream;
/// Filter for events affecting a specific server
Stream<DeletionEvent> forServer(String serverId) => stream.where((e) => e.serverId == serverId);
/// Filter for events affecting a specific item or its children
Stream<DeletionEvent> forItem(String ratingKey) => stream.where((e) => e.affectsItem(ratingKey));
/// Emit a deletion event
/// Emit a deletion event with logging
@override
void notify(DeletionEvent event) {
appLogger.d('DeletionNotifier: $event');
_ensureController.add(event);
super.notify(event);
}
/// Helper to emit a deletion event from metadata
@@ -110,9 +91,4 @@ class DeletionNotifier {
}
return chain;
}
void dispose() {
_controller?.close();
_controller = null;
}
}
+3 -2
View File
@@ -182,8 +182,9 @@ DurationLocale _getDurationLocale() {
/// Formats the clock time at which media will finish playing, given the remaining duration.
/// Returns a localized time string like "6:12 PM" or "18:12" depending on locale.
String formatFinishTime(Duration remaining) {
final finishTime = DateTime.now().add(remaining);
String formatFinishTime(Duration remaining, {double rate = 1.0}) {
final adjustedRemaining = remaining * (1.0 / rate);
final finishTime = DateTime.now().add(adjustedRemaining);
final formatter = DateFormat.jm(LocaleSettings.currentLocale.languageCode);
return formatter.format(finishTime);
}
+34
View File
@@ -0,0 +1,34 @@
/// Mixin providing hierarchical event matching methods.
///
/// Events that represent changes to media items often need to check if they
/// affect a specific item or any of its parents in the hierarchy. This mixin
/// provides common matching logic for such events.
mixin HierarchicalEventMixin {
/// The ratingKey of the affected item.
String get ratingKey;
/// Composite key: serverId:ratingKey.
String get globalKey;
/// Server this item belongs to.
String get serverId;
/// Parent chain for hierarchical matching.
/// For an episode: [seasonRatingKey, showRatingKey]
/// For a season: [showRatingKey]
/// For a movie: []
List<String> get parentChain;
/// Check if this event affects a specific item by ratingKey.
bool affectsItem(String ratingKey) => this.ratingKey == ratingKey || parentChain.contains(ratingKey);
/// Check if this event affects a specific globalKey.
bool affectsGlobalKey(String globalKey) =>
this.globalKey == globalKey || parentChain.any((pk) => '$serverId:$pk' == globalKey);
/// Check if this event affects any item in a collection.
bool affectsAnyOf(Iterable<String> ratingKeys) => ratingKeys.any(affectsItem);
/// Check if this event affects any item in a global-key collection.
bool affectsAnyGlobalKey(Iterable<String> globalKeys) => globalKeys.any(affectsGlobalKey);
}
+4 -24
View File
@@ -1,4 +1,4 @@
import 'dart:async';
import 'base_notifier.dart';
/// Types of library refresh events
enum LibraryRefreshType { collections, playlists }
@@ -7,27 +7,13 @@ enum LibraryRefreshType { collections, playlists }
///
/// Singleton pattern with reinitializable state. The controller is lazily
/// created and automatically recreated if disposed and later accessed.
class LibraryRefreshNotifier {
class LibraryRefreshNotifier extends BaseNotifier<LibraryRefreshType> {
static final LibraryRefreshNotifier _instance = LibraryRefreshNotifier._internal();
factory LibraryRefreshNotifier() => _instance;
LibraryRefreshNotifier._internal();
/// Unified stream controller (lazily created, reinitializable)
StreamController<LibraryRefreshType>? _controller;
/// Ensure controller exists (creates if null or closed)
StreamController<LibraryRefreshType> get _ensureController {
if (_controller == null || _controller!.isClosed) {
_controller = StreamController<LibraryRefreshType>.broadcast();
}
return _controller!;
}
/// Unified stream of all refresh events
Stream<LibraryRefreshType> get stream => _ensureController.stream;
/// Stream for collections tab (backward compatible)
Stream<void> get collectionsStream => stream.where((t) => t == LibraryRefreshType.collections).map((_) {});
@@ -36,17 +22,11 @@ class LibraryRefreshNotifier {
/// Notify that collections have changed
void notifyCollectionsChanged() {
_ensureController.add(LibraryRefreshType.collections);
notify(LibraryRefreshType.collections);
}
/// Notify that playlists have changed
void notifyPlaylistsChanged() {
_ensureController.add(LibraryRefreshType.playlists);
}
/// Dispose controller (can be reinitialized later by accessing stream)
void dispose() {
_controller?.close();
_controller = null;
notify(LibraryRefreshType.playlists);
}
}
+11 -35
View File
@@ -1,19 +1,23 @@
import 'dart:async';
import '../models/plex_metadata.dart';
import 'app_logger.dart';
import 'base_notifier.dart';
import 'hierarchical_event_mixin.dart';
/// Types of watch state changes
enum WatchStateChangeType { watched, unwatched, progressUpdate }
/// Event representing a watch state change with parent chain for hierarchical invalidation
class WatchStateEvent {
class WatchStateEvent with HierarchicalEventMixin {
/// The item that changed
@override
final String ratingKey;
/// Composite key: serverId:ratingKey
@override
final String globalKey;
/// Server this item belongs to
@override
final String serverId;
/// Type of change
@@ -23,6 +27,7 @@ class WatchStateEvent {
/// For an episode: [seasonRatingKey, showRatingKey]
/// For a season: [showRatingKey]
/// For a movie: []
@override
final List<String> parentChain;
/// Media type that changed
@@ -44,19 +49,6 @@ class WatchStateEvent {
this.isNowWatched,
}) : globalKey = '$serverId:$ratingKey';
/// Check if this event affects a specific item by ratingKey
bool affectsItem(String ratingKey) => this.ratingKey == ratingKey || parentChain.contains(ratingKey);
/// Check if this event affects a specific globalKey
bool affectsGlobalKey(String globalKey) =>
this.globalKey == globalKey || parentChain.any((pk) => '$serverId:$pk' == globalKey);
/// Check if this event affects any item in a collection
bool affectsAnyOf(Iterable<String> ratingKeys) => ratingKeys.any(affectsItem);
/// Check if this event affects any item in a global-key collection
bool affectsAnyGlobalKey(Iterable<String> globalKeys) => globalKeys.any(affectsGlobalKey);
@override
String toString() => 'WatchStateEvent($changeType, $globalKey, parents: $parentChain)';
}
@@ -65,35 +57,24 @@ class WatchStateEvent {
///
/// Singleton pattern following [LibraryRefreshNotifier]. Screens subscribe
/// to receive events when items are marked watched/unwatched or progress updates.
class WatchStateNotifier {
class WatchStateNotifier extends BaseNotifier<WatchStateEvent> {
static final WatchStateNotifier _instance = WatchStateNotifier._internal();
factory WatchStateNotifier() => _instance;
WatchStateNotifier._internal();
StreamController<WatchStateEvent>? _controller;
StreamController<WatchStateEvent> get _ensureController {
if (_controller == null || _controller!.isClosed) {
_controller = StreamController<WatchStateEvent>.broadcast();
}
return _controller!;
}
/// Stream of all watch state events
Stream<WatchStateEvent> get stream => _ensureController.stream;
/// Filter for events affecting a specific server
Stream<WatchStateEvent> forServer(String serverId) => stream.where((e) => e.serverId == serverId);
/// Filter for events affecting a specific item or its children
Stream<WatchStateEvent> forItem(String ratingKey) => stream.where((e) => e.affectsItem(ratingKey));
/// Emit a watch state event
/// Emit a watch state event with logging
@override
void notify(WatchStateEvent event) {
appLogger.d('WatchStateNotifier: $event');
_ensureController.add(event);
super.notify(event);
}
/// Helper to emit a watched/unwatched event from metadata
@@ -139,9 +120,4 @@ class WatchStateNotifier {
}
return chain;
}
void dispose() {
_controller?.close();
_controller = null;
}
}
+2 -6
View File
@@ -75,21 +75,17 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
if (_highlightedIndex > 0) {
setState(() => _highlightedIndex--);
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
}
return KeyEventResult.handled;
}
if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
if (_highlightedIndex < AlphaJumpHelper.allLetters.length - 1) {
setState(() => _highlightedIndex++);
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
}
return KeyEventResult.handled;
}
if (event.logicalKey == LogicalKeyboardKey.select ||
event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.gameButtonA) {
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
return KeyEventResult.handled;
}
if (event.logicalKey == LogicalKeyboardKey.arrowLeft) {
widget.onNavigateLeft?.call();
return KeyEventResult.handled;
@@ -544,16 +544,23 @@ class DesktopVideoControlsState extends State<DesktopVideoControls> {
stream: widget.player.streams.duration,
initialData: widget.player.state.duration,
builder: (context, durSnap) {
final position = posSnap.data ?? Duration.zero;
final duration = durSnap.data ?? Duration.zero;
final remaining = duration - position;
if (remaining.inSeconds <= 0) return const SizedBox.shrink();
return Padding(
padding: const EdgeInsets.only(left: 8),
child: Text(
t.videoControls.endsAt(time: formatFinishTime(remaining)),
style: const TextStyle(color: Colors.white70, fontSize: 13),
),
return StreamBuilder<double>(
stream: widget.player.streams.rate,
initialData: widget.player.state.rate,
builder: (context, rateSnap) {
final position = posSnap.data ?? Duration.zero;
final duration = durSnap.data ?? Duration.zero;
final remaining = duration - position;
final rate = rateSnap.data ?? 1.0;
if (remaining.inSeconds <= 0) return const SizedBox.shrink();
return Padding(
padding: const EdgeInsets.only(left: 8),
child: Text(
t.videoControls.endsAt(time: formatFinishTime(remaining, rate: rate)),
style: const TextStyle(color: Colors.white70, fontSize: 13),
),
);
},
);
},
);
@@ -260,6 +260,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
HardwareKeyboard.instance.addHandler(_handleGlobalKeyEvent);
// Listen for first frame to start auto-hide timer
widget.hasFirstFrame?.addListener(_onFirstFrameReady);
// Listen for external requests to show controls (e.g. screen-level focus recovery)
widget.controlsVisible?.addListener(_onControlsVisibleExternal);
}
/// Called when hasFirstFrame changes - start auto-hide timer when first frame is ready
@@ -269,6 +271,14 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
}
}
/// Called when controlsVisible is set externally (e.g. screen-level focus recovery
/// after controls auto-hide ejects focus on Android TV).
void _onControlsVisibleExternal() {
if (widget.controlsVisible?.value == true && !_showControls && mounted) {
_showControlsWithFocus();
}
}
/// Focus play/pause button if we're in keyboard navigation mode (desktop/TV only)
void _focusPlayPauseIfKeyboardMode() {
if (!mounted) return;
@@ -515,6 +525,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
@override
void dispose() {
HardwareKeyboard.instance.removeHandler(_handleGlobalKeyEvent);
widget.controlsVisible?.removeListener(_onControlsVisibleExternal);
widget.hasFirstFrame?.removeListener(_onFirstFrameReady);
_hideTimer?.cancel();
_feedbackTimer?.cancel();
@@ -111,8 +111,15 @@ class VideoTimelineBar extends StatelessWidget {
if (!showFinishTime || remaining.inSeconds >= 0) {
return _buildTimestamp(remaining);
}
final text = '${formatDurationTimestamp(remaining)} · ${formatFinishTime(remaining.abs())}';
return Text(text, style: const TextStyle(color: Colors.white, fontSize: 14));
return StreamBuilder<double>(
stream: player.streams.rate,
initialData: player.state.rate,
builder: (context, rateSnap) {
final rate = rateSnap.data ?? 1.0;
final text = '${formatDurationTimestamp(remaining)} · ${formatFinishTime(remaining.abs(), rate: rate)}';
return Text(text, style: const TextStyle(color: Colors.white, fontSize: 14));
},
);
}
Widget _buildSlider(Duration position, Duration duration) {
+1 -1
View File
@@ -1,7 +1,7 @@
name: plezy
description: "A beautiful Plex client for Flutter"
publish_to: "none"
version: 1.16.0+36
version: 1.16.1+37
environment:
sdk: ^3.8.1