Shuttle2
Shuttle2 copied to clipboard
Fix playback reporting to media servers
This commit resolves issue #96 by adding playback reporting functionality for remote media servers. The implementation follows the existing architecture patterns and integrates seamlessly with the playback system.
Changes:
-
Created PlaybackReportingService for each provider:
- Jellyfin: POST /Sessions/Playing, /Playing/Progress, /Playing/Stopped
- Emby: Same endpoints as Jellyfin (compatible API)
- Plex: GET /:/timeline for state updates, /:/scrobble for completion
-
Added PlaybackInfo data classes for each provider:
- Jellyfin/Emby: PlaybackStartInfo, PlaybackProgressInfo, PlaybackStopInfo
- Plex: Uses query parameters with PlaybackState enum
-
Updated DI modules to provide PlaybackReportingService instances:
- JellyfinMediaProviderModule
- EmbyMediaProviderModule
- PlexMediaProviderModule
-
Created PlaybackReporter coordinator class:
- Implements PlaybackWatcherCallback to listen for playback events
- Routes reporting to appropriate service based on Song.mediaProvider
- Manages session IDs and progress reporting intervals (10s)
- Handles playback start, progress updates, pause/resume, and stop
- Only reports for remote providers (not local files)
-
Created PlaybackReporterInitializer:
- Registers PlaybackReporter with PlaybackWatcher on app startup
- Integrated via AppModuleBinds using Hilt's multibinding
Architecture:
- Follows Observer pattern (PlaybackWatcherCallback)
- Uses Strategy pattern for provider-specific implementations
- Dependency injection via Hilt for all components
- Coroutine-based async operations
- Proper error handling with Timber logging
Benefits:
- Jellyfin/Emby/Plex servers now receive "now playing" updates
- Server dashboards show active playback sessions
- Playback history is tracked on the server side
- Play counts and progress are synced to servers
- No changes required to existing playback logic
Fixes #96