How anegrin/debutante works
Project Type and Purpose
• This is a native Android application (Java) built around ExoPlayer for audio playback.
• It supports both local files and remote Subsonic-compliant servers, Bluetooth AVRCP/A2DP, Android Auto, and Google Cast.
File Structure
• Module “app/”: contains all source code, resources, assets, schemas, and Gradle configs.
• src/main/java/io/github/debutante:
– Activities & Fragments (UI layer)
– adapter/, helper/, listeners/, layout/: support classes for UI binding and event handling
– model/api/: data models matching Subsonic API
– persistence/: Room database (AppDatabase), DAO interfaces, entity classes
– receivers/: BroadcastReceivers for Bluetooth, media controls, account sync, etc.
– service/: long-running components (MediaService, HTTPDService, SyncService, JobServices)
• Resources: layouts, drawables, menus, navigation graphs, preferences, themes.
• Assets: open_source_licenses.json
• Tests: unit and instrumentation tests under src/test, src/androidTest.
Extract Insights from the README
• Core features: playback (ExoPlayer), library browsing (by artist/album), remote streaming via Subsonic API, Bluetooth & cast integration.
• No external support server code—assumes an existing Subsonic server (e.g., Navidrome).
Main Components
A. UI Layer
• Activities: MainActivity, AccountActivity, OSSActivity, PreferencesActivity
• Fragments: BrowsingFragment, PlayerFragment, PlaylistFragment, etc.
• Navigation Graphs (browsing_nav.xml, player_nav.xml)
B. ViewModel/Controller (Model layer)
• BrowseMediaViewModel, PlayMediaViewModel
C. Data Layer
• Remote Data Source: SubsonicHelper + GsonRequest (HTTP client)
• Local Data Source: Room database (AppDatabase) + EntityRepository + DAOs
D. Services & Background Components
• MediaService/PlayerService: ExoPlayer wrapper managing playback, MediaSession
• HTTPDService: local HTTP server to serve remote/local streams
• SyncService/SyncJobService/WatchdogJobService/InitService/MediaDownloadService: account syncing, pre-download, background initialization
E. External Integrations
• Subsonic-compliant API Server (remote)
• Bluetooth Stack (A2DP/AVRCP): A2DPReceiver, CastSessionAvailabilityListener
• Android Auto (via car_app_desc XML)
• Google Cast (DefaultCastOptionsProvider, CastPlayerListener)
F. Core Playback Engine
• ExoPlayer components wrapped by PlayerPreparer, PlayerWrapper
• DynamicSizeCacheEvictor for caching
• MediaSessionNotificationListener for notification controls
Relationships & Data Flows
• UI → ViewModel: user actions (play, browse)
• ViewModel → Repository: fetch library data
• Repository → Remote/Local Data Source: HTTP calls or DB queries
• Repository → ViewModel → UI: LiveData (or callbacks) update UI
• UI → MediaService: bind & send playback commands
• MediaService ↔ ExoPlayer: control playback, emit state changes
• Services/BroadcastReceivers ↔ UI: notify about playback state, Bluetooth events
• HTTPDService ↔ ExoPlayer: serve streams to external cast devices
Architectural Patterns & Principles
• MVVM-style separation (Activity/Fragment ↔ ViewModel ↔ Repository).
• Repository pattern abstracting Room and network.
• Observer pattern via LiveData or custom Rx wrappers (RxHelper).
• Single Responsibility: distinct packages for adapters, helpers, listeners.
• Android Foreground Service for playback to ensure persistence.