Commit Graph

794 Commits

Author SHA1 Message Date
Arkadiusz Fal
8c5c503df2 Fix iPad iOS 18 keyboard dismissal issue in search
Removed auto-focus logic that was causing keyboard show/hide loop
on iPad with docked keyboard. The keyboard was repeatedly dismissing
immediately after appearing due to interaction between keyboard
notifications, focus state changes, and view updates.

Changes:
- Removed focused state and keyboard observer from SearchModel
- Removed iOS textField reference (kept macOS only)
- Removed auto-focus logic from FocusableSearchTextField on iOS
- Cleaned up unused focus-related code

The search field now works reliably when tapped manually on iPad.
Auto-focus still works on macOS where it doesn't cause issues.
2025-11-20 17:49:10 +01:00
Arkadiusz Fal
36738572da Fix SwiftFormat and SwiftLint issues
- Fix indentation in AppSidebarNavigation, VideoCell
- Replace && with comma in PlayerModel condition
- Add SwiftLint suppression for necessary tvOS 17.0 availability check
- Update SwiftLint config to use renamed rules and disable false positives
2025-11-20 17:05:22 +01:00
Arkadiusz Fal
bb2bd86c07 Add feature flag to disable hide shorts functionality
The hide shorts feature is no longer working due to API changes that prevent reliable detection of short videos. This commit introduces a feature flag system to disable the functionality while preserving the ability to easily restore it if the API issue is resolved.

Changes:
- Add FeatureFlags.swift with hideShortsEnabled flag (currently disabled)
- Hide all HideShortsButtons UI elements when flag is disabled
- Disable shorts filtering logic in ContentItemView, FavoriteItemView, and FeedModel
- Preserve hideShorts user preference for future restoration
2025-11-20 13:05:12 +01:00
Arkadiusz Fal
c1b23d20f2 Fix tab selection timing to wait for account sign-in
Tab selection was being set immediately during app configuration, before
the user account had completed sign-in. This caused tabs that require
authentication (like Subscriptions and Playlists) to not be properly
selected on startup since they weren't visible yet.

Changes:
- Add notification system for account configuration completion
- Post notification after all account types finish configuration:
  * Accounts with existing tokens
  * Accounts requiring sign-in (after network request completes)
  * Anonymous/public accounts
  * Error cases (missing credentials, network failures)
- Set up observer before account configuration to ensure notification
  is received
- Set tab selection only when account is fully configured
2025-11-19 23:24:21 +01:00
Arkadiusz Fal
a55adb2e65 Fix thumbnail loading for video details
Explicitly specify thumbnail quality order instead of using Thumbnail.Quality.allCases to ensure proper thumbnail URL generation and loading priority.
2025-11-19 22:05:55 +01:00
Arkadiusz Fal
cea296c4b7 Fix audio session interrupting other apps on launch
Previously, the audio session was initialized immediately when the app launched, causing audio from other apps (like Music) to stop even when no video was playing in Yattee.

Changes:
- Remove audio session initialization from AppDelegate launch
- Remove audio session setup from MPVClient initialization
- Update setAudioSessionActive() to configure audio session category before activation

The audio session is now lazily initialized only when playback actually starts:
- For MPV backend: triggered by FILE_LOADED, PLAYBACK_RESTART, AUDIO_RECONFIG events
- For AVPlayer backend: triggered when play() is called

This allows music from other apps to continue playing until a video is actually played in Yattee.
2025-11-19 21:45:56 +01:00
Arkadiusz Fal
33377f7e0e Fix nil crash when accessing stream.format
This commit addresses crashes caused by accessing nil format values on streams:

- QualityProfile.swift: Add guard check for stream.format to prevent nil access crash
- MPVBackend.swift: Add nil check in canPlay method before comparing format
- PlayerStreams.swift: Add nil check before comparing format in asset processing

The crashes occurred when stream.format was nil and accessed as an implicitly unwrapped optional, causing "Unexpectedly found nil while implicitly unwrapping an Optional value" errors.
2025-11-19 18:03:43 +01:00
Arkadiusz Fal
4b577a296b Fix array index out of bounds crash in audio track handling
This commit addresses crashes caused by race conditions when accessing audio track arrays:

- MPVBackend.swift: Use safe index clamping to prevent array out of bounds crashes when selecting audio tracks
- PlayerModel.swift: Add selectedAudioTrack computed property for thread-safe audio track access
- ControlsOverlay.swift: Use safe accessor with "Original" fallback label
- PlaybackSettings.swift: Use safe accessor with "Original" fallback label

This fix resolves approximately 37% of crashes (23 out of 62 crash logs) that were caused by index out of range errors in MPVBackend.playStream at line 345.
2025-11-19 18:01:02 +01:00
Arkadiusz Fal
45f72ce4a1 Fix playing videos from channel view in modal opened in video player
Handle case where player is already presenting by using delayed dispatch instead of appending to onPresentPlayer callback queue.
2025-11-19 01:32:09 +01:00
Arkadiusz Fal
a5275fd800 Remove verbose logging statements
Removed logging for audio session activation and partial update operations to reduce log noise.
2025-11-18 18:19:45 +01:00
Arkadiusz Fal
49278e13cd Fix audio track label showing "Original" instead of "Unknown"
Changed the default audio track content type from "Unknown" to "Original"
when the content type is not specified. This provides a more accurate
description for the default audio track.
2025-11-18 18:16:38 +01:00
Arkadiusz Fal
4c5b801c45 Fix Now Playing controls when switching between MPV and AVPlayer backends
When switching from AVPlayer to MPV backend, Now Playing controls (play/pause/seek) were disabled because AVPlayer maintained control of the remote command center and audio session. This fix ensures MPV can properly reclaim control.

Key changes:
- Clear AVPlayer's current item when switching to MPV to release media control
- Clear Now Playing info and set playback state to stopped before MPV takes over
- Reset remote command center by removing all targets (including AVPlayer's internal handlers) and re-adding custom handlers
- Force audio session deactivation/reactivation with .notifyOthersOnDeactivation
- Add forceReactivate parameter to setupAudioSessionForNowPlaying() for backend switches
- Ensure stream loading continues after Now Playing setup (don't return early)

The fix properly handles the transition by:
1. Clearing AVPlayer's media session completely
2. Scheduling async Now Playing setup without blocking stream loading
3. Resetting remote command handlers to reclaim control from AVPlayer
4. Re-activating audio session to establish MPV as the active player
2025-11-18 16:43:17 +01:00
Arkadiusz Fal
e6b6778ba1 Fix iOS Now Playing integration for MPV backend
The MPV backend now properly displays Now Playing information in iOS Control Center. The fix addresses the issue where the AVAudioSession would become inactive during MPV's playback lifecycle.

Key changes:
- Added setupAudioSessionForNowPlaying() method to activate AVAudioSession with proper playback category and movie playback mode
- Re-activate audio session at critical MPV events: FILE_LOADED, PLAYBACK_RESTART, AUDIO_RECONFIG, and during periodic updates
- Initialize audio session immediately after mpv_initialize() in MPVClient

The audio session must be re-activated at multiple points during playback, not just at initialization, to ensure iOS recognizes the app as playing media.
2025-11-18 16:20:30 +01:00
Arkadiusz Fal
5758417293 Fix SwiftLint and SwiftFormat violations
- Run SwiftFormat to fix indentation, spacing, and formatting issues
- Replace CGFloat with Double and NSRect with CGRect per style guide
- Remove redundant .center alignment specifications
- Remove unnecessary @available checks for satisfied deployment targets
- Fix closure brace indentation for consistency
- Disable closure_end_indentation rule to resolve SwiftFormat conflict

All linting checks now pass with zero errors and warnings.
2025-11-15 19:42:37 +01:00
Arkadiusz Fal
8b889da2ef Add retry mechanism for AVPlayer file load errors
Implemented automatic retry logic with exponential backoff (2, 4, 6 seconds) when file loading fails in AVPlayerBackend. Retries up to 3 times before showing error to user. Retry state is properly reset on successful loads. This matches the retry implementation added to MPVBackend in commit b6df73f9.
2025-11-15 19:33:01 +01:00
Arkadiusz Fal
98bdd5d6a5 Fix iOS Now Playing Info Center integration for AVPlayer backend
This commit enables proper Now Playing Info Center integration on iOS, allowing video playback information to appear in Control Center and Lock Screen with working remote controls.

Key changes:
- Activate audio session on app launch with setCategory(.playback, mode: .moviePlayback) and setActive(true)
- Set up remote commands on first play() call instead of during app initialization to avoid claiming Now Playing slot prematurely
- Remove removeTarget(nil) calls that were claiming Now Playing without content
- Enable remote commands (play, pause, toggle, seek) explicitly and add proper target handlers
- Use backend.isPlaying instead of PlayerModel.isPlaying to avoid race conditions
- Include playback rate (1.0 for playing, 0.0 for paused) in Now Playing info
- Update Now Playing info on main queue for thread safety
- Update Now Playing when switching between backends
- Remove audio session deactivation from pause() and stop() methods

Note: This fix works for AVPlayer backend. MPV backend has fundamental incompatibility with iOS Now Playing system.
2025-11-15 15:44:05 +01:00
Arkadiusz Fal
a464b15e29 Fix MPV player vertical positioning in fullscreen mode
Remove incorrect safe area insets from offsetY calculation that was
causing unequal black bars (smaller top, larger bottom). Now properly
centers video with equal padding like AVPlayer backend.
2025-11-15 11:29:58 +01:00
Arkadiusz Fal
fcb97a5591 Remove verbose logging from MPV rendering
Removed debug log statements for screen refresh rate and successful render context calls to reduce log noise.
2025-11-14 20:51:05 +01:00
Arkadiusz Fal
b88169c7dd Improve video layer rendering on macOS
Refactored glUpdate to use requestRedraw method for better control. Added needsRedraw flag to prevent redundant display calls. Enabled asynchronous drawing on VideoLayer for improved performance. Modified displayLinkCallback to only report swap without triggering display to avoid flooding the main thread.
2025-11-14 20:24:33 +01:00
Arkadiusz Fal
ddf997ee58 Simplify stream description by removing instance info
Removed instance description from stream description string to simplify the display and avoid showing redundant backend information.
2025-11-14 20:10:13 +01:00
Arkadiusz Fal
9d8fb0cfa2 Add nil safety check for currentTime in MPVBackend
Added guard check to return early if currentTime is nil in getTimeUpdates. Simplified optional unwrapping by using the guarded currentTime value throughout the method.
2025-11-14 20:04:54 +01:00
Arkadiusz Fal
6511d4c9ba Add nil safety checks for stream resolution handling
Added comprehensive nil checks for stream resolution values across PlayerBackend, QualityProfile, and PlayerQueue to prevent crashes when streams have missing resolution metadata. Also added backend nil checks in PlayerQueue.
2025-11-14 18:58:27 +01:00
Arkadiusz Fal
b6df73f949 Add retry mechanism for MPV file load errors
Implemented automatic retry logic with exponential backoff (2, 4, 6 seconds) when file loading fails in MPVBackend. Retries up to 3 times before showing error to user. Retry state is properly reset on successful loads.
2025-11-14 18:58:27 +01:00
Arkadiusz Fal
11a2ef207c Remove debug print statement from thumbnail URL handling
Cleaned up debug logging that was printing final thumbnail URLs in InvidiousAPI.
2025-11-14 18:58:12 +01:00
Arkadiusz Fal
be4e1adb9b Fix all SwiftLint violations across codebase
Resolves 130+ violations including deployment target checks, code style issues, and formatting inconsistencies. Adds SwiftLint disable comments for compiler-required availability checks while maintaining deployment target compliance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:35 +01:00
Arkadiusz Fal
8123770614 Improve fullscreen orientation handling for iOS player
Refactor orientation logic when entering fullscreen to better handle
button-initiated vs gesture-initiated transitions:

- Consolidate orientation determination into a single expression that
  considers whether fullscreen was initiated by button or gesture
- When initiated by button, always use rotateToLandscapeOnEnterFullScreen
  preference
- When initiated by gesture, respect current device orientation if already
  in landscape, otherwise use preference
- Apply .landscape lock only for button-initiated transitions, .all for
  gesture-initiated (when not orientation locked)

This provides more intuitive behavior where button taps rotate to preferred
orientation, while gestures respect current device orientation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:35 +01:00
Arkadiusz Fal
62d5a86146 Add debug logging for stream URLs in PlayerBackend
Add logging for video and audio asset URLs during stream filtering to help debug stream selection issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:34 +01:00
Arkadiusz Fal
86e843305f Improve MPV backend audio track handling
Add proper validation and fallback logic for audio track selection in MPV backend:
- Validate audio track index is within bounds before switching
- Handle streams without separate audio tracks (single asset streams)
- Reset selectedAudioTrackIndex if out of bounds
- Add fallback path for streams without audioTracks array

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:34 +01:00
Arkadiusz Fal
5b18c3c114 Add multi-track audio support for Piped backend
Extract and provide all available audio tracks (ORIGINAL, DUBBED, etc.) from Piped API instead of only using the first ORIGINAL track. This allows users to select between different audio languages and track types.

Changes:
- Extract all M4A audio tracks grouped by type and language
- Keep highest bitrate stream for each unique track combination
- Sort tracks with ORIGINAL first, then others alphabetically
- Pass audio tracks array to Stream for player selection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:34 +01:00
Arkadiusz Fal
735fc0cb6c Fix published date handling in Piped API
Clear the published string when a proper publishedAt date is extracted from uploadDate to prevent duplicate or inconsistent date display. Only fallback to string-based published date when no structured date is available.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:34 +01:00
Arkadiusz Fal
874b976da9 Fix Invidious companion API endpoint path
Update companion API endpoint URLs to use /companion/latest_version instead of /latest_version to match the correct API path structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:14:34 +01:00
Ivan0xFF
8609ef7709 Added caption support for Piped backend (#867)
Co-authored-by: Ivan <ivanferrari@porch.com>
2025-06-17 16:03:18 +02:00
ned
2461a33feb feat: default lang and mpv audio track switching 2025-06-01 22:19:03 +02:00
Arkadiusz Fal
09c2fb19a9 Fix swiftformat offenses 2025-03-23 13:32:46 +01:00
Jakub Filo
5239b36cfe Add support for invidious companion 2025-03-18 22:56:45 +01:00
piuvas
9efbac3d15 make 0-length videos not shorts. 2024-12-21 12:55:44 -03:00
Arkadiusz Fal
c7e1a50e56 Merge pull request #833 from blennster/main
Fix uneven playback when using MPV and not syncing refreshrate
2024-11-08 15:03:51 +01:00
Arkadiusz Fal
798d2fc67f Merge pull request #817 from yattee/fix-subtitles
improved subtitle handling
2024-11-08 15:01:56 +01:00
Arkadiusz Fal
a5a88f8890 Merge pull request #815 from yattee/refined-audio-ducking
proper audio interrupt and route change handling
2024-11-08 15:01:27 +01:00
Emil Blennow
055d5575ba fix uneven playback when using MPV and not syncing refreshrate 2024-10-06 17:32:02 +02:00
Toni Förster
3339e8cb1f improved subtitle handling
- fix subtitle disabling not working
- make subtitle adding/removing async
- make subtitle menu non blocking

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
2024-09-14 11:33:12 +02:00
Toni Förster
4855f9bead fix tvOS build
Signed-off-by: Toni Förster <toni.foerster@gmail.com>
2024-09-13 11:48:40 +02:00
Toni Förster
a65ed67751 proper audio interrupt and route change handling
- set AVAudioSession inactive on pause and stop
- handle audio route changes
2024-09-13 11:21:07 +02:00
Toni Förster
72dcbe4515 allow user to disable fullscreen swipe gesture
furthermore, some rewording

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
2024-09-12 16:57:48 +02:00
Arkadiusz Fal
6d48a825cd Merge pull request #809 from yattee/refactor-search
refactor Search
2024-09-11 09:29:43 +02:00
Arkadiusz Fal
ed11e593ff Merge pull request #810 from yattee/auto-retry-video-loading
Retry loading video before presenting error
2024-09-11 09:29:28 +02:00
Arkadiusz Fal
102dfba751 Merge pull request #805 from yattee/mpv-better-performance
MPV: improved A/V sync
2024-09-11 09:29:14 +02:00
Arkadiusz Fal
4202b27c03 Merge pull request #807 from yattee/more-robust-resolution-handling
more robust resolution handling
2024-09-11 09:29:00 +02:00
Toni Förster
28a7b6e981 auto retry loading the video before showing error
Signed-off-by: Toni Förster <toni.foerster@gmail.com>
2024-09-10 11:07:20 +02:00
Toni Förster
4663aab3da refactor Search
- have a separate body view for each os
- macOS: set navigation title for search
- macOS: set min width to 835 for main content
- macOS: set main window min height to 600
- macOS: don’t have text behind the cancel button
- split SearchTextField into macOS and iOS/tvOS
- iOS: move search menu to the right
- iOS: unified search field
- make min width a constant
- add option to disable search suggestions

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
2024-09-10 09:38:14 +02:00