Skip to content

Conversation

@timusus
Copy link
Owner

@timusus timusus commented Nov 16, 2025

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:

  1. 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
  2. Added PlaybackInfo data classes for each provider:

    • Jellyfin/Emby: PlaybackStartInfo, PlaybackProgressInfo, PlaybackStopInfo
    • Plex: Uses query parameters with PlaybackState enum
  3. Updated DI modules to provide PlaybackReportingService instances:

    • JellyfinMediaProviderModule
    • EmbyMediaProviderModule
    • PlexMediaProviderModule
  4. 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)
  5. 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

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:

1. 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

2. Added PlaybackInfo data classes for each provider:
   - Jellyfin/Emby: PlaybackStartInfo, PlaybackProgressInfo, PlaybackStopInfo
   - Plex: Uses query parameters with PlaybackState enum

3. Updated DI modules to provide PlaybackReportingService instances:
   - JellyfinMediaProviderModule
   - EmbyMediaProviderModule
   - PlexMediaProviderModule

4. 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)

5. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jellyfin Playback reporting

3 participants