Documentation
¶
Overview ¶
Package odmobile is the OpenDeezer engine exposed for gomobile (gobind), so a native Android (or iOS) app can drive the same login/decrypt/decode/playback pipeline the desktop GUIs use. Build it with:
gomobile bind -target=android -androidapi 24 -o gui/android/app/libs/odmobile.aar ./mobile
Every browse/list call returns a JSON string (the wire shape the GUIs already use); mutations return bool/string. The caller polls FinishedCount to drive auto-advance, mirroring the C-archive frontends.
Index ¶
- Constants
- func Account() string
- func AddFavorite(id string) bool
- func AddToPlaylist(playlistID, trackID string) bool
- func AdsDisabled() bool
- func AlbumTracks(id string) string
- func ArtistMixJSON(id string) string
- func ArtistProfile(id string) string
- func ArtistTop(id string) string
- func CancelSleepTimer()
- func Charts() string
- func CheckUpdate() string
- func ClearPreload()
- func ConnectDevice(addr string) bool
- func ConnectHostInfo() string
- func ConnectHostSetEnabled(on int)
- func ConnectedDevice() string
- func CreatePlaylist(title string) string
- func CrossfadeMS() int
- func DeletePlaylist(id string) bool
- func DisconnectDevice()
- func DiscoverDevices(timeoutMS int) string
- func DownloadAlbum(id string) string
- func DownloadDir() string
- func DownloadForOffline(id string) string
- func DownloadPlaylist(id string) string
- func DownloadTrack(trackID, destDir string) string
- func DurationMS() int64
- func EQJSON() string
- func FavoriteIDsJSON() string
- func Favorites() string
- func Fetch(url string) []byte
- func FinishedCount() int
- func Flow() string
- func Format() string
- func Gapless() bool
- func GetRepeat() string
- func GetShuffle() bool
- func HistoryRecentJSON(n int) string
- func HistoryStatsJSON(sinceDays int) string
- func Home() string
- func Init(arl string) bool
- func IsPreview() bool
- func LoggedIn() bool
- func LoginErrorKind() int
- func Logout()
- func Lyrics(id string) string
- func MediaCacheMB() int
- func NowPlaying() string
- func Pause()
- func Play(trackID string, durationMS int64) bool
- func PlayEpisode(id string) bool
- func PlayEpisodeMS(id string, durationMS int64) bool
- func PlaylistTracks(id string) string
- func Playlists() string
- func PodcastEpisodes(id string) string
- func PositionMS() int64
- func Preload(id string) error
- func Quality() int
- func QueueIndex() int
- func QueueInsertNext(trackJSON string)
- func QueueJSON() string
- func QueueMove(from, to int)
- func QueueRemove(index int)
- func QueueVersion() int64
- func RemoveFavorite(id string) bool
- func RemoveFromPlaylist(playlistID, trackID string) bool
- func RenamePlaylist(id, title string) bool
- func ReplayGain() bool
- func Resume()
- func Search(q string) string
- func SearchPodcasts(q string) string
- func Seek(ms int64)
- func SetAdsDisabled(disabled bool) bool
- func SetClientInfo(clientName, device string)
- func SetCrossfadeMS(ms int)
- func SetDataDir(dir string)
- func SetDownloadDir(path string) bool
- func SetEQJSON(js string) bool
- func SetGapless(on bool)
- func SetMediaCacheMB(mb int) bool
- func SetOutputSuspended(on bool)
- func SetQuality(level int)
- func SetQueueIndex(i int)
- func SetQueueJSON(js string) error
- func SetRepeat(mode int)
- func SetReplayGain(on bool)
- func SetShuffle(on int)
- func SetSleepTimer(minutes int, endOfTrack int)
- func SetVolume(v float64)
- func SleepActive() int
- func SleepEndOfTrack() int
- func SleepRemainingMS() int64
- func State() int
- func Stop()
- func TogglePause()
- func TrackMixJSON(id string) string
- func UserID() string
- func Volume() float64
- func WebRemoteInfo() string
- func WebRemoteQRPNG() []byte
- func WebRemoteSetEnabled(on int)
Constants ¶
const Version = version.Number
Version is the engine/app version (single source: internal/version).
Variables ¶
This section is empty.
Functions ¶
func AddFavorite ¶
func AddToPlaylist ¶
func AdsDisabled ¶
func AdsDisabled() bool
AdsDisabled reports whether the free-tier ads/play-reporting opt-out is on.
func AlbumTracks ¶
func ArtistMixJSON ¶
ArtistMixJSON returns an "artist radio" mix seeded from an artist: {tracks:[...]} in the shared wire shape, mirroring Flow.
func ArtistProfile ¶
func CheckUpdate ¶
func CheckUpdate() string
CheckUpdate checks GitHub for a newer release; returns JSON {current, latest, hasUpdate, url, notes}.
func ClearPreload ¶
func ClearPreload()
ClearPreload discards a preloaded next track. Call when the upcoming track is no longer determined (shuffle/repeat toggled, queue edited after a preload was armed) so a stale preload can't be gaplessly swapped in.
func ConnectDevice ¶
ConnectDevice routes playback to the device at addr (host:port). Stops local playback (audio moves to the device). Returns true on success.
func ConnectHostInfo ¶
func ConnectHostInfo() string
ConnectHostInfo returns a JSON string: {"enabled":bool,"addr":"<lanip>:<port>","port":<int>,"name":"<account>"}. addr/name are empty when the Connect host is disabled.
func ConnectHostSetEnabled ¶
func ConnectHostSetEnabled(on int)
ConnectHostSetEnabled makes this device a discoverable OpenDeezer Connect target on the LAN (on!=0), so other devices signed into the same Deezer account can find it in their device picker and drive its playback; or stops advertising it (on==0). The control server runs on a LAN address with same-account auth. Idempotent.
func ConnectedDevice ¶
func ConnectedDevice() string
ConnectedDevice returns the connected device address ("" if local).
func CreatePlaylist ¶
func CrossfadeMS ¶
func CrossfadeMS() int
func DeletePlaylist ¶
func DisconnectDevice ¶
func DisconnectDevice()
DisconnectDevice returns control to local playback. Stops the remote device (so it doesn't keep playing unattended) before clearing the connection.
func DiscoverDevices ¶
DiscoverDevices returns LAN + configured Connect devices as a JSON array.
func DownloadAlbum ¶
DownloadAlbum downloads every track of albumID to the shared download folder (DownloadDir) and returns the batch summary {"saved":N,"failed":N,"dir":"...","error":""}. Blocking and premium-only, the same gate + folder DownloadTrack uses — call it off the UI thread. On a partial download "failed" counts the per-track failures and "error" carries the batch message; a free account yields saved:0,failed:0 with the premium error.
func DownloadDir ¶
func DownloadDir() string
DownloadDir returns the current download folder (env/config/default).
func DownloadForOffline ¶
DownloadForOffline fetches the raw ciphertext for id into the media cache (if not already present) and ensures the plan meta is stored via PutMeta so subsequent plays can use PrepareStreamCached with zero network (cache-only plan). Returns JSON status {"status":"...","key":"...","trackID":"..."} or {"error":"..."}. When plan.CDNURL=="" (meta hit) it checks for the body and short-circuits cleanly without network if present; otherwise forces a resolve to obtain a URL for the body fetch. Call off the UI thread. Requires cache enabled (MediaCacheMB>0) at startup.
func DownloadPlaylist ¶
DownloadPlaylist downloads every track of playlistID to the shared download folder and returns the same batch summary as DownloadAlbum.
func DownloadTrack ¶
DownloadTrack downloads trackID to a file in destDir and returns JSON {"path":"..."} on success or {"error":"..."} on failure. Pass "" for destDir to use the shared default folder (DownloadDir). Blocking — call it off the UI thread. Downloads are premium-only; a free account gets an error.
func DurationMS ¶
func DurationMS() int64
func EQJSON ¶
func EQJSON() string
EQJSON returns the equalizer state: {enabled,mono,preampDb,gainsDb:[10],preset,bands:[10],presets:[...]}. Same wire shape as corelib's DZEQJSON so every client renders the same UI.
func FavoriteIDsJSON ¶
func FavoriteIDsJSON() string
FavoriteIDsJSON returns the account's liked (favorite) track ids as a JSON array of strings, e.g. ["123","456"]. It reuses the same c.Favorites() the library view fetches, so the app can render truthful "liked" hearts across lists without a per-track lookup. Returns "[]" when not logged in or on a fetch error.
func FinishedCount ¶
func FinishedCount() int
func GetRepeat ¶
func GetRepeat() string
GetRepeat returns the current repeat mode ("off"|"all"|"one"). When routed to a Connect device it returns the remote host's mode (the routed snapshot), so the app renders the host's real mode while casting; otherwise it returns the engine queue's mode.
func GetShuffle ¶
func GetShuffle() bool
GetShuffle reports whether shuffle is on. When routed to a Connect device it returns the remote host's flag (the routed snapshot), so the app renders the host's real mode while casting; otherwise the engine queue's flag.
func HistoryRecentJSON ¶
HistoryRecentJSON returns the newest n entries of the machine-local listening history as a JSON array (newest first, the same stable shape the control API's /history/recent serves); n <= 0 returns all. Empty/unavailable history yields "[]".
Each entry is {trackId,title,artist,album?,kind?,startedAt,durationPlayedSec}. "kind" is omitted or "track" for a song and "episode" for a podcast episode — an app routes replay on it: episode -> PlayEpisodeMS(trackId), else PlayTrackMS.
func HistoryStatsJSON ¶
HistoryStatsJSON returns local listening stats over the last sinceDays (sinceDays <= 0 = all history) as {topTracks:[{trackId,title,artist,plays,totalSec}],
topArtists:[{artist,plays,totalSec}], totalSeconds:N}. Empty/unavailable
history yields the same shape with empty arrays and totalSeconds:0. topTracks and topArtists are music-only (podcast episodes excluded); totalSeconds counts all listening time.
func Home ¶
func Home() string
Home aggregates the Home-screen sections (charts top tracks/albums + the user's playlists) in one call, mirroring corelib DZHomeJSON. Best-effort.
func IsPreview ¶
func IsPreview() bool
IsPreview reports whether the current track is Deezer's 30-second preview (the free-account fallback) rather than the full stream.
func LoginErrorKind ¶
func LoginErrorKind() int
LoginErrorKind returns why the most recent Init failed so the UI shows a No-Internet retry screen instead of forcing re-auth: 0 = ok, 1 = ARL expired or invalid, 2 = no internet, 3 = other.
func Logout ¶
func Logout()
Logout tears the engine session down: stops playback, closes the control server (dropping web-remote pairing sessions and the old account's same-account auth), stops Connect-host advertising, and forgets the Deezer client. A later Init starts services fresh for the new account.
func MediaCacheMB ¶
func MediaCacheMB() int
MediaCacheMB returns the on-disk raw-stream cache budget in megabytes (media.json; 0 = cache disabled, the default).
func NowPlaying ¶
func NowPlaying() string
NowPlaying returns the track actually playing (remote when routed, else local).
func PlayEpisode ¶
PlayEpisode resolves + plays a podcast episode (plain stream) with an unknown duration. Prefer PlayEpisodeMS when the caller knows the duration.
func PlayEpisodeMS ¶
PlayEpisodeMS resolves + plays a podcast episode (plain stream). Sets the episode as the current track immediately (id + duration, mirroring corelib DZPlayEpisode — the player never derives duration from the stream), then asynchronously enriches title / podcast name / artwork via REST /episode.
func PlaylistTracks ¶
func PodcastEpisodes ¶
func PositionMS ¶
func PositionMS() int64
func Preload ¶
Preload resolves trackID's stream (exactly like Play does) and arms the player's preload, so the transition after the current track ends is gapless / crossfaded instead of a full network re-resolve at track end. No-op when both gapless and crossfade are off, or when routed to a Connect device. Blocking (network round-trip) — call it off the UI thread. The track duration is taken from the synced queue (SetQueueJSON) when present, else fetched best-effort.
func QueueIndex ¶
func QueueIndex() int
QueueIndex returns the engine queue's cursor (-1 when empty/unsynced), so the app can resync its own cursor after an engine-driven advance (remote /next|/prev, gapless promote).
func QueueInsertNext ¶
func QueueInsertNext(trackJSON string)
QueueInsertNext inserts the track described by trackJSON (wire shape, same as SetQueueJSON payload; accepts either a single object or a 1-element array) immediately after the current row (or at start if empty). Bumps version.
func QueueJSON ¶
func QueueJSON() string
QueueJSON returns the engine queue as {"version":N,"index":I,"tracks":[..]} (tracks in the shared wire shape), so the app can adopt remote queue edits.
func QueueMove ¶
func QueueMove(from, to int)
QueueMove reorders the engine queue (from -> to). Cursor/history follow. from==to and out-of-range are no-ops.
func QueueRemove ¶
func QueueRemove(index int)
QueueRemove removes the track at index from the engine queue (if valid and not the playing row). It is the direct export for mobile queue UIs to mutate engineQ (bumping version) so remote controllers see consistent state.
func QueueVersion ¶
func QueueVersion() int64
QueueVersion returns a counter bumped on every engine-queue CONTENT change (SetQueueJSON, remote /queue/add|remove|move, /play/album, /play/mix/{track,artist}) — cursor moves don't bump it. The app polls this cheaply and pulls QueueJSON only when a remote controller actually edited the queue.
func RemoveFavorite ¶
func RemoveFromPlaylist ¶
func RenamePlaylist ¶
func ReplayGain ¶
func ReplayGain() bool
func SearchPodcasts ¶
func SetAdsDisabled ¶
SetAdsDisabled turns Deezer Free's play-reporting/ads off/on and persists it. FREE accounts only: reporting plays (log.listen) credits artists and drives the ad schedule; disabling it is ad-free but stops reporting — the user's at-own-risk choice. Paid accounts are unaffected.
func SetClientInfo ¶
func SetClientInfo(clientName, device string)
SetClientInfo overrides the advertised client id + device label (before Init).
func SetCrossfadeMS ¶
func SetCrossfadeMS(ms int)
func SetDataDir ¶ added in v3.1.3
func SetDataDir(dir string)
SetDataDir points the engine's config + on-disk caches at dir — an app-private directory the host guarantees is writable and persists across reboots (on Android: context.getFilesDir(); on iOS: Application Support). os.UserConfigDir is not such a path on mobile, so the host MUST call this once at startup, before Init — otherwise media.json (the stream-cache setting) and the mediacache/ directory are written somewhere that isn't there next launch, so the cache neither persists nor reads back correctly in Settings.
func SetDownloadDir ¶
SetDownloadDir persists the download folder ("" resets to the default).
func SetEQJSON ¶
SetEQJSON applies a partial EQ update. Recognized keys (all optional): enabled (bool), mono (bool), preampDb (number), gainsDb ([10]number), preset (string), band ({"index":N,"gainDb":X}). Returns false if any present key failed to apply.
func SetGapless ¶
func SetGapless(on bool)
func SetMediaCacheMB ¶
SetMediaCacheMB persists the raw-stream cache budget in megabytes (0 or a negative value disables the cache). The cache is attached to the player once at startup, before any playback, so a change takes effect at the next launch.
func SetOutputSuspended ¶
func SetOutputSuspended(on bool)
SetOutputSuspended suspends (true) or resumes (false) the local OS audio device without touching playback state — for audio-focus/route handling on mobile. Local-only: it never routes to a Connect device.
func SetQuality ¶
func SetQuality(level int)
func SetQueueIndex ¶
func SetQueueIndex(i int)
SetQueueIndex aligns the engine queue's cursor to i (clamped; no-op when the queue is empty). Call it whenever the app changes the playing row so the engine queue tracks what is audible. It uses AlignIndex, not SetIndex, so this pure synchronisation records no navigation history (a synthetic entry would make a later remote Prev jump to a never-played track). Genuine remote jumps go through engineQueueSelect (SetIndex), which does record history.
func SetQueueJSON ¶
SetQueueJSON replaces the engine-side playback queue with the app's queue so remote controllers see it on /status and /next + /prev walk it. js is a JSON array of tracks in the same wire shape every list call returns ({id,name,durationMs,artistLine,artistId,artists,albumName,artworkUrl, explicit}); only id is required, but durationMs should be set so controllers' end-of-track detection works. The cursor resets to 0 — follow with SetQueueIndex to point it at the playing row. Pass "[]" to clear. Apps that never call this keep today's behavior exactly (app-owned queue via FinishedCount). Returns an error on a parse failure.
func SetRepeat ¶
func SetRepeat(mode int)
SetRepeat sets the repeat mode (mode: 0=off, 1=all, 2=one). The mode is recorded on the engine-side queue — /status reports it and the engine queue honors it when it advances. It is NOT forwarded to a connected remote device (B2): while casting, the controller keeps repeat local so the host's single- track queue never loops the current track. Read the host's own mode with GetRepeat.
func SetReplayGain ¶
func SetReplayGain(on bool)
func SetShuffle ¶
func SetShuffle(on int)
SetShuffle sets shuffle on (non-zero) or off (0). The flag is always recorded on the engine-side queue — /status reports it and the engine queue honors it when it advances — and it is forwarded to the connected remote device when one is selected.
func SetSleepTimer ¶
SetSleepTimer arms the sleep timer: pause after `minutes` (with a fade-out), or when the current track ends if endOfTrack != 0 (minutes ignored). minutes <= 0 with endOfTrack == 0 cancels it.
func SleepActive ¶
func SleepActive() int
SleepActive reports whether a sleep timer is armed (1) or not (0).
func SleepEndOfTrack ¶
func SleepEndOfTrack() int
SleepEndOfTrack reports whether the armed timer is end-of-track mode (1/0).
func SleepRemainingMS ¶
func SleepRemainingMS() int64
SleepRemainingMS returns milliseconds until the timer fires (0 if none).
func TogglePause ¶
func TogglePause()
func TrackMixJSON ¶
TrackMixJSON returns a "song radio" mix seeded from a track (the seed kept as the first entry): {tracks:[...]} in the shared wire shape, mirroring Flow.
func WebRemoteInfo ¶
func WebRemoteInfo() string
WebRemoteInfo returns a JSON string: {"enabled":bool,"code":"123456","url":"http://<lanip>:<port>/remote","port":<int>}. code and url are empty when the remote is disabled.
func WebRemoteQRPNG ¶
func WebRemoteQRPNG() []byte
WebRemoteQRPNG returns a PNG-encoded QR code for the web remote URL, or nil when the remote is disabled. Free-able by the caller (Go GC manages it).
func WebRemoteSetEnabled ¶
func WebRemoteSetEnabled(on int)
WebRemoteSetEnabled enables (on!=0) or disables (on==0) the web remote. When enabling, the control server is started on a LAN-reachable address if it is not already, and pairing is activated so a phone can scan the QR and connect.
Types ¶
This section is empty.