spotube/lib/services/audio_player
S.B cee65b5f2f
Update audio_player.dart
Key Improvements:

    SpotubeMediaFactory: Handles the logic of creating SpotubeMedia instances, allowing for easier scalability and reducing repetitive code.

    Dependency Injection (DI): CustomPlayer is injected into the AudioPlayerInterface, improving testability and modularity.

    Helper Methods: Functions like getNetworkAddress() and getUriForTrack() simplify and centralize repeated logic, improving maintainability.

    Playback Control Methods: Added play(), pause(), stop(), and seek() methods for better playback control with error handling.

    PlaybackStateManager: Manages the state-related properties (isPlaying, duration, etc.), keeping the AudioPlayerInterface cleaner and more focused on playback control.

Advantages:

    Separation of Concerns: The code is now better structured with clear separation between media management (SpotubeMedia), playback state management (PlaybackStateManager), and playback controls (AudioPlayerInterface).

    Extensibility: The code is more scalable with the factory pattern, making it easy to add new track types or other media sources.

    Testability: With dependency injection, you can easily mock the CustomPlayer and test the logic of AudioPlayerInterface independently.

    Clean Code: Centralized logic and helper methods reduce code duplication, improving readability and maintainability.
2024-10-19 14:48:18 +02:00
..
audio_player_impl.dart chore: create new audio player centric playback notifier with drift persistence 2024-06-23 12:23:28 +06:00
audio_player.dart Update audio_player.dart 2024-10-19 14:48:18 +02:00
audio_players_streams_mixin.dart chore: update translations and refactor to flutter 3.22 ThemeData 2024-08-10 22:54:25 +06:00
custom_player.dart refactor: remove catcher_2 and use custom zoned based error handling 2024-06-09 22:52:34 +06:00
playback_state.dart feat: show loading when track metadata is being fetched, android, ios, macos enable shuffling 2023-05-27 13:34:25 +06:00