mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
88e9ca229e66d4fcccfdfc78677080beec36b461
PlayerManager and MediaRepository
- Introduce `PlayerManager` to encapsulate `Media3` player interactions, state management, and UI updates. - Manages playback state (playing, buffering, ended, error), progress, metadata, track selection, and the media queue. - Exposes state via `StateFlow` for reactive UI updates. - Handles player lifecycle and event listeners. - Create `MediaRepository` to fetch media items and upcoming episodes from the Jellyfin API. - Abstracts away the logic for retrieving media sources, playback URLs, and constructing `MediaItem` objects. - Includes a method to get the next episodes for auto-play, avoiding duplicates already in the queue. - Implement `TrackMapper` to convert Media3 `Tracks` into a `TrackSelectionState` model for the UI. - Refactor `PlayerViewModel` to delegate all player and data-fetching logic to `PlayerManager` and `MediaRepository`. - The ViewModel now observes state flows from the manager and orchestrates UI actions (e.g., auto-hiding controls). - Simplifies the ViewModel by removing direct player listener implementation, progress loops, and track parsing. - Improves error handling for invalid media IDs and data loading issues.
Description
Languages
Kotlin
100%