diff --git a/docs/assets/extra.css b/docs/assets/extra.css new file mode 100644 index 00000000..1904d270 --- /dev/null +++ b/docs/assets/extra.css @@ -0,0 +1,86 @@ +/* + * MkDocs Material theme buttons have wrong colors for the theme + * setting: + * + * palette: + * scheme: default + * primary: white + * + * Thus the following CSS overwrites the button background- and + * text-colors. + */ +.md-button { + color: var(--md-accent-fg-color) !important; + border-color: currentColor !important; +} +.md-button:focus, +.md-button:hover { + color: var(--md-primary-fg-color) !important; + background-color: var(--md-accent-fg-color) !important; + border-color: var(--md-accent-fg-color) !important; +} + +/* + * The nav title has a click handler to scroll to the top + */ +.md-header-nav__title { + cursor: pointer; +} + +/* + * Text alignment + */ +.text-center { + text-align: center; +} + +/* + * Custom CSS for images + */ +.hidden { + visibility: hidden; + opacity: 0; + transition: visibility 0s linear 300ms, opacity 300ms; +} +.visible { + visibility: visible; + opacity: 1; + transition: visibility 0s linear 0s, opacity 300ms; +} +.fullscreen-image-background { + z-index: 25; + background-color: rgba(10, 10, 10, 0.5); + position: fixed; + bottom: 0; + left: 0; + right: 0; + top: 0; +} +.fullscreen-image-background img { + transition: opacity 1s; + cursor: zoom-out; + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + z-index: 100; + position: fixed; + left: 0; + right: 0; + top: 0; + bottom: 0; + margin: 1rem auto; + max-height: calc(100vh - 2rem); + width: auto; +} +.zoom { + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); + border-radius: 0.2rem; + margin: 0.5rem; + width: 25%; + cursor: zoom-in; +} +.zoom-wrapper { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + flex-wrap: wrap; +} diff --git a/docs/assets/extra.js b/docs/assets/extra.js new file mode 100644 index 00000000..1717d99c --- /dev/null +++ b/docs/assets/extra.js @@ -0,0 +1,32 @@ +/* + * Add click event handler for images with class="zoom" + */ +document.querySelectorAll('img.zoom').forEach(item => { + const p = item.parentElement; + if (!p.classList.contains('processed')) { + p.classList.add('processed'); + if (p.querySelectorAll('img.zoom').length === p.children.length) { + p.classList.add('zoom-wrapper'); + } + } + item.addEventListener('click', function () { + const img = document.getElementById('fullscreen-image-img'); + img.setAttribute('src', this.getAttribute('src')); + img.setAttribute('alt', this.getAttribute('alt')); + + const div = document.getElementById('fullscreen-image'); + div.classList.replace('hidden', 'visible'); + }) +}); + +var div = document.createElement('div'); +div.classList.add('fullscreen-image-background', 'hidden'); +div.id = 'fullscreen-image'; +var img = document.createElement('img'); +img.id = 'fullscreen-image-img'; +div.appendChild(img); + +div.addEventListener('click', function () { + this.classList.replace('visible', 'hidden'); +}); +document.body.appendChild(div); \ No newline at end of file diff --git a/docs/assets/favicon.ico b/docs/assets/favicon.ico new file mode 100644 index 00000000..8521bedf Binary files /dev/null and b/docs/assets/favicon.ico differ diff --git a/docs/assets/logo.svg b/docs/assets/logo.svg new file mode 100644 index 00000000..8151f49b --- /dev/null +++ b/docs/assets/logo.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + diff --git a/docs/documentation.md b/docs/documentation.md new file mode 100644 index 00000000..1536b3b8 --- /dev/null +++ b/docs/documentation.md @@ -0,0 +1,575 @@ +# Documentation + +## Getting started + +After installation (see [Installation](installation.md)) do the following: + + 1. Edit the configuration file (usually `/etc/owntone.conf`) to suit your + needs + 2. Start or restart the server (usually `/etc/init.d/owntone restart`) + 3. Go to the web interface [http://owntone.local:3689](http://owntone.local:3689), + or, if that won't work, to [http://[your_server_address_here]:3689](http://[your_server_address_here]:3689) + 4. Wait for the library scan to complete + 5. If you will be using a remote, e.g. Apple Remote: Start the remote, go to + Settings, Add Library + 6. Enter the pair code in the web interface (update the page with F5 if it does + not automatically pick up the pairing request) + + +## Supported clients + +OwnTone supports these kinds of clients: + +- DAAP clients, like iTunes or Rhythmbox +- Remote clients, like Apple Remote or compatibles for Android/Windows Phone +- AirPlay devices, like AirPort Express, Shairport and various AirPlay speakers +- Chromecast devices +- MPD clients, like mpc (see [mpd-clients](#mpd-clients)) +- MP3 network stream clients, like VLC and almost any other music player +- RSP clients, like Roku Soundbridge + +Like iTunes, you can control OwnTone with Remote and stream your music to +AirPlay devices. + +A single OwnTone instance can handle several clients concurrently, regardless of +the protocol. + +By default all clients on 192.168.* (and the ipv6 equivalent) are allowed to +connect without authentication. You can change that in the configuration file. + +Here is a list of working and non-working DAAP and Remote clients. The list is +probably obsolete when you read it :-) + +| Client | Developer | Type | Platform | Working (vers.) | +| ------------------------ | ----------- | ------ | ------------- | --------------- | +| iTunes | Apple | DAAP | Win | Yes (12.10.1) | +| Apple Music | Apple | DAAP | MacOS | Yes | +| Rhythmbox | Gnome | DAAP | Linux | Yes | +| Diapente | diapente | DAAP | Android | Yes | +| WinAmp DAAPClient | WardFamily | DAAP | WinAmp | Yes | +| Amarok w/DAAP plugin | KDE | DAAP | Linux/Win | Yes (2.8.0) | +| Banshee | | DAAP | Linux/Win/OSX | No (2.6.2) | +| jtunes4 | | DAAP | Java | No | +| Firefly Client | | (DAAP) | Java | No | +| Remote | Apple | Remote | iOS | Yes (4.3) | +| Retune | SquallyDoc | Remote | Android | Yes (3.5.23) | +| TunesRemote+ | Melloware | Remote | Android | Yes (2.5.3) | +| Remote for iTunes | Hyperfine | Remote | Android | Yes | +| Remote for Windows Phone | Komodex | Remote | Windows Phone | Yes (2.2.1.0) | +| TunesRemote SE | | Remote | Java | Yes (r108) | +| rtRemote for Windows | bizmodeller | Remote | Windows | Yes (1.2.0.67) | + + +## Web interface + +You can find the web interface at [http://owntone.local:3689](http://owntone.local:3689) +or alternatively at [http://[your_server_address_here]:3689](http://[your_server_address_here]:3689). + +Use the web interface to control playback, trigger manual library rescans, pair +with remotes, select speakers, authenticate with Spotify, etc. + +You can find some screenshots and build instructions in the [web interface documentation](web-interface.md). + +## Using Remote + +Remote gets a list of output devices from the server; this list includes any +and all devices on the network we know of that advertise AirPlay: AirPort +Express, Apple TV, ... It also includes the local audio output, that is, the +sound card on the server (even if there is no soundcard). + +OwnTone remembers your selection and the individual volume for each +output device; selected devices will be automatically re-selected, except if +they return online during playback. + +### Pairing + + 1. Open the [web interface](http://owntone.local:3689) + 2. Start Remote, go to Settings, Add Library + 3. Enter the pair code in the web interface (update the page with F5 if it does + not automatically pick up the pairing request) + +If Remote doesn't connect to OwnTone after you entered the pairing code +something went wrong. Check the log file to see the error message. Here are +some common reasons: + +- You did not enter the correct pairing code + + You will see an error in the log about pairing failure with a HTTP response code + that is *not* 0. + + Solution: Try again. + +- No response from Remote, possibly a network issue + + If you see an error in the log with either: + + - a HTTP response code that is 0 + - "Empty pairing request callback" + + it means that OwnTone could not establish a connection to Remote. This + might be a network issue, your router may not be allowing multicast between the + Remote device and the host OwnTone is running on. + + Solution 1: Sometimes it resolves the issue if you force Remote to quit, restart + it and do the pairing proces again. Another trick is to establish some other + connection (eg SSH) from the iPod/iPhone/iPad to the host. + + Solution 2: Check your router settings if you can whitelist multicast addresses + under IGMP settings. For Apple Bonjour, setting a multicast address of + 224.0.0.251 and a netmask of 255.255.255.255 should work. + +- Otherwise try using avahi-browse for troubleshooting: + + - in a terminal, run `avahi-browse -r -k _touch-remote._tcp` + - start Remote, goto Settings, Add Library + - after a couple seconds at most, you should get something similar to this: + + ``` + + ath0 IPv4 59eff13ea2f98dbbef6c162f9df71b784a3ef9a3 _touch-remote._tcp local + = ath0 IPv4 59eff13ea2f98dbbef6c162f9df71b784a3ef9a3 _touch-remote._tcp local + hostname = [Foobar.local] + address = [192.168.1.1] + port = [49160] + txt = ["DvTy=iPod touch" "RemN=Remote" "txtvers=1" "RemV=10000" "Pair=FAEA410630AEC05E" "DvNm=Foobar"] + ``` + + Hit Ctrl-C to terminate avahi-browse. + +- To check for network issues you can try to connect to address and port with telnet. + + +## AirPlay devices/speakers + +OwnTone will discover the AirPlay devices available on your network. For +devices that are password-protected, the device's AirPlay name and password +must be given in the configuration file. See the sample configuration file +for the syntax. + +If your Apple TV requires device verification (always required by Apple TV4 with +tvOS 10.2) then you can do that through Settings > Remotes & Outputs in the web +interface: Select the device and then enter the PIN that the Apple TV displays. + +If your speaker is silent when you start playback, and there is no obvious error +message in the log, you can try disabling ipv6 in the config. Some speakers +announce that they support ipv6, but in fact don't (at least not with forked- +daapd). + +If the speaker becomes unselected when you start playback, and you in the log +see "ANNOUNCE request failed in session startup: 400 Bad Request", then try +the Apple Home app > Allow Speakers & TV Access > Anyone On the Same Network +(or Everyone). + + +## Chromecast + +OwnTone will discover Chromecast devices available on your network, and you +can then select the device as a speaker. There is no configuration required. + + +## Local audio through ALSA + +In the config file, you can select ALSA for local audio. This is the default. + +When using ALSA, the server will try to syncronize playback with AirPlay. You +can adjust the syncronization in the config file. + +For most setups the default values in the config file should work. If they +don't, there is help [here](outputs-alsa.md) + + +## Local audio, Bluetooth and more through Pulseaudio + +In the config file, you can select Pulseaudio for local audio. In addition to +local audio, Pulseaudio also supports an array of other targets, e.g. Bluetooth +or DLNA. However, Pulseaudio does require some setup, so here is a separate page +with some help on that: [Pulse audio](outputs-pulse.md) + +Note that if you select Pulseaudio the "card" setting in the config file has +no effect. Instead all soundcards detected by Pulseaudio will be listed as +speakers by OwnTone. + +You can adjust the latency of Pulseaudio playback in the config file. + + +## MP3 network streaming (streaming to iOS) + +You can listen to audio being played by OwnTone by opening this network +stream address in pretty much any music player: + + http://[your hostname/ip address]:3689/stream.mp3 + +This is currently the only way of listening to your audio on iOS devices, since +Apple does not allow AirPlay receiver apps, and because Apple Home Sharing +cannot be supported by OwnTone. So what you can do instead is install a +music player app like VLC, connect to the stream and control playback with +Remote. + +In the speaker selection list, clicking on the icon should start the stream +playing in the background on browsers that support that. + +Note that MP3 encoding must be supported by ffmpeg/libav for this to work. If +it is not available you will see a message in the log file. In Debian/Ubuntu you +get MP3 encoding support by installing the package "libavcodec-extra". + + +## Remote access + +It is possible to access a shared library over the internet from a DAAP client +like iTunes. You must have remote access to the host machine. + +First log in to the host and forward port 3689 to your local machine. You now +need to broadcast the daap service to iTunes on your local machine. On macOS the +command is: + +``` +dns-sd -P iTunesServer _daap._tcp local 3689 localhost.local 127.0.0.1 "ffid=12345" +``` + +The `ffid` key is required but its value does not matter. + +Your library will now appear as 'iTunesServer' in iTunes. + +You can also access your library remotely using something like Zerotier. See [this +guide](https://github.com/owntone/owntone-server/wiki/Accessing-Owntone-remotely-through-iTunes-Music-with-Zerotier) +for details. + + +## Supported formats + +OwnTone should support pretty much all audio formats. It relies on libav +(or ffmpeg) to extract metadata and decode the files on the fly when the client +doesn't support the format. + +Formats are attributed a code, so any new format will need to be explicitely +added. Currently supported: + +- MPEG4: mp4a, mp4v +- AAC: alac +- MP3 (and friends): mpeg +- FLAC: flac +- OGG VORBIS: ogg +- Musepack: mpc +- WMA: wma (WMA Pro), wmal (WMA Lossless), wmav (WMA video) +- AIFF: aif +- WAV: wav +- Monkey's audio: ape + + +## Playlists and internet radio + +OwnTone supports M3U and PLS playlists. Just drop your playlist somewhere +in your library with an .m3u or .pls extension and it will pick it up. + +From the web interface, and some mpd clients, you can also create and modify +playlists by saving the current queue. Click the "Save" button. Note that this +requires that `allow_modifying_stored_playlists` is enabled in the configuration +file, and that the server has write access to `default_playlist_directory`. + +If the playlist contains an http URL it will be added as an internet radio +station, and the URL will be probed for Shoutcast (ICY) metadata. If the radio +station provides artwork, OwnTone will download it during playback and send +it to any remotes or AirPlay devices requesting it. + +Instead of downloading M3U's from your radio stations, you can also make an +empty M3U file and insert links in it to the M3U's of your radio stations. + +Radio streams can only be played by OwnTone, so that means they will not be +available to play in DAAP clients like iTunes. + +The server can import playlists from iTunes Music Library XML files. By default, +metadata from our parsers is preferred over what's in the iTunes DB; use +itunes_overrides = true if you prefer iTunes' metadata. + +OwnTone has support for smart playlists. How to create a smart playlist is +documented in [Smart playlists](smart-playlists.md). + +If you're not satisfied with internet radio metadata that OwnTone shows, +then you can read about tweaking it in +[Radio streams](radio-streams.md). + + +## Artwork + +OwnTone has support for PNG and JPEG artwork which is either: + +- embedded in the media files +- placed as separate image files in the library +- made available online by the radio station + +For media in your library, OwnTone will try to locate album and artist +artwork (group artwork) by the following procedure: + +- if a file {artwork,cover,Folder}.{png,jpg} is found in one of the directories + containing files that are part of the group, it is used as the artwork. The + first file found is used, ordering is not guaranteed; +- failing that, if [directory name].{png,jpg} is found in one of the + directories containing files that are part of the group, it is used as the + artwork. The first file found is used, ordering is not guaranteed; +- failing that, individual files are examined and the first file found + with an embedded artwork is used. Here again, ordering is not guaranteed. + +{artwork,cover,Folder} are the default, you can add other base names in the +configuration file. Here you can also enable/disable support for individual +file artwork (instead of using the same artwork for all tracks in an entire +album). + +For playlists in your library, say /foo/bar.m3u, then for any http streams in +the list, OwnTone will look for /foo/bar.{jpg,png}. + +You can use symlinks for the artwork files. + +OwnTone caches artwork in a separate cache file. The default path is +`/var/cache/owntone/cache.db` and can be configured in the configuration +file. The cache.db file can be deleted without losing the library and pairing +informations. + + +## Library + +The library is scanned in bulk mode at startup, but the server will be available +even while this scan is in progress. You can follow the progress of the scan in +the log file or via the web interface. When the scan is complete you will see +the log message: "Bulk library scan completed in X sec". + +The very first scan will take longer than subsequent startup scans, since every +file gets analyzed. At the following startups the server looks for changed files +and only analyzis those. + +Updates to the library are reflected in real time after the initial scan, so you +do not need to manually start rescans. The directories are monitored for changes +and rescanned on the fly. Note that if you have your library on a network mount +then real time updating may not work. Read below about what to do in that case. + +If you change any of the directory settings in the library section of the +configuration file a rescan is required before the new setting will take effect. +You can do this by using "Update library" from the web interface. + +Symlinks are supported and dereferenced, but it is best to use them for +directories only. + + +### Pipes (for e.g. multiroom with Shairport-sync) + +Some programs, like for instance Shairport-sync, can be configured to output +audio to a named pipe. If this pipe is placed in the library, OwnTone will +automatically detect that it is there, and when there is audio being written to +it, playback of the audio will be autostarted (and stopped). + +Using this feature, OwnTone can act as an AirPlay multiroom "router": You can +have an AirPlay source (e.g. your iPhone) send audio Shairport-sync, which +forwards it to OwnTone through the pipe, which then plays it on whatever +speakers you have selected (through Remote). + +The format of the audio being written to the pipe must be PCM16. + +You can also start playback of pipes manually. You will find them in remotes +listed under "Unknown artist" and "Unknown album". The track title will be the +name of the pipe. + +Shairport-sync can write metadata to a pipe, and OwnTone can read this. +This requires that the metadata pipe has the same filename as the audio pipe +plus a ".metadata" suffix. Say Shairport-sync is configured to write audio to +"/foo/bar/pipe", then the metadata pipe should be "/foo/bar/pipe.metadata". + + +### Libraries on network mounts + +Most network filesharing protocols do not offer notifications when the library +is changed. So that means OwnTone cannot update its database in real time. +Instead you can schedule a cron job to update the database. + +The first step in doing this is to add two entries to the 'directories' +configuration item in owntone.conf: + +``` + directories = { "/some/local/dir", "/your/network/mount/library" } +``` + +Now you can make a cron job that runs this command: + +``` + touch /some/local/dir/trigger.init-rescan +``` + +When OwnTone detects a file with filename ending .init-rescan it will +perform a bulk scan similar to the startup scan. + +Alternatively, you can force a metadata scan of the library even if the +files have not changed by creating a filename ending `.meta-rescan`. + + +### Troubleshooting library issues + +If you place a file with the filename ending .full-rescan in your library, +you can trigger a full rescan of your library. This will clear all music and +playlists from OwnTone's database and initiate a fresh bulk scan. Pairing +and speaker information will be kept. Only use this for troubleshooting, it is +not necessary during normal operation. + + +## Command line + +You can choose between: + +- a [MPD command line client](#mpd-clients) (easiest) like `mpc` +- curl with OwnTone's JSON API (see [README_JSON_API.md](https://github.com/owntone/owntone-server/blob/master/README_JSON_API.md)) +- curl with DAAP/DACP commands (hardest) + +Here is an example of how to use curl with DAAP/DACP. Say you have a playlist +with a radio station, and you want to make a script that starts playback of that +station: + +1. Run `sqlite3 [your OwnTone db]`. Use `select id,title from files` to get + the id of the radio station, and use `select id,title from playlists` to get + the id of the playlist. +2. Convert the two ids to hex. +3. Put the following lines in the script with the relevant ids inserted (also + observe that you must use a session-id < 100, and that you must login and + logout): + +``` +curl "http://localhost:3689/login?pairing-guid=0x1&request-session-id=50" +curl "http://localhost:3689/ctrl-int/1/playspec?database-spec='dmap.persistentid:0x1'&container-spec='dmap.persistentid:0x[PLAYLIST-ID]'&container-item-spec='dmap.containeritemid:0x[FILE ID]'&session-id=50" +curl "http://localhost:3689/logout?session-id=50" +``` + + +## Spotify + +OwnTone has built-in support for playback of the tracks in your Spotify library. + +You must have a Spotify premium account. If you normally log into Spotify with +your Facebook account you must first go to Spotify's web site where you can get +the Spotify username and password that matches your account. + +You must also make sure that your browser can reach OwnTone's web interface via +the address [http://owntone.local:3689](http://owntone.local:3689). Try it right +now! That is where Spotify's OAuth page will redirect your browser with the +token that OwnTone needs, so it must work. The address is announced by the +server via mDNS, but if that for some reason doesn't work then configure it via +router or .hosts file. You can remove it again after completing the login. + +To authorize OwnTone, open the web interface, locate Settings > Online Services +and then click the Authorize button. You will then be sent to Spotify's +authorization service, which will send you back to the web interface after +you have given the authorization. + +Spotify no longer automatically notifies clients about library updates, so you +have to trigger updates manually. You can for instance set up a cron job that +runs `/usr/bin/curl http://localhost:3689/api/update` + +To logout and remove Spotify tracks + credentials make a request to +[http://[your_server_address_here]:3689/api/spotify-logout](http://[your_server_address_here]:3689/api/spotify-logout). + +Limitations: +You will not be able to do any playlist management through OwnTone - use +a Spotify client for that. You also can only listen to your music by letting +OwnTone do the playback - so that means you can't stream to DAAP clients (e.g. +iTunes) and RSP clients. + +### Via librespot/spocon + +You can also use OwnTone with one of the various incarnations of +[librespot](https://github.com/librespot-org/librespot). This adds librespot as +a selectable metaspeaker in Spotify's client, and when you start playback, +librespot can be configured to start writing audio to a pipe that you have added +to your library. This will be detected by OwnTone that then starts playback. +You can also have a pipe for metadata and playback events, e.g. volume changes. + +The easiest way of accomplishing this may be with [Spocon](https://github.com/spocon/spocon), +since it requires minimal configuration. After installing, create two pipes +(with mkfifo) and set the configuration in the player section: + +``` +# Audio output device (MIXER, PIPE, STDOUT) +output = "PIPE" +# Output raw (signed) PCM to this file (`player.output` must be PIPE) +pipe = "/srv/music/spotify" +# Output metadata in Shairport Sync format (https://github.com/mikebrady/shairport-sync-metadata-reader) +metadataPipe = "/srv/music/spotify.metadata" +``` + +### Via libspotify + +This method is being deprecated, but is still available if the server was built +with it, libspotify is installed and `use_libspotify` is enabled in the config +file. Please consult [previous README versions](#references) for details on +using libspotify. + + +## LastFM + +You can have OwnTone scrobble the music you listen to. To set up scrobbling +go to the web interface and authorize OwnTone with your LastFM credentials. + +OwnTone will not store your LastFM username/password, only the session key. +The session key does not expire. + + +## MPD clients + +You can - to some extent - use clients for MPD to control OwnTone. + +By default OwnTone listens on port 6600 for MPD clients. You can change +this in the configuration file. + +Currently only a subset of the commands offered by MPD (see [MPD protocol documentation](http://www.musicpd.org/doc/protocol/)) +are supported. + +Due to some differences between OwnTone and MPD not all commands will act the +same way they would running MPD: + +- crossfade, mixrampdb, mixrampdelay and replaygain will have no effect +- single, repeat: unlike MPD, OwnTone does not support setting single and repeat separately + on/off, instead repeat off, repeat all and repeat single are supported. Thus setting single on + will result in repeat single, repeat on results in repeat all. + +The following table shows what is working for a selection of MPD clients: + +| Client | Type | Status | +| --------------------------------------------- | ------ | --------------- | +| [mpc](http://www.musicpd.org/clients/mpc/) | CLI | Working commands: mpc, add, crop, current, del (ranges are not yet supported), play, next, prev (behaves like cdprev), pause, toggle, cdprev, seek, clear, outputs, enable, disable, playlist, ls, load, volume, repeat, random, single, search, find, list, update (initiates an init-rescan, the path argument is not supported) | +| [ympd](http://www.ympd.org/) | Web | Everything except "add stream" should work | + +## Running Multiple Instances + +To run multiple instances of owntone on a server, you should copy +`/etc/owntone.conf` to `/etc/owntone-zone.conf` (for each `zone`) and +modify the following to be unique across all instances: + +* the three port settings (`general` -> `websocket_port`, + `library` -> `port`, and `mpd` -> `port`) + +* the database paths (`general` -> `db_path`, `db_backup_path`, and `db_cache_path`) + +* the service name (`library` -> `name`). + +* you probably also want to disable local output (set `audio` -> `type = + "disabled"`). + +Then run `owntone -c /etc/owntone-zone.conf` to run owntone with the new +zone configuration. + +Owntone has a `systemd` template which lets you run this automatically +on systems that use systemd. You can start or enable the service for +a `zone` by `sudo systemctl start owntone@zone` and check that it is +running with `sudo systemctl status owntone@zone`. Use `sudo +systemctl enable ownton@zone` to get the service to start on reboot. + +## References + +The source for this version of OwnTone can be found here: + +- [https://github.com/owntone/owntone-server.git](https://github.com/owntone/owntone-server.git) + +README's for current and previous versions of OwnTone: + +- [OwnTone version 28.3](https://github.com/owntone/owntone-server/blob/28.3/README.md) + +- [OwnTone version 28.2](https://github.com/owntone/owntone-server/blob/28.2/README.md) + +- [OwnTone version 28.1](https://github.com/owntone/owntone-server/blob/28.1/README.md) + +README from when OwnTone was forked-daapd: + +- [forked-daapd version 27.4](https://github.com/owntone/owntone-server/blob/27.4/README.md) diff --git a/docs/images/screenshot-audiobooks-authors.png b/docs/images/screenshot-audiobooks-authors.png new file mode 100644 index 00000000..c94b2bb7 Binary files /dev/null and b/docs/images/screenshot-audiobooks-authors.png differ diff --git a/docs/images/screenshot-audiobooks-books.png b/docs/images/screenshot-audiobooks-books.png new file mode 100644 index 00000000..db6cae5f Binary files /dev/null and b/docs/images/screenshot-audiobooks-books.png differ diff --git a/docs/images/screenshot-files.png b/docs/images/screenshot-files.png new file mode 100644 index 00000000..c940e804 Binary files /dev/null and b/docs/images/screenshot-files.png differ diff --git a/docs/images/screenshot-menu.png b/docs/images/screenshot-menu.png new file mode 100644 index 00000000..28b79584 Binary files /dev/null and b/docs/images/screenshot-menu.png differ diff --git a/docs/images/screenshot-music-album.png b/docs/images/screenshot-music-album.png new file mode 100644 index 00000000..0d0b9d06 Binary files /dev/null and b/docs/images/screenshot-music-album.png differ diff --git a/docs/images/screenshot-music-albums-options.png b/docs/images/screenshot-music-albums-options.png new file mode 100644 index 00000000..5ff12726 Binary files /dev/null and b/docs/images/screenshot-music-albums-options.png differ diff --git a/docs/images/screenshot-music-albums.png b/docs/images/screenshot-music-albums.png new file mode 100644 index 00000000..725422dc Binary files /dev/null and b/docs/images/screenshot-music-albums.png differ diff --git a/docs/images/screenshot-music-artist.png b/docs/images/screenshot-music-artist.png new file mode 100644 index 00000000..53d9fad2 Binary files /dev/null and b/docs/images/screenshot-music-artist.png differ diff --git a/docs/images/screenshot-music-artists.png b/docs/images/screenshot-music-artists.png new file mode 100644 index 00000000..770d8c7e Binary files /dev/null and b/docs/images/screenshot-music-artists.png differ diff --git a/docs/images/screenshot-music-browse.png b/docs/images/screenshot-music-browse.png new file mode 100644 index 00000000..1fdef89a Binary files /dev/null and b/docs/images/screenshot-music-browse.png differ diff --git a/docs/images/screenshot-music-spotify.png b/docs/images/screenshot-music-spotify.png new file mode 100644 index 00000000..263b3db0 Binary files /dev/null and b/docs/images/screenshot-music-spotify.png differ diff --git a/docs/images/screenshot-now-playing.png b/docs/images/screenshot-now-playing.png new file mode 100644 index 00000000..bf37b6e0 Binary files /dev/null and b/docs/images/screenshot-now-playing.png differ diff --git a/docs/images/screenshot-outputs.png b/docs/images/screenshot-outputs.png new file mode 100644 index 00000000..2c946891 Binary files /dev/null and b/docs/images/screenshot-outputs.png differ diff --git a/docs/images/screenshot-podcast.png b/docs/images/screenshot-podcast.png new file mode 100644 index 00000000..ffb538dd Binary files /dev/null and b/docs/images/screenshot-podcast.png differ diff --git a/docs/images/screenshot-podcasts.png b/docs/images/screenshot-podcasts.png new file mode 100644 index 00000000..0731bfa1 Binary files /dev/null and b/docs/images/screenshot-podcasts.png differ diff --git a/docs/images/screenshot-queue.png b/docs/images/screenshot-queue.png new file mode 100644 index 00000000..d5192fca Binary files /dev/null and b/docs/images/screenshot-queue.png differ diff --git a/docs/images/screenshot-search.png b/docs/images/screenshot-search.png new file mode 100644 index 00000000..5a143962 Binary files /dev/null and b/docs/images/screenshot-search.png differ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..32bb1d22 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,72 @@ +# OwnTone + +**OwnTone** is an open source (audio) media server for GNU/Linux, FreeBSD +and MacOS. + +It allows sharing and streaming your media library to iTunes (DAAP[^1]), +Roku (RSP), AirPlay devices (multiroom), Chromecast and also supports local playback. + +You can control OwnTone via its web interface, Apple Remote (and compatible +DAAP/DACP clients), MPD clients or via its JSON API. + +Besides serving your local music, podcast and audiobook media files, +OwnTone supports internet radios and Spotify (requires Spotify premium account). + +OwnTone was previously called forked-daapd, which again was a rewrite of +mt-daapd (Firefly Media Server). It is written in C with a web interface written in Vue.js. + +[^1]: + DAAP stands for Digital Audio Access Protocol which is the protocol used by + iTunes and friends to share/stream media libraries over the network. + +## Features + +- Stream to :material-cast-variant: AirPlay (synchronized multiroom) and :material-cast: + Chromecast devices +- :material-music-box-multiple-outline: Share local library with iTunes and Roku +- :material-volume-high: Local audio playback with ALSA or PulseAudio +- Supports multiple different clients: + + - :material-cellphone: Remote apps like Apple Remote (iOS) or Retune (Android) + - :material-web: Integrated mobile friendly web interface + - :material-console: MPD clients + +- Supports :material-music: music and :material-book-open-variant: + audiobook files, :material-microphone: podcast files and :material-rss: RSS + and :material-radio: internet radio +- :material-file-music: Supports audio files in most formats +- :material-spotify: Supports playing your Spotify library (requires + Spotify premium account) +- :material-raspberry-pi: Runs on low power devices like the Raspberry Pi + +--- + +![Now playing](images/screenshot-now-playing.png){: class="zoom" } +![Music browse](images/screenshot-music-browse.png){: class="zoom" } +![Music album](images/screenshot-music-album.png){: class="zoom" } + +_(You can find more screenshots from OwnTone's web interface [here](web-interface.md))_ +{: class="text-center" } + +--- + +## Looking for help? + +Before you continue, make sure you know what version of OwnTone you have, +and what features it was built with (e.g. Spotify support). + +How to find out? Go to the [web interface](http://owntone.local:3689) and +check. No web interface? Then check the top of OwnTone's log file (usually +/var/log/owntone.log). + +Note that you are viewing a snapshot of the instructions that may or may not +match the version of OwnTone that you are using. + +If you are looking for help on building OwnTone (not using it), then +please see the documentation on [Building from Source](installation.md). + +## References + +The source for this version of OwnTone can be found here: + +[https://github.com/owntone/owntone-server.git](https://github.com/owntone/owntone-server.git) diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000..5a748eac --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,351 @@ +# Installation instructions for OwnTone + +This document contains instructions for installing OwnTone from the git tree. If +you just want to install from a release tarball, you don't need the build tools +(git, autotools, autoconf, automake, gawk, gperf, gettext, bison and flex), and +you can skip the autoreconf step. + +The source for this version of OwnTone can be found here: +[owntone/owntone-server](https://github.com/owntone/owntone-server.git) + +## Quick version for Raspberry Pi OS + +See the instructions here: +[OwnTone server (iTunes server) - +Raspberry Pi Forums](http://www.raspberrypi.org/phpBB3/viewtopic.php?t=49928) + +## Quick version for Debian/Ubuntu users + +If you are the lucky kind, this should get you all the required tools and +libraries: + +```bash +sudo apt-get install \ + build-essential git autotools-dev autoconf automake libtool gettext gawk \ + gperf bison flex libconfuse-dev libunistring-dev libsqlite3-dev \ + libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev libavutil-dev \ + libasound2-dev libmxml-dev libgcrypt20-dev libavahi-client-dev zlib1g-dev \ + libevent-dev libplist-dev libsodium-dev libjson-c-dev libwebsockets-dev \ + libcurl4-openssl-dev libprotobuf-c-dev +``` + +Note that OwnTone will also work with other versions and flavours of +libgcrypt and libcurl, so the above are just suggestions. + +The following features require extra packages, and that you add a configure +argument when you run ./configure: + + Feature | Configure argument | Packages + ---------------------|--------------------------|------------------------------------- + Chromecast | `--enable-chromecast` | libgnutls*-dev + Legacy libspotify | `--enable-libspotify` | libspotify-dev + Pulseaudio | `--with-pulseaudio` | libpulse-dev + +These features can be disabled saving you package dependencies: + + Feature | Configure argument | Packages + ---------------------|--------------------------|------------------------------------- + Spotify (built-in) | `--disable-spotify` | libprotobuf-c-dev + Player web UI | `--disable-webinterface` | libwebsockets-dev + Live web UI | `--without-libwebsockets`| libwebsockets-dev + +Then run the following (adding configure arguments for optional features): + +```bash +git clone https://github.com/owntone/owntone-server.git +cd owntone-server +autoreconf -i +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-install-user +make +sudo make install +``` + +Using `--enable-install-user` means that `make install` will also add system +user and group for owntone. + +With the above configure arguments, a systemd service file will be installed to +`/etc/systemd/system/owntone.service` so that the server will start on boot. +Use `--disable-install-systemd` if you don't want that. + +Now edit `/etc/owntone.conf`. Note the guide at the top highlighting which +settings that normally require modification. + +Start the server with `sudo systemctl start owntone` and check that it is +running with `sudo systemctl status owntone`. + +See the [Documentation](documentation.md) for usage information. + +## Quick version for Fedora + +If you haven't already enabled the free RPM fusion packages do that, since you +will need ffmpeg. You can google how to do that. Then run: + +```bash +sudo yum install \ + git automake autoconf gettext-devel gperf gawk libtool bison flex \ + sqlite-devel libconfuse-devel libunistring-devel mxml-devel libevent-devel \ + avahi-devel libgcrypt-devel zlib-devel alsa-lib-devel ffmpeg-devel \ + libplist-devel libsodium-devel json-c-devel libwebsockets-devel \ + libcurl-devel protobuf-c-devel +``` + +Clone the OwnTone repo: + +```bash +git clone https://github.com/owntone/owntone-server.git +cd owntone-server +``` + +Then run the following: + +```bash +autoreconf -i +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-install-user +make +sudo make install +``` + +Using `--enable-install-user` means that `make install` will also add system +user and group for owntone. + +With the above configure arguments, a systemd service file will be installed to +`/etc/systemd/system/owntone.service` so that the server will start on boot. +Use `--disable-install-systemd` if you don't want that. + +Now edit `/etc/owntone.conf`. Note the guide at the top highlighting which +settings that normally require modification. + +Start the server with `sudo systemctl start owntone` and check that it is +running with `sudo systemctl status owntone`. + +See the [Documentation](documentation.md) for usage information. + +## Quick version for FreeBSD + +There is a script in the 'scripts' folder that will at least attempt to do all +the work for you. And should the script not work for you, you can still look +through it and use it as an installation guide. + +## Quick version for macOS (using Homebrew) + +This workflow file used for building OwnTone via Github actions includes +all the steps that you need to execute: +[.github/workflows/macos.yml](https://github.com/owntone/owntone-server/blob/master/.github/workflows/macos.yml) + +## "Quick" version for macOS (using macports) + +Caution: +1) this approach may be out of date, consider using the Homebrew method above +since it is continuously tested. +2) macports requires many downloads and lots of time to install (and sometimes +build) ports... you'll want a decent network connection and some patience! + +Install macports (which requires Xcode): + +```bash +sudo port install \ + autoconf automake libtool pkgconfig git gperf bison flex libgcrypt \ + libunistring libconfuse ffmpeg libevent json-c libwebsockets curl \ + libplist libsodium protobuf-c +``` + +Download, configure, build and install the Mini-XML library: + +Download, configure, build and install the libinotify library: + +Add the following to `.bashrc`: + +```bash +# add /usr/local to pkg-config path +export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig +# libunistring doesn't support pkg-config, set overrides +export LIBUNISTRING_CFLAGS=-I/opt/local/include +export LIBUNISTRING_LIBS="-L/opt/local/lib -lunistring" +``` + +Optional features require the following additional ports: + + Feature | Configure argument | Ports + --------------------|--------------------------|------------------- + Chromecast | `--enable-chromecast` | gnutls + Pulseaudio | `--with-pulseaudio` | pulseaudio + +Clone the OwnTone repo: + +```bash +git clone https://github.com/owntone/owntone-server.git +cd owntone-server +``` + +Finally, configure, build and install, adding configure arguments for +optional features: + +```bash +autoreconf -i +./configure +make +sudo make install +``` + +Note: if for some reason you've installed the avahi port, you need to +add `--without-avahi` to configure above. + +Edit `/usr/local/etc/owntone.conf` and change the `uid` to a nice +system daemon (eg: unknown), and run the following: + +```bash +sudo mkdir -p /usr/local/var/run +sudo mkdir -p /usr/local/var/log # or change logfile in conf +sudo chown unknown /usr/local/var/cache/owntone # or change conf +``` + +Run OwnTone: + +```bash +sudo /usr/local/sbin/owntone +``` + +Verify it's running (you need to Ctrl+C to stop +dns-sd): + +```bash +dns-sd -B _daap._tcp +``` + +## Long version - requirements + +Required tools: + +- autotools: autoconf 2.63+, automake 1.10+, libtool 2.2. Run `autoreconf -i` + at the top of the source tree to generate the build system. +- gettext: libunistring requires iconv and gettext provides the autotools + macro definitions for iconv. +- gperf +- bison 3.0+ (yacc is not sufficient) +- flex (lex is not sufficient) + +Libraries: + +- Avahi client libraries (avahi-client), 0.6.24 minimum + from +- sqlite3 3.5.0+ with unlock notify API enabled (read below) + from +- ffmpeg (libav) + from +- libconfuse + from +- libevent 2.0+ (best with 2.1.4+) + from +- MiniXML (aka mxml or libmxml) + from +- gcrypt 1.2.0+ + from +- zlib + from +- libunistring 0.9.3+ + from +- libjson-c + from +- libcurl + from +- libplist 0.16+ + from +- libsodium + from +- libprotobuf-c + from +- libasound (optional - ALSA local audio) + often already installed as part of your distro +- libpulse (optional - Pulseaudio local audio) + from +- libspotify (optional - Spotify support) + (deprecated by Spotify) +- libgnutls (optional - Chromecast support) + from +- libwebsockets 2.0.2+ (optional - websocket support) + from + +If using binary packages, remember that you need the development packages to +build OwnTone (usually named -dev or -devel). + +sqlite3 needs to be built with support for the unlock notify API; this isn't +always the case in binary packages, so you may need to rebuild sqlite3 to +enable the unlock notify API (you can check for the presence of the +sqlite3_unlock_notify symbol in the sqlite3 library). Refer to the sqlite3 +documentation, look for `SQLITE_ENABLE_UNLOCK_NOTIFY`. + +## Long version - building and installing + +Start by generating the build system by running `autoreconf -i`. This will +generate the configure script and `Makefile.in`. + +To display the configure options `run ./configure --help`. + +Support for Spotify is optional. Use `--disable-spotify` to disable this feature. +OwnTone supports two ways of integrating with Spotify: Using its own, built-in +integration layer (which is the default), or to use Spotify's deprecated +libspotify. To enable the latter, you must configure with `--enable-libspotify` +and also make sure libspotify's `libspotify/api.h` is installed at compile time. +At runtime, libspotify must be installed, and `use_libspotify` must be enabled +in owntone.conf. OwnTone uses runtime dynamic linking to the libspotify library, +so even though you compiled with `--enable-libspotify`, the executable will +still be able to run on systems without libspotify. If you only want libspotify +integration, you can use `--disable-spotify` and `--enable-libspotify`. + +Support for LastFM scrobbling is optional. Use `--enable-lastfm` to enable this +feature. + +Support for the MPD protocol is optional. Use `--disable-mpd` to disable this +feature. + +Support for Chromecast devices is optional. Use `--enable-chromecast` to enable +this feature. + +The player web interface is optional. Use `--disable-webinterface` to disable +this feature. +If enabled, `sudo make install` will install the prebuild html, js, css files. +The prebuild files are: + +- `htdocs/index.html` +- `htdocs/player/*` + +The source for the player web interface is located under the `web-src` folder and +requires nodejs >= 6.0 to be built. In the `web-src` folder run `npm install` to +install all dependencies for the player web interface. After that run `npm run build`. +This will build the web interface and update the `htdocs` folder. +(See [Web interface](web-interface.md) for more +informations) + +Building with libwebsockets is required if you want the web interface. It will be enabled +if the library is present (with headers). Use `--without-libwebsockets` to disable. + +Building with Pulseaudio is optional. It will be enabled if the library is +present (with headers). Use `--without-pulseaudio` to disable. + +Recommended build settings: + +```bash +./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-install-user +``` + +After configure run the usual make, and if that went well, `sudo make install`. + +With the above configure arguments, a systemd service file will be installed to +`/etc/systemd/system/owntone.service` so that the server will start on boot. +Use `--disable-install-systemd` if you don't want that. + +Using `--enable-install-user` means that `make install` will also add a system +user and group for owntone. + +After installation: + +- edit the configuration file, `/etc/owntone.conf` +- make sure the Avahi daemon is installed and running (Debian: + `apt install avahi-daemon`) + +OwnTone will drop privileges to any user you specify in the configuration file +if it's started as root. + +This user must have read permission to your library and read/write permissions +to the database location (`$localstatedir/cache/owntone` by default). + diff --git a/docs/json-api.md b/docs/json-api.md new file mode 100644 index 00000000..221d16a8 --- /dev/null +++ b/docs/json-api.md @@ -0,0 +1,2651 @@ +# OwnTone API Endpoint Reference + +Available API endpoints: + +* [Player](#player): control playback, volume, shuffle/repeat modes +* [Outputs / Speakers](#outputs-speakers): list available outputs and enable/disable outputs +* [Queue](#queue): list, add or modify the current queue +* [Library](#library): list playlists, artists, albums and tracks from your library or trigger library rescan +* [Search](#search): search for playlists, artists, albums and tracks +* [Server info](#server-info): get server information +* [Settings](#settings): list and change settings for the player web interface +* [Push notifications](#push-notifications): receive push notifications + +JSON-Object model: + +* [Queue item](#queue-item-object) +* [Playlist](#playlist-object) +* [Artist](#artist-object) +* [Album](#album-object) +* [Track](#track-object) + +## Player + +| Method | Endpoint | Description | +| --------- | ------------------------------------------------ | ------------------------------------ | +| GET | [/api/player](#get-player-status) | Get player status | +| PUT | [/api/player/play, /api/player/pause, /api/player/stop, /api/player/toggle](#control-playback) | Start, pause or stop playback | +| PUT | [/api/player/next, /api/player/previous](#skip-tracks) | Skip forward or backward | +| PUT | [/api/player/shuffle](#set-shuffle-mode) | Set shuffle mode | +| PUT | [/api/player/consume](#set-consume-mode) | Set consume mode | +| PUT | [/api/player/repeat](#set-repeat-mode) | Set repeat mode | +| PUT | [/api/player/volume](#set-volume) | Set master volume or volume for a specific output | +| PUT | [/api/player/seek](#seek) | Seek to a position in the currently playing track | + + + +### Get player status + +**Endpoint** + +```http +GET /api/player +``` + +**Response** + +| Key | Type | Value | +| ----------------- | -------- | ----------------------------------------- | +| state | string | `play`, `pause` or `stop` | +| repeat | string | `off`, `all` or `single` | +| consume | boolean | `true` if consume mode is enabled | +| shuffle | boolean | `true` if shuffle mode is enabled | +| volume | integer | Master volume in percent (0 - 100) | +| item_id | integer | The current playing queue item `id` | +| item_length_ms | integer | Total length in milliseconds of the current queue item | +| item_progress_ms | integer | Progress into the current queue item in milliseconds | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/player" +``` + +```json +{ + "state": "pause", + "repeat": "off", + "consume": false, + "shuffle": false, + "volume": 50, + "item_id": 269, + "item_length_ms": 278093, + "item_progress_ms": 3674 +} +``` + + +### Control playback + +Start or resume, pause, stop playback. + +**Endpoint** + +```http +PUT /api/player/play +``` + +```http +PUT /api/player/pause +``` + +```http +PUT /api/player/stop +``` + +```http +PUT /api/player/toggle +``` + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/player/play" +``` + +```shell +curl -X PUT "http://localhost:3689/api/player/pause" +``` + +```shell +curl -X PUT "http://localhost:3689/api/player/stop" +``` + +```shell +curl -X PUT "http://localhost:3689/api/player/toggle" +``` + + +### Skip tracks + +Skip forward or backward + +**Endpoint** + +```http +PUT /api/player/next +``` + +```http +PUT /api/player/previous +``` + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/player/next" +``` + +```shell +curl -X PUT "http://localhost:3689/api/player/previous" +``` + + +### Set shuffle mode + +Enable or disable shuffle mode + +**Endpoint** + +```http +PUT /api/player/shuffle +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| state | The new shuffle state, should be either `true` or `false` | + + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/player/shuffle?state=true" +``` + + +### Set consume mode + +Enable or disable consume mode + +**Endpoint** + +```http +PUT /api/player/consume +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| state | The new consume state, should be either `true` or `false` | + + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/player/consume?state=true" +``` + + +### Set repeat mode + +Change repeat mode + +**Endpoint** + +```http +PUT /api/player/repeat +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| state | The new repeat mode, should be either `off`, `all` or `single` | + + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/player/repeat?state=all" +``` + + +### Set volume + +Change master volume or volume of a specific output. + +**Endpoint** + +```http +PUT /api/player/volume +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| volume | The new volume (0 - 100) | +| step | The increase or decrease volume by the given amount (-100 - 100) | +| output_id | *(Optional)* If an output id is given, only the volume of this output will be changed. If parameter is omited, the master volume will be changed. | + +Either `volume` or `step` must be present as query parameter + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/player/volume?volume=50" +``` + +```shell +curl -X PUT "http://localhost:3689/api/player/volume?step=-5" +``` + +```shell +curl -X PUT "http://localhost:3689/api/player/volume?volume=50&output_id=0" +``` + + +### Seek + +Seek to a position in the currently playing track. + +**Endpoint** + +```http +PUT /api/player/seek +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| position_ms | The new position in milliseconds to seek to | +| seek_ms | A relative amount of milliseconds to seek to | + + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +Seek to position: + +```shell +curl -X PUT "http://localhost:3689/api/player/seek?position_ms=2000" +``` + +Relative seeking (skip 30 seconds backwards): + +```shell +curl -X PUT "http://localhost:3689/api/player/seek?seek_ms=-30000" +``` + + +## Outputs / Speakers + +| Method | Endpoint | Description | +| --------- | ------------------------------------------------ | ------------------------------------ | +| GET | [/api/outputs](#get-a-list-of-available-outputs) | Get a list of available outputs | +| PUT | [/api/outputs/set](#set-enabled-outputs) | Set enabled outputs | +| GET | [/api/outputs/{id}](#get-an-output) | Get an output | +| PUT | [/api/outputs/{id}](#change-an-output) | Change an output setting | +| PUT | [/api/outputs/{id}/toggle](#toggle-an-output) | Enable or disable an output, depending on the current state | + + + +### Get a list of available outputs + +**Endpoint** + +```http +GET /api/outputs +``` + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| outputs | array | Array of `output` objects | + +**`output` object** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| id | string | Output id | +| name | string | Output name | +| type | string | Type of the output: `AirPlay`, `Chromecast`, `ALSA`, `Pulseaudio`, `fifo` | +| selected | boolean | `true` if output is enabled | +| has_password | boolean | `true` if output is password protected | +| requires_auth | boolean | `true` if output requires authentication | +| needs_auth_key | boolean | `true` if output requires an authorization key (device verification) | +| volume | integer | Volume in percent (0 - 100) | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/outputs" +``` + +```json +{ + "outputs": [ + { + "id": "123456789012345", + "name": "kitchen", + "type": "AirPlay", + "selected": true, + "has_password": false, + "requires_auth": false, + "needs_auth_key": false, + "volume": 0 + }, + { + "id": "0", + "name": "Computer", + "type": "ALSA", + "selected": true, + "has_password": false, + "requires_auth": false, + "needs_auth_key": false, + "volume": 19 + }, + { + "id": "100", + "name": "daapd-fifo", + "type": "fifo", + "selected": false, + "has_password": false, + "requires_auth": false, + "needs_auth_key": false, + "volume": 0 + } + ] +} +``` + +### Set enabled outputs + +Set the enabled outputs by passing an array of output ids. The server enables all outputs +with the given ids and disables the remaining outputs. + +**Endpoint** + +```http +PUT /api/outputs/set +``` + +**Body parameters** + +| Parameter | Type | Value | +| --------------- | -------- | -------------------- | +| outputs | array | Array of output ids | + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/outputs/set" --data "{\"outputs\":[\"198018693182577\",\"0\"]}" +``` + + +### Get an output + +Get an output + +**Endpoint** + +```http +GET /api/outputs/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Output id | + +**Response** + +On success returns the HTTP `200 OK` success status response code. With the response body holding the **`output` object**. + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/outputs/0" +``` + +```json +{ + "id": "0", + "name": "Computer", + "type": "ALSA", + "selected": true, + "has_password": false, + "requires_auth": false, + "needs_auth_key": false, + "volume": 3 +} +``` + +### Change an output + +Enable or disable an output and change its volume. + +**Endpoint** + +```http +PUT /api/outputs/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Output id | + +**Body parameters** + +| Parameter | Type | Value | +| --------------- | --------- | -------------------- | +| selected | boolean | *(Optional)* `true` to enable and `false` to disable the output | +| volume | integer | *(Optional)* Volume in percent (0 - 100) | +| pin | string | *(Optional)* PIN for device verification | + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/outputs/0" --data "{\"selected\":true, \"volume\": 50}" +``` + +### Toggle an output + +Enable or disable an output, depending on its current state + +**Endpoint** + +```http +PUT /api/outputs/{id}/toggle +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Output id | + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/outputs/0/toggle" +``` + + + +## Queue + +| Method | Endpoint | Description | +| --------- | ----------------------------------------------------------- | ------------------------------------ | +| GET | [/api/queue](#list-queue-items) | Get a list of queue items | +| PUT | [/api/queue/clear](#clearing-the-queue) | Remove all items from the queue | +| POST | [/api/queue/items/add](#adding-items-to-the-queue) | Add items to the queue | +| PUT | [/api/queue/items/{id}\|now_playing](#updating-a-queue-item)| Updating a queue item in the queue | +| DELETE | [/api/queue/items/{id}](#removing-a-queue-item) | Remove a queue item from the queue | + + + +### List queue items + +Lists the items in the current queue + +**Endpoint** + +```http +GET /api/queue +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| id | *(Optional)* If a queue item id is given, only the item with the id will be returend. Use id=now_playing to get the currently playing item. | +| start | *(Optional)* If a `start`and an `end` position is given, only the items from `start` (included) to `end` (excluded) will be returned. If only a `start` position is given, only the item at this position will be returned. | +| end | *(Optional)* See `start` parameter | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| version | integer | Version number of the current queue | +| count | integer | Number of items in the current queue | +| items | array | Array of [`queue item`](#queue-item-object) objects | + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/queue" +``` + +```json +{ + "version": 833, + "count": 20, + "items": [ + { + "id": 12122, + "position": 0, + "track_id": 10749, + "title": "Angels", + "artist": "The xx", + "artist_sort": "xx, The", + "album": "Coexist", + "album_sort": "Coexist", + "albumartist": "The xx", + "albumartist_sort": "xx, The", + "genre": "Indie Rock", + "year": 2012, + "track_number": 1, + "disc_number": 1, + "length_ms": 171735, + "media_kind": "music", + "data_kind": "file", + "path": "/music/srv/The xx/Coexist/01 Angels.mp3", + "uri": "library:track:10749" + }, + ... + ] +} +``` + + +### Clearing the queue + +Remove all items form the current queue + +**Endpoint** + +```http +PUT /api/queue/clear +``` + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/queue/clear" +``` + + +### Adding items to the queue + +Add tracks, playlists artists or albums to the current queue + +**Endpoint** + +```http +POST /api/queue/items/add +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| uris | Comma seperated list of resource identifiers (`track`, `playlist`, `artist` or `album` object `uri`) | +| expression | A smart playlist query expression identifying the tracks that will be added to the queue. | +| position | *(Optional)* If a position is given, new items are inserted starting from this position into the queue. | +| playback | *(Optional)* If the `playback` parameter is set to `start`, playback will be started after adding the new items. | +| playback_from_position | *(Optional)* If the `playback` parameter is set to `start`, playback will be started with the queue item at the position given in `playback_from_position`. | +| clear | *(Optional)* If the `clear` parameter is set to `true`, the queue will be cleared before adding the new items. | +| shuffle | *(Optional)* If the `shuffle` parameter is set to `true`, the shuffle mode is activated. If it is set to something else, the shuffle mode is deactivated. To leave the shuffle mode untouched the parameter should be ommited. | +| limit | *(Optional)* Maximum number of tracks to add | + +Either the `uris` or the `expression` parameter must be set. If both are set the `uris` parameter takes presedence and the `expression` parameter will be ignored. + +**Response** + +On success returns the HTTP `200 OK` success status response code. + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| count | integer | number of tracks added to the queue | + + +**Example** + +Add new items by uri: + +```shell +curl -X POST "http://localhost:3689/api/queue/items/add?uris=library:playlist:68,library:artist:2932599850102967727" +``` + +```json +{ + "count": 42 +} +``` + +Add new items by query language: + +```shell +curl -X POST "http://localhost:3689/api/queue/items/add?expression=media_kind+is+music" +``` + +```json +{ + "count": 42 +} +``` + +Clear current queue, add 10 new random tracks of `genre` _Pop_ and start playback +``` +curl -X POST "http://localhost:3689/api/queue/items/add?limit=10&clear=true&playback=start&expression=genre+is+%22Pop%22+order+by+random+desc" +``` + +```json +{ + "count": 10 +} +``` + +### Updating a queue item + +Update or move a queue item in the current queue + +**Endpoint** + +```http +PUT /api/queue/items/{id} +``` +or +```http +PUT /api/queue/items/now_playing +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Queue item id | + +(or use now_playing to update the currenly playing track) + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| new_position | The new position for the queue item in the current queue. | +| title | New track title | +| album | New album title | +| artist | New artist | +| album_artist | New album artist | +| composer | New composer | +| genre | New genre | +| artwork_url | New URL to track artwork | + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/queue/items/3?new_position=0" +``` + +```shell +curl -X PUT "http://localhost:3689/api/queue/items/3?title=Awesome%20title&artwork_url=http%3A%2F%2Fgyfgafguf.dk%2Fimages%2Fpige3.jpg" +``` + +```shell +curl -X PUT "http://localhost:3689/api/queue/items/now_playing?title=Awesome%20title&artwork_url=http%3A%2F%2Fgyfgafguf.dk%2Fimages%2Fpige3.jpg" +``` + +### Removing a queue item + +Remove a queue item from the current queue + +**Endpoint** + +```http +DELETE /api/queue/items/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Queue item id | + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/queue/items/2" +``` + + + +## Library + +| Method | Endpoint | Description | +| --------- | ----------------------------------------------------------- | ------------------------------------ | +| GET | [/api/library](#library-information) | Get library information | +| GET | [/api/library/playlists](#list-playlists) | Get a list of playlists | +| GET | [/api/library/playlists/{id}](#get-a-playlist) | Get a playlist | +| PUT | [/api/library/playlists/{id}](#update-a-playlist) | Update a playlist attribute | +| DELETE | [/api/library/playlists/{id}](#delete-a-playlist) | Delete a playlist | +| GET | [/api/library/playlists/{id}/tracks](#list-playlist-tracks) | Get list of tracks for a playlist | +| PUT | [/api/library/playlists/{id}/tracks](#update-playlist-tracks) | Update play count of tracks for a playlist | +| GET | [/api/library/playlists/{id}/playlists](#list-playlists-in-a-playlist-folder) | Get list of playlists for a playlist folder | +| GET | [/api/library/artists](#list-artists) | Get a list of artists | +| GET | [/api/library/artists/{id}](#get-an-artist) | Get an artist | +| GET | [/api/library/artists/{id}/albums](#list-artist-albums) | Get list of albums for an artist | +| GET | [/api/library/albums](#list-albums) | Get a list of albums | +| GET | [/api/library/albums/{id}](#get-an-album) | Get an album | +| GET | [/api/library/albums/{id}/tracks](#list-album-tracks) | Get list of tracks for an album | +| GET | [/api/library/tracks/{id}](#get-a-track) | Get a track | +| GET | [/api/library/tracks/{id}/playlists](#list-playlists-for-a-track) | Get list of playlists for a track | +| PUT | [/api/library/tracks](#update-track-properties) | Update multiple track properties | +| PUT | [/api/library/tracks/{id}](#update-track-properties) | Update single track properties | +| GET | [/api/library/genres](#list-genres) | Get list of genres | +| GET | [/api/library/count](#get-count-of-tracks-artists-and-albums) | Get count of tracks, artists and albums | +| GET | [/api/library/files](#list-local-directories) | Get list of directories in the local library | +| POST | [/api/library/add](#add-an-item-to-the-library) | Add an item to the library | +| PUT | [/api/update](#trigger-rescan) | Trigger a library rescan | +| PUT | [/api/rescan](#trigger-metadata-rescan) | Trigger a library metadata rescan | +| PUT | [/api/library/backup](#backup-db) | Request library backup db | + + + +### Library information + +List some library stats + +**Endpoint** + +```http +GET /api/library +``` + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| songs | integer | Array of [`playlist`](#playlist-object) objects | +| db_playtime | integer | Total playtime of all songs in the library | +| artists | integer | Number of album artists in the library | +| albums | integer | Number of albums in the library | +| started_at | string | Server startup time (timestamp in `ISO 8601` format) | +| updated_at | string | Last library update (timestamp in `ISO 8601` format) | +| updating | boolean | `true` if library rescan is in progress | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library" +``` + +```json +{ + "songs": 217, + "db_playtime": 66811, + "artists": 9, + "albums": 19, + "started_at": "2018-11-19T19:06:08Z", + "updated_at": "2018-11-19T19:06:16Z", + "updating": false +} +``` + + +### List playlists + +Lists all playlists in your library (does not return playlist folders) + +**Endpoint** + +```http +GET /api/library/playlists +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first playlist to return | +| limit | *(Optional)* Maximum number of playlists to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`playlist`](#playlist-object) objects | +| total | integer | Total number of playlists in the library | +| offset | integer | Requested offset of the first playlist | +| limit | integer | Requested maximum number of playlists | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/playlists" +``` + +```json +{ + "items": [ + { + "id": 1, + "name": "radio", + "path": "/music/srv/radio.m3u", + "smart_playlist": false, + "uri": "library:playlist:1" + }, + ... + ], + "total": 20, + "offset": 0, + "limit": -1 +} +``` + + +### Get a playlist + +Get a specific playlists in your library + +**Endpoint** + +```http +GET /api/library/playlists/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Playlist id | + +**Response** + +On success returns the HTTP `200 OK` success status response code. With the response body holding the **[`playlist`](#playlist-object) object**. + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/playlists/1" +``` + +```json +{ + "id": 1, + "name": "radio", + "path": "/music/srv/radio.m3u", + "smart_playlist": false, + "uri": "library:playlist:1" +} +``` + + +### Update a playlist + +Update attributes of a specific playlists in your library + +**Endpoint** + +```http +PUT /api/library/playlists/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Playlist id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| query_limit | For RSS feeds, this sets how many podcasts to retrieve | + + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/library/playlists/25?query_limit=20" +``` + + +### Delete a playlist + +Delete a playlist, e.g. a RSS feed + +**Endpoint** + +```http +DELETE /api/library/playlists/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Playlist id | + +**Example** + +```shell +curl -X DELETE "http://localhost:3689/api/library/playlists/25" +``` + + +### List playlist tracks + +Lists the tracks in a playlists + +**Endpoint** + +```http +GET /api/library/playlists/{id}/tracks +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Playlist id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first track to return | +| limit | *(Optional)* Maximum number of tracks to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`track`](#track-object) objects | +| total | integer | Total number of tracks in the playlist | +| offset | integer | Requested offset of the first track | +| limit | integer | Requested maximum number of tracks | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/playlists/1/tracks" +``` + +```json +{ + "items": [ + { + "id": 10766, + "title": "Solange wir tanzen", + "artist": "Heinrich", + "artist_sort": "Heinrich", + "album": "Solange wir tanzen", + "album_sort": "Solange wir tanzen", + "albumartist": "Heinrich", + "albumartist_sort": "Heinrich", + "genre": "Electronica", + "year": 2014, + "track_number": 1, + "disc_number": 1, + "length_ms": 223085, + "play_count": 2, + "skip_count": 1, + "time_played": "2018-02-23T10:31:20Z", + "media_kind": "music", + "data_kind": "file", + "path": "/music/srv/Heinrich/Solange wir tanzen/01 Solange wir tanzen.mp3", + "uri": "library:track:10766" + }, + ... + ], + "total": 20, + "offset": 0, + "limit": -1 +} +``` + +### Update playlist tracks + +Updates the play count for tracks in a playlists + +**Endpoint** + +```http +PUT /api/library/playlists/{id}/tracks +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Playlist id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| play_count | Either `increment`, `played` or `reset`. `increment` will increment `play_count` and update `time_played`, `played` will be like `increment` but only where `play_count` is 0, `reset` will set `play_count` and `skip_count` to zero and delete `time_played` and `time_skipped` | + + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/library/playlists/1/tracks?play_count=played" +``` + +### List playlists in a playlist folder + +Lists the playlists in a playlist folder + +**Note**: The root playlist folder has `id` 0. + +**Endpoint** + +```http +GET /api/library/playlists/{id}/playlists +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Playlist id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first playlist to return | +| limit | *(Optional)* Maximum number of playlist to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ------------------------------------------------ | +| items | array | Array of [`playlist`](#playlist-object) objects | +| total | integer | Total number of playlists in the playlist folder | +| offset | integer | Requested offset of the first playlist | +| limit | integer | Requested maximum number of playlist | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/playlists/0/tracks" +``` + +```json +{ + "items": [ + { + "id": 11, + "name": "Spotify", + "path": "spotify:playlistfolder", + "parent_id": "0", + "smart_playlist": false, + "folder": true, + "uri": "library:playlist:11" + }, + { + "id": 8, + "name": "bytefm", + "path": "/srv/music/Playlists/bytefm.m3u", + "parent_id": "0", + "smart_playlist": false, + "folder": false, + "uri": "library:playlist:8" + } + ], + "total": 2, + "offset": 0, + "limit": -1 +} +``` + + +### List artists + +Lists the artists in your library + +**Endpoint** + +```http +GET /api/library/artists +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first artist to return | +| limit | *(Optional)* Maximum number of artists to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ------------------------------------------- | +| items | array | Array of [`artist`](#artist-object) objects | +| total | integer | Total number of artists in the library | +| offset | integer | Requested offset of the first artist | +| limit | integer | Requested maximum number of artists | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/artists" +``` + +```json +{ + "items": [ + { + "id": "3815427709949443149", + "name": "ABAY", + "name_sort": "ABAY", + "album_count": 1, + "track_count": 10, + "length_ms": 2951554, + "uri": "library:artist:3815427709949443149" + }, + ... + ], + "total": 20, + "offset": 0, + "limit": -1 +} +``` + + +### Get an artist + +Get a specific artist in your library + +**Endpoint** + +```http +GET /api/library/artists/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Artist id | + +**Response** + +On success returns the HTTP `200 OK` success status response code. With the response body holding the **[`artist`](#artist-object) object**. + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/artists/3815427709949443149" +``` + +```json +{ + "id": "3815427709949443149", + "name": "ABAY", + "name_sort": "ABAY", + "album_count": 1, + "track_count": 10, + "length_ms": 2951554, + "uri": "library:artist:3815427709949443149" +} +``` + + +### List artist albums + +Lists the albums of an artist + +**Endpoint** + +```http +GET /api/library/artists/{id}/albums +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Artist id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first album to return | +| limit | *(Optional)* Maximum number of albums to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`album`](#album-object) objects | +| total | integer | Total number of albums of this artist | +| offset | integer | Requested offset of the first album | +| limit | integer | Requested maximum number of albums | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/artists/32561671101664759/albums" +``` + +```json +{ + "items": [ + { + "id": "8009851123233197743", + "name": "Add Violence", + "name_sort": "Add Violence", + "artist": "Nine Inch Nails", + "artist_id": "32561671101664759", + "track_count": 5, + "length_ms": 1634961, + "uri": "library:album:8009851123233197743" + }, + ... + ], + "total": 20, + "offset": 0, + "limit": -1 +} +``` + + +### List albums + +Lists the albums in your library + +**Endpoint** + +```http +GET /api/library/albums +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first album to return | +| limit | *(Optional)* Maximum number of albums to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`album`](#album-object) objects | +| total | integer | Total number of albums in the library | +| offset | integer | Requested offset of the first albums | +| limit | integer | Requested maximum number of albums | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/albums" +``` + +```json +{ + "items": [ + { + "id": "8009851123233197743", + "name": "Add Violence", + "name_sort": "Add Violence", + "artist": "Nine Inch Nails", + "artist_id": "32561671101664759", + "track_count": 5, + "length_ms": 1634961, + "uri": "library:album:8009851123233197743" + }, + ... + ], + "total": 20, + "offset": 0, + "limit": -1 +} +``` + + +### Get an album + +Get a specific album in your library + +**Endpoint** + +```http +GET /api/library/albums/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Album id | + +**Response** + +On success returns the HTTP `200 OK` success status response code. With the response body holding the **[`album`](#album-object) object**. + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/albums/8009851123233197743" +``` + +```json +{ + "id": "8009851123233197743", + "name": "Add Violence", + "name_sort": "Add Violence", + "artist": "Nine Inch Nails", + "artist_id": "32561671101664759", + "track_count": 5, + "length_ms": 1634961, + "uri": "library:album:8009851123233197743" +} +``` + + +### List album tracks + +Lists the tracks in an album + +**Endpoint** + +```http +GET /api/library/albums/{id}/tracks +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Album id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first track to return | +| limit | *(Optional)* Maximum number of tracks to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`track`](#track-object) objects | +| total | integer | Total number of tracks | +| offset | integer | Requested offset of the first track | +| limit | integer | Requested maximum number of tracks | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/albums/1/tracks" +``` + +```json +{ + "items": [ + { + "id": 10766, + "title": "Solange wir tanzen", + "artist": "Heinrich", + "artist_sort": "Heinrich", + "album": "Solange wir tanzen", + "album_sort": "Solange wir tanzen", + "albumartist": "Heinrich", + "albumartist_sort": "Heinrich", + "genre": "Electronica", + "year": 2014, + "track_number": 1, + "disc_number": 1, + "length_ms": 223085, + "play_count": 2, + "last_time_played": "2018-02-23T10:31:20Z", + "media_kind": "music", + "data_kind": "file", + "path": "/music/srv/Heinrich/Solange wir tanzen/01 Solange wir tanzen.mp3", + "uri": "library:track:10766" + }, + ... + ], + "total": 20, + "offset": 0, + "limit": -1 +} +``` + + +### Get a track + +Get a specific track in your library + +**Endpoint** + +```http +GET /api/library/tracks/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Track id | + +**Response** + +On success returns the HTTP `200 OK` success status response code. With the response body holding the **[`track`](#track-object) object**. + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/track/1" +``` + +```json +{ + "id": 1, + "title": "Pardon Me", + "title_sort": "Pardon Me", + "artist": "Incubus", + "artist_sort": "Incubus", + "album": "Make Yourself", + "album_sort": "Make Yourself", + "album_id": "6683985628074308431", + "album_artist": "Incubus", + "album_artist_sort": "Incubus", + "album_artist_id": "4833612337650426236", + "composer": "Alex Katunich/Brandon Boyd/Chris Kilmore/Jose Antonio Pasillas II/Mike Einziger", + "genre": "Alternative Rock", + "year": 2001, + "track_number": 12, + "disc_number": 1, + "length_ms": 223170, + "rating": 0, + "usermark": 0, + "play_count": 0, + "skip_count": 0, + "time_added": "2019-01-20T11:58:29Z", + "date_released": "2001-05-27", + "seek_ms": 0, + "media_kind": "music", + "data_kind": "file", + "path": "/music/srv/Incubus/Make Yourself/12 Pardon Me.mp3", + "uri": "library:track:1", + "artwork_url": "/artwork/item/1" +} +``` + + +### List playlists for a track + +Get the list of playlists that contain a track (does not return smart playlists) + +**Endpoint** + +```http +GET /api/library/tracks/{id}/playlists +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Track id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| offset | *(Optional)* Offset of the first playlist to return | +| limit | *(Optional)* Maximum number of playlist to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`playlist`](#playlist-object) objects | +| total | integer | Total number of playlists | +| offset | integer | Requested offset of the first playlist | +| limit | integer | Requested maximum number of playlists | + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/tracks/27/playlists" +``` + +```json +{ + "items": [ + { + "id": 1, + "name": "playlist", + "path": "/music/srv/playlist.m3u", + "smart_playlist": false, + "uri": "library:playlist:1" + }, + ... + ], + "total": 2, + "offset": 0, + "limit": -1 +} +``` + + +### Update track properties + +Change properties of one or more tracks (supported properties are "rating", "play_count" and "usermark") + +**Endpoint** + +```http +PUT /api/library/tracks +``` + +**Body parameters** + +| Parameter | Type | Value | +| --------------- | -------- | ----------------------- | +| tracks | array | Array of track objects | + + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT -d '{ "tracks": [ { "id": 1, "rating": 100, "usermark": 4 }, { "id": 2, "usermark": 3 } ] }' "http://localhost:3689/api/library/tracks" +``` + +**Endpoint** + +```http +PUT /api/library/tracks/{id} +``` + +**Path parameters** + +| Parameter | Value | +| --------------- | -------------------- | +| id | Track id | + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| rating | The new rating (0 - 100) | +| play_count | Either `increment` or `reset`. `increment` will increment `play_count` and update `time_played`, `reset` will set `play_count` and `skip_count` to zero and delete `time_played` and `time_skipped` | +| usermark | The new usermark (>= 0) | + + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/library/tracks/1?rating=100" +``` + +```shell +curl -X PUT "http://localhost:3689/api/library/tracks/1?play_count=increment" +``` + + +### List genres + +Get list of genres + +**Endpoint** + +```http +GET /api/library/genres +``` +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`browse-info`](#browse-info-object) objects | +| total | integer | Total number of genres in the library | +| offset | integer | Requested offset of the first genre | +| limit | integer | Requested maximum number of genres | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/genres" +``` + +```json +{ + "items": [ + { + "name": "Classical" + }, + { + "name": "Drum & Bass" + }, + { + "name": "Pop" + }, + { + "name": "Rock/Pop" + }, + { + "name": "'90s Alternative" + } + ], + "total": 5, + "offset": 0, + "limit": -1 +} + +``` + +### List albums for genre + +Lists the albums in a genre + +**Endpoint** + +```http +GET api/search?type=albums&expression=genre+is+\"{genre name}\"" +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| genre | genre name (uri encoded and html esc seq for chars: '/&) | +| offset | *(Optional)* Offset of the first album to return | +| limit | *(Optional)* Maximum number of albums to return | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of [`album`](#album-object) objects | +| total | integer | Total number of albums in the library | +| offset | integer | Requested offset of the first albums | +| limit | integer | Requested maximum number of albums | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/search?type=albums&expression=genre+is+\"Pop\"" +curl -X GET "http://localhost:3689/api/search?type=albums&expression=genre+is+\"Rock%2FPop\"" # Rock/Pop +curl -X GET "http://localhost:3689/api/search?type=albums&expression=genre+is+\"Drum%20%26%20Bass\"" # Drum & Bass +curl -X GET "http://localhost:3689/api/search?type=albums&expression=genre+is+\"%2790s%20Alternative\"" # '90 Alternative +``` + +```json +{ + "albums": { + "items": [ + { + "id": "320189328729146437", + "name": "Best Ever", + "name_sort": "Best Ever", + "artist": "ABC", + "artist_id": "8760559201889050080", + "track_count": 1, + "length_ms": 3631, + "uri": "library:album:320189328729146437" + }, + { + "id": "7964595866631625723", + "name": "Greatest Hits", + "name_sort": "Greatest Hits", + "artist": "Marvin Gaye", + "artist_id": "5261930703203735930", + "track_count": 2, + "length_ms": 7262, + "uri": "library:album:7964595866631625723" + }, + { + "id": "3844610748145176456", + "name": "The Very Best of Etta", + "name_sort": "Very Best of Etta", + "artist": "Etta James", + "artist_id": "2627182178555864595", + "track_count": 1, + "length_ms": 177926, + "uri": "library:album:3844610748145176456" + } + ], + "total": 3, + "offset": 0, + "limit": -1 + } +} +``` + +### Get count of tracks, artists and albums + +Get information about the number of tracks, artists and albums and the total playtime + +**Endpoint** + +```http +GET /api/library/count +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| expression | *(Optional)* The smart playlist query expression, if this parameter is omitted returns the information for the whole library | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| tracks | integer | Number of tracks matching the expression | +| artists | integer | Number of artists matching the expression | +| albums | integer | Number of albums matching the expression | +| db_playtime | integer | Total playtime in milliseconds of all tracks matching the expression | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/count?expression=data_kind+is+file" +``` + +```json +{ + "tracks": 6811, + "artists": 355, + "albums": 646, + "db_playtime": 1590767 +} +``` + + +### List local directories + +List the local directories and the directory contents (tracks and playlists) + + +**Endpoint** + +```http +GET /api/library/files +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| directory | *(Optional)* A path to a directory in your local library. | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| directories | array | Array of [`directory`](#directory-object) objects containing the sub directories | +| tracks | object | [`paging`](#paging-object) object containing [`track`](#track-object) objects that matches the `directory` | +| playlists | object | [`paging`](#paging-object) object containing [`playlist`](#playlist-object) objects that matches the `directory` | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/library/files?directory=/music/srv" +``` + +```json +{ + "directories": [ + { + "path": "/music/srv/Audiobooks" + }, + { + "path": "/music/srv/Music" + }, + { + "path": "/music/srv/Playlists" + }, + { + "path": "/music/srv/Podcasts" + } + ], + "tracks": { + "items": [ + { + "id": 1, + "title": "input.pipe", + "artist": "Unknown artist", + "artist_sort": "Unknown artist", + "album": "Unknown album", + "album_sort": "Unknown album", + "album_id": "4201163758598356043", + "album_artist": "Unknown artist", + "album_artist_sort": "Unknown artist", + "album_artist_id": "4187901437947843388", + "genre": "Unknown genre", + "year": 0, + "track_number": 0, + "disc_number": 0, + "length_ms": 0, + "play_count": 0, + "skip_count": 0, + "time_added": "2018-11-24T08:41:35Z", + "seek_ms": 0, + "media_kind": "music", + "data_kind": "pipe", + "path": "/music/srv/input.pipe", + "uri": "library:track:1", + "artwork_url": "/artwork/item/1" + } + ], + "total": 1, + "offset": 0, + "limit": -1 + }, + "playlists": { + "items": [ + { + "id": 8, + "name": "radio", + "path": "/music/srv/radio.m3u", + "smart_playlist": true, + "uri": "library:playlist:8" + } + ], + "total": 1, + "offset": 0, + "limit": -1 + } +} +``` + + +### Trigger rescan + +Trigger a library rescan + +**Endpoint** + +```http +PUT /api/update +``` + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/update" +``` + +```json +{ + "songs": 217, + "db_playtime": 66811, + "artists": 9, + "albums": 19, + "started_at": "2018-11-19T19:06:08Z", + "updated_at": "2018-11-19T19:06:16Z", + "updating": false +} +``` + +### Trigger metadata rescan + +Trigger a library metadata rescan even if files have not been updated. Maintenence method. + +**Endpoint** + +```http +PUT /api/rescan +``` + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/rescan" +``` + +### Backup DB + +Request a library backup - configuration must be enabled and point to a valid writable path. Maintenance method. + +**Endpoint** + +```http +PUT /api/library/backup +``` + +**Response** + +On success returns the HTTP `200 OK` success status response code. +If backups are not enabled returns HTTP `503 Service Unavailable` response code. +Otherwise a HTTP `500 Internal Server Error` response is returned. + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/library/backup" +``` + +## Search + +| Method | Endpoint | Description | +| --------- | ----------------------------------------------------------- | ------------------------------------ | +| GET | [/api/search](#search-by-search-term) | Search for playlists, artists, albums, tracks,genres by a simple search term | +| GET | [/api/search](#search-by-query-language) | Search by complex query expression | + + + +### Search by search term + +Search for playlists, artists, albums, tracks, genres that include the given query in their title (case insensitive matching). + +**Endpoint** + +```http +GET /api/search +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| query | The search keyword | +| type | Comma separated list of the result types (`playlist`, `artist`, `album`, `track`, `genre`) | +| media_kind | *(Optional)* Filter results by media kind (`music`, `movie`, `podcast`, `audiobook`, `musicvideo`, `tvshow`). Filter only applies to artist, album and track result types. | +| offset | *(Optional)* Offset of the first item to return for each type | +| limit | *(Optional)* Maximum number of items to return for each type | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| tracks | object | [`paging`](#paging-object) object containing [`track`](#track-object) objects that matches the `query` | +| artists | object | [`paging`](#paging-object) object containing [`artist`](#artist-object) objects that matches the `query` | +| albums | object | [`paging`](#paging-object) object containing [`album`](#album-object) objects that matches the `query` | +| playlists | object | [`paging`](#paging-object) object containing [`playlist`](#playlist-object) objects that matches the `query` | + + +**Example** + +Search for all tracks, artists, albums and playlists that contain "the" in their title and return the first two results for each type: + +```shell +curl -X GET "http://localhost:3689/api/search?type=tracks,artists,albums,playlists&query=the&offset=0&limit=2" +``` + +```json +{ + "tracks": { + "items": [ + { + "id": 35, + "title": "Another Love", + "artist": "Tom Odell", + "artist_sort": "Tom Odell", + "album": "Es is was es is", + "album_sort": "Es is was es is", + "album_id": "6494853621007413058", + "album_artist": "Various artists", + "album_artist_sort": "Various artists", + "album_artist_id": "8395563705718003786", + "genre": "Singer/Songwriter", + "year": 2013, + "track_number": 7, + "disc_number": 1, + "length_ms": 251030, + "play_count": 0, + "media_kind": "music", + "data_kind": "file", + "path": "/music/srv/Compilations/Es is was es is/07 Another Love.m4a", + "uri": "library:track:35" + }, + { + "id": 215, + "title": "Away From the Sun", + "artist": "3 Doors Down", + "artist_sort": "3 Doors Down", + "album": "Away From the Sun", + "album_sort": "Away From the Sun", + "album_id": "8264078270267374619", + "album_artist": "3 Doors Down", + "album_artist_sort": "3 Doors Down", + "album_artist_id": "5030128490104968038", + "genre": "Rock", + "year": 2002, + "track_number": 2, + "disc_number": 1, + "length_ms": 233278, + "play_count": 0, + "media_kind": "music", + "data_kind": "file", + "path": "/music/srv/Away From the Sun/02 Away From the Sun.mp3", + "uri": "library:track:215" + } + ], + "total": 14, + "offset": 0, + "limit": 2 + }, + "artists": { + "items": [ + { + "id": "8737690491750445895", + "name": "The xx", + "name_sort": "xx, The", + "album_count": 2, + "track_count": 25, + "length_ms": 5229196, + "uri": "library:artist:8737690491750445895" + } + ], + "total": 1, + "offset": 0, + "limit": 2 + }, + "albums": { + "items": [ + { + "id": "8264078270267374619", + "name": "Away From the Sun", + "name_sort": "Away From the Sun", + "artist": "3 Doors Down", + "artist_id": "5030128490104968038", + "track_count": 12, + "length_ms": 2818174, + "uri": "library:album:8264078270267374619" + }, + { + "id": "6835720495312674468", + "name": "The Better Life", + "name_sort": "Better Life", + "artist": "3 Doors Down", + "artist_id": "5030128490104968038", + "track_count": 11, + "length_ms": 2393332, + "uri": "library:album:6835720495312674468" + } + ], + "total": 3, + "offset": 0, + "limit": 2 + }, + "playlists": { + "items": [], + "total": 0, + "offset": 0, + "limit": 2 + } +} +``` + +### Search by query language + +Search for artists, albums, tracks by a smart playlist query expression (see [README_SMARTPL.md](https://github.com/owntone/owntone-server/blob/master/README_SMARTPL.md) for the expression syntax). + +**Endpoint** + +```http +GET /api/search +``` + +**Query parameters** + +| Parameter | Value | +| --------------- | ----------------------------------------------------------- | +| expression | The smart playlist query expression | +| type | Comma separated list of the result types (`artist`, `album`, `track` | +| offset | *(Optional)* Offset of the first item to return for each type | +| limit | *(Optional)* Maximum number of items to return for each type | + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| tracks | object | [`paging`](#paging-object) object containing [`track`](#track-object) objects that matches the `query` | +| artists | object | [`paging`](#paging-object) object containing [`artist`](#artist-object) objects that matches the `query` | +| albums | object | [`paging`](#paging-object) object containing [`album`](#album-object) objects that matches the `query` | + + +**Example** + +Search for music tracks ordered descending by the time added to the library and limit result to 2 items: + +```shell +curl -X GET "http://localhost:3689/api/search?type=tracks&expression=media_kind+is+music+order+by+time_added+desc&offset=0&limit=2" +``` + + +## Server info + +| Method | Endpoint | Description | +| --------- | ------------------------------------------------ | ------------------------------------ | +| GET | [/api/config](#config) | Get configuration information | + + + +### Config + +**Endpoint** + +```http +GET /api/config +``` + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| version | string | Server version | +| websocket_port | integer | Port number for the [websocket](#push-notifications) (or `0` if websocket is disabled) | +| buildoptions | array | Array of strings indicating which features are supported by the server | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/config" +``` + +```json +{ + "websocket_port": 3688, + "version": "25.0", + "buildoptions": [ + "ffmpeg", + "iTunes XML", + "Spotify", + "LastFM", + "MPD", + "Device verification", + "Websockets", + "ALSA" + ] +} +``` + + +## Settings + +| Method | Endpoint | Description | +| --------- | ------------------------------------------------ | ------------------------------------ | +| GET | [/api/settings](#list-categories) | Get all available categories | +| GET | [/api/settings/{category-name}](#get-a-category) | Get all available options for a category | +| GET | [/api/settings/{category-name}/{option-name}](#get-an-option) | Get a single setting option | +| PUT | [/api/settings/{category-name}/{option-name}](#change-an-option-value) | Change the value of a setting option | +| DELETE | [/api/settings/{category-name}/{option-name}](#delete-an-option) | Reset a setting option to its default | + + + +### List categories + +List all settings categories with their options + +**Endpoint** + +```http +GET /api/settings +``` + +**Response** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| categories | array | Array of settings [category](#category-object) objects | + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/settings" +``` + +```json +{ + "categories": [ + { + "name": "webinterface", + "options": [ + { + "name": "show_composer_now_playing", + "type": 1, + "value": true + }, + { + "name": "show_composer_for_genre", + "type": 2, + "value": "classical" + } + ] + } + ] +} +``` + + +### Get a category + +Get a settings category with their options + +**Endpoint** + +```http +GET /api/settings/{category-name} +``` + +**Response** + +Returns a settings [category](#category-object) object + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/settings/webinterface" +``` + +```json +{ + "name": "webinterface", + "options": [ + { + "name": "show_composer_now_playing", + "type": 1, + "value": true + }, + { + "name": "show_composer_for_genre", + "type": 2, + "value": "classical" + } + ] +} +``` + + +### Get an option + +Get a single settings option + +**Endpoint** + +```http +GET /api/settings/{category-name}/{option-name} +``` + +**Response** + +Returns a settings [option](#option-object) object + + +**Example** + +```shell +curl -X GET "http://localhost:3689/api/settings/webinterface/show_composer_now_playing" +``` + +```json +{ + "name": "show_composer_now_playing", + "type": 1, + "value": true +} +``` + + +### Change an option value + +Get a single settings option + +**Endpoint** + +```http +PUT /api/settings/{category-name}/{option-name} +``` + +**Request** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| name | string | Option name | +| value | (integer / boolean / string) | New option value | + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + + +**Example** + +```shell +curl -X PUT "http://localhost:3689/api/settings/webinterface/show_composer_now_playing" --data "{\"name\":\"show_composer_now_playing\",\"value\":true}" +``` + + +### Delete an option + +Delete a single settings option (thus resetting it to default) + +**Endpoint** + +```http +DELETE /api/settings/{category-name}/{option-name} +``` + +**Response** + +On success returns the HTTP `204 No Content` success status response code. + + +**Example** + +```shell +curl -X DELETE "http://localhost:3689/api/settings/webinterface/show_composer_now_playing" +``` + + +## Push notifications + +If the server was built with websocket support it exposes a websocket at `localhost:3688` to inform clients of changes (e. g. player state or library updates). +The port depends on the server configuration and can be read using the [`/api/config`](#config) endpoint. + +After connecting to the websocket, the client should send a message containing the event types it is interested in. After that the server +will send a message each time one of the events occurred. + +**Message** + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| notify | array | Array of event types | + +**Event types** + +| Type | Description | +| --------------- | ----------------------------------------- | +| update | Library update started or finished | +| database | Library database changed (new/modified/deleted tracks) | +| outputs | An output was enabled or disabled | +| player | Player state changes | +| options | Playback option changes (shuffle, repeat, consume mode) | +| volume | Volume changes | +| queue | Queue changes | + +**Example** + +```shell +curl --include \ + --no-buffer \ + --header "Connection: Upgrade" \ + --header "Upgrade: websocket" \ + --header "Host: localhost:3688" \ + --header "Origin: http://localhost:3688" \ + --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ + --header "Sec-WebSocket-Version: 13" \ + --header "Sec-WebSocket-Protocol: notify" \ + http://localhost:3688/ \ + --data "{ \"notify\": [ \"player\" ] }" +``` + +```json +{ + "notify": [ + "player" + ] +} +``` + + +## Object model + + +### `queue item` object + +| Key | Type | Value | +| ------------------ | -------- | ----------------------------------------- | +| id | string | Item id | +| position | integer | Position in the queue (starting with zero) | +| track_id | string | Track id | +| title | string | Title | +| artist | string | Track artist name | +| artist_sort | string | Track artist sort name | +| album | string | Album name | +| album_sort | string | Album sort name | +| album_id | string | Album id | +| album_artist | string | Album artist name | +| album_artist_sort | string | Album artist sort name | +| album_artist_id | string | Album artist id | +| composer | string | Composer (optional) | +| genre | string | Genre | +| year | integer | Release year | +| track_number | integer | Track number | +| disc_number | integer | Disc number | +| length_ms | integer | Track length in milliseconds | +| media_kind | string | Media type of this track: `music`, `movie`, `podcast`, `audiobook`, `musicvideo`, `tvshow` | +| data_kind | string | Data type of this track: `file`, `url`, `spotify`, `pipe` | +| path | string | Path | +| uri | string | Resource identifier | +| artwork_url | string | *(optional)* [Artwork url](#artwork-urls) | +| type | string | file (codec) type (ie mp3/flac/...) | +| bitrate | string | file bitrate (ie 192/128/...) | +| samplerate | string | file sample rate (ie 44100/48000/...) | +| channel | string | file channel (ie mono/stereo/xx ch)) | + + +### `playlist` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| id | string | Playlist id | +| name | string | Playlist name | +| path | string | Path | +| parent_id | integer | Playlist id of the parent (folder) playlist | +| type | string | Type of this playlist: `special`, `folder`, `smart`, `plain` | +| smart_playlist | boolean | `true` if playlist is a smart playlist | +| folder | boolean | `true` if it is a playlist folder | +| uri | string | Resource identifier | + + +### `artist` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| id | string | Artist id | +| name | string | Artist name | +| name_sort | string | Artist sort name | +| album_count | integer | Number of albums | +| track_count | integer | Number of tracks | +| length_ms | integer | Total length of tracks in milliseconds | +| uri | string | Resource identifier | +| artwork_url | string | *(optional)* [Artwork url](#artwork-urls) | + + +### `album` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| id | string | Album id | +| name | string | Album name | +| name_sort | string | Album sort name | +| artist_id | string | Album artist id | +| artist | string | Album artist name | +| track_count | integer | Number of tracks | +| length_ms | integer | Total length of tracks in milliseconds | +| uri | string | Resource identifier | +| artwork_url | string | *(optional)* [Artwork url](#artwork-urls) | + + +### `track` object + +| Key | Type | Value | +| ------------------ | -------- | ----------------------------------------- | +| id | integer | Track id | +| title | string | Title | +| title_sort | string | Sort title | +| artist | string | Track artist name | +| artist_sort | string | Track artist sort name | +| album | string | Album name | +| album_sort | string | Album sort name | +| album_id | string | Album id | +| album_artist | string | Album artist name | +| album_artist_sort | string | Album artist sort name | +| album_artist_id | string | Album artist id | +| composer | string | Track composer | +| genre | string | Genre | +| comment | string | Comment | +| year | integer | Release year | +| track_number | integer | Track number | +| disc_number | integer | Disc number | +| length_ms | integer | Track length in milliseconds | +| rating | integer | Track rating (ranges from 0 to 100) | +| play_count | integer | How many times the track was played | +| skip_count | integer | How many times the track was skipped | +| time_played | string | Timestamp in `ISO 8601` format | +| time_skipped | string | Timestamp in `ISO 8601` format | +| time_added | string | Timestamp in `ISO 8601` format | +| date_released | string | Date in the format `yyyy-mm-dd` | +| seek_ms | integer | Resume point in milliseconds (available only for podcasts and audiobooks) | +| media_kind | string | Media type of this track: `music`, `movie`, `podcast`, `audiobook`, `musicvideo`, `tvshow` | +| data_kind | string | Data type of this track: `file`, `url`, `spotify`, `pipe` | +| path | string | Path | +| uri | string | Resource identifier | +| artwork_url | string | *(optional)* [Artwork url](#artwork-urls) | +| usermark | integer | User review marking of track (ranges from 0) | + + +### `paging` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| items | array | Array of result objects | +| total | integer | Total number of items | +| offset | integer | Requested offset of the first item | +| limit | integer | Requested maximum number of items | + + +### `browse-info` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| name | string | Name (depends on the type of the query) | +| name_sort | string | Sort name | +| artist_count | integer | Number of artists | +| album_count | integer | Number of albums | +| track_count | integer | Number of tracks | +| time_played | string | Timestamp in `ISO 8601` format | +| time_added | string | Timestamp in `ISO 8601` format | + + +### `directory` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| path | string | Directory path | + + +### `category` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| name | string | Category name | +| options | array | Array of option in this category | + + +### `option` object + +| Key | Type | Value | +| --------------- | -------- | ----------------------------------------- | +| name | string | Option name | +| type | integer | The type of the value for this option (`0`: integer, `1`: boolean, `2`: string) | +| value | (integer / boolean / string) | Current value for this option | + + +### Artwork urls + +Artwork urls in `queue item`, `artist`, `album` and `track` objects can be either relative urls or absolute urls to the artwork image. +Absolute artwork urls are pointing to external artwork images (e. g. for radio streams that provide artwork metadata), while relative artwork urls are served from the server. + +It is possible to add the query parameters `maxwidth` and/or `maxheight` to relative artwork urls, in order to get a smaller image (the server only scales down never up). + +Note that even if a relative artwork url attribute is present, it is not guaranteed to exist. diff --git a/docs/outputs-alsa.md b/docs/outputs-alsa.md new file mode 100644 index 00000000..fb8e5611 --- /dev/null +++ b/docs/outputs-alsa.md @@ -0,0 +1,489 @@ +# OwnTone and ALSA + +ALSA is one of the main output configuration options for local audio; when using ALSA you will typically let the system select the soundcard on your machine as the `default` device/sound card - a mixer associated with the ALSA device is used for volume control. However if your machine has multiple sound cards and your system chooses the wrong playback device, you will need to manually select the card and mixer to complete the OwnTone configuration. + +## Quick introduction to ALSA devices + +ALSA devices can be addressed in a number ways but traditionally we have referred to them using the hardware prefix, card number and optionally device number with something like `hw:0` or `hw:0,1`. In ALSA configuration terms `card X, device Y` is known as `hw:X,Y`. + +ALSA has other _prefixes_ for each card and most importantly `plughw`. The `plughw` performs transparent sample format and sample rate conversions and maybe a better choice for many users rather than `hw:` which would fail when provided unsupported audio formats/sample rates. + +Alternative ALSA names can be used to refer to physical ALSA devices and can be useful in a number of ways: + +* more descriptive rather than being a card number +* consistent for USB numeration - USB ALSA devices may not have the same card number across reboots/reconnects + +The ALSA device information required for configuration the server can be deterined using `aplay`, as described in the rest of this document, but OwnTone can also assist; when configured to log at `INFO` level the following information is provided during startup: + +``` +laudio: Available ALSA playback mixer(s) on hw:0 CARD=Intel (HDA Intel): 'Master' 'Headphone' 'Speaker' 'PCM' 'Mic' 'Beep' +laudio: Available ALSA playback mixer(s) on hw:1 CARD=E30 (E30): 'E30 ' +laudio: Available ALSA playback mixer(s) on hw:2 CARD=Seri (Plantronics Blackwire 3210 Seri): 'Sidetone' 'Headset' +``` +The `CARD=` string is the alternate ALSA name for the device and can be used in place of the traditional `hw:x` name. + +On this machine the server reports that it can see the onboard HDA Intel sound card and two additional sound cards: a Topping E30 DAC and a Plantronics Headset which are both USB devices. We can address the first ALSA device as `hw:0` or `hw:CARD=Intel` or `hw:Intel` or `plughw:Intel`, the second ALSA device as `hw:1` or `hw:E30` and so forth. The latter 2 devices being on USB will mean that `hw:1` may not always refer to `hw:E30` and thus in such a case using the alternate name is useful. + +## Configuring the server + +OwnTone can support a single ALSA device or multiple ALSA devices. + +``` +# example audio section for server for a single soundcard +audio { + nickname = "Computer" + type = "alsa" + + card = "hw:1" # defaults to 'default' + mixer = "Analogue" # defaults to 'PCM' or 'Master' + mixer_device = "hw:1" # defaults to same as 'card' value +} +``` + +Multiple devices can be made available to OwnTone using seperate `alsa { .. }` sections. + +``` +audio { + type = "alsa" +} + +alsa "hw:1" { + nickname = "Computer" + mixer = "Analogue" + mixer_device = "hw:1" +} + +alsa "hw:2" { + nickname = "Second ALSA device" +} +``` + +NB: When introducing `alsa { .. }` section(s) the ALSA specific configuration in the `audio { .. }` section will be ignored. + +If there is only one sound card, verify if the `default` sound device is correct for playback, we will use the `aplay` utility. + +``` +# generate some audio if you don't have a wav file to hand +$ sox -n -c 2 -r 44100 -b 16 -C 128 /tmp/sine441.wav synth 30 sin 500-100 fade h 0.2 30 0.2 + +$ aplay -Ddefault /tmp/sine441.wav +``` + +If you can hear music played then you are good to use `default` for the server configuration. If you can not hear anything from the `aplay` firstly verify (using `alsamixer`) that the sound card is not muted. If the card is not muted AND there is no sound you can try the options below to determine the card and mixer for configuring the server. + +## Automatically Determine ALL relevant the sound card information + +As shown above, OwnTone can help, consider the information that logged: + +``` +laudio: Available ALSA playback mixer(s) on hw:0 CARD=Intel (HDA Intel): 'Master' 'Headphone' 'Speaker' 'PCM' 'Mic' 'Beep' +laudio: Available ALSA playback mixer(s) on hw:1 CARD=E30 (E30): 'E30 ' +laudio: Available ALSA playback mixer(s) on hw:2 CARD=Seri (Plantronics Blackwire 3210 Seri): 'Sidetone' 'Headset' +``` + +Using the information above, we can see 3 soundcards that we could use with OwnTone with the first soundcard having a number of seperate mixer devices (volume control) for headphone and the interal speakers - we'll configure the server to use both these and also the E30 device. The server configuration for theese multiple outputs would be: + +``` +# using ALSA device alias where possible + +alsa "hw:Intel" { + nickname = "Computer - Speaker" + mixer = "Speaker" +} + +alsa "hw:Intel" { + nickname = "Computer - Headphones" + mixer = "Headphone" +} + +alsa "plughw:E30" { + # this E30 device only support S32_LE so we can use the 'plughw' prefix to + # add transparent conversion support of more common S16/S24_LE formats + + nickname = "E30 DAC" + mixer = "E30 " + mixer_device = "hw:E30" +} +``` + +NB: it is troublesome to use `hw` or `plughw` ALSA addressing when running OwnTone on a machine with `pulseaudio` and if you wish to use refer to ALSA devices directly that you stop `pulseaudio`. + +## Manually Determining the sound cards you have / ALSA can see +The example below is how I determined the correct sound card and mixer values for a Raspberry Pi that has an additional DAC card (hat) mounted. Of course using the log output from the server would have given the same results. + +Use `aplay -l` to list all the sound cards and their order as known to the system - you can have multiple `card X, device Y` entries; some cards can also have multiple playback devices such as the RPI's onboard soundcard which feeds both headphone (card 0, device 0) and HDMI (card 0, device 1). + +``` +$ aplay -l +**** List of PLAYBACK Hardware Devices **** +card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA] + Subdevices: 6/7 + Subdevice #0: subdevice #0 + Subdevice #1: subdevice #1 + Subdevice #2: subdevice #2 + Subdevice #3: subdevice #3 + Subdevice #4: subdevice #4 + Subdevice #5: subdevice #5 + Subdevice #6: subdevice #6 +card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI] + Subdevices: 1/1 + Subdevice #0: subdevice #0 +card 1: IQaudIODAC [IQaudIODAC], device 0: IQaudIO DAC HiFi pcm512x-hifi-0 [] + Subdevices: 1/1 + Subdevice #0: subdevice #0 +``` + +On this machine we see the second sound card installed, an IQaudIODAC dac hat, and identified as `card 1 device 0`. This is the playback device we want to be used by the server. + +`hw:1,0` is the IQaudIODAC that we want to use - we verify audiable playback through that sound card using `aplay -Dhw:1 /tmp/sine441.wav`. If the card has only one device, we can simply refer to the sound card using `hw:X` so in this case where the IQaudIODAC only has one device, we can refer to this card as `hw:1` or `hw:1,0`. + +Use `aplay -L` to get more information about the PCM devices defined on the system. + +``` +$ aplay -L +null + Discard all samples (playback) or generate zero samples (capture) +default:CARD=ALSA + bcm2835 ALSA, bcm2835 ALSA + Default Audio Device +sysdefault:CARD=ALSA + bcm2835 ALSA, bcm2835 ALSA + Default Audio Device +dmix:CARD=ALSA,DEV=0 + bcm2835 ALSA, bcm2835 ALSA + Direct sample mixing device +dmix:CARD=ALSA,DEV=1 + bcm2835 ALSA, bcm2835 IEC958/HDMI + Direct sample mixing device +dsnoop:CARD=ALSA,DEV=0 + bcm2835 ALSA, bcm2835 ALSA + Direct sample snooping device +dsnoop:CARD=ALSA,DEV=1 + bcm2835 ALSA, bcm2835 IEC958/HDMI + Direct sample snooping device +hw:CARD=ALSA,DEV=0 + bcm2835 ALSA, bcm2835 ALSA + Direct hardware device without any conversions +hw:CARD=ALSA,DEV=1 + bcm2835 ALSA, bcm2835 IEC958/HDMI + Direct hardware device without any conversions +plughw:CARD=ALSA,DEV=0 + bcm2835 ALSA, bcm2835 ALSA + Hardware device with all software conversions +plughw:CARD=ALSA,DEV=1 + bcm2835 ALSA, bcm2835 IEC958/HDMI + Hardware device with all software conversions +default:CARD=IQaudIODAC + IQaudIODAC, + Default Audio Device +sysdefault:CARD=IQaudIODAC + IQaudIODAC, + Default Audio Device +dmix:CARD=IQaudIODAC,DEV=0 + IQaudIODAC, + Direct sample mixing device +dsnoop:CARD=IQaudIODAC,DEV=0 + IQaudIODAC, + Direct sample snooping device +hw:CARD=IQaudIODAC,DEV=0 + IQaudIODAC, + Direct hardware device without any conversions +plughw:CARD=IQaudIODAC,DEV=0 + IQaudIODAC, + Hardware device with all software conversions +``` + +For the server configuration, we will use: + +``` +audio { + nickname = "Computer" + type = "alsa" + card="hw:1" + # mixer=TBD + # mixer_device=TBD +} +``` + +## Mixer name + +Once you have the card number (determined from `aplay -l`) we can inspect/confirm the name of the mixer that can be used for playback (it may NOT be `PCM` as expected by the server). In this example, the card `1` is of interest and thus we use `-c 1` with the following command: + +``` +$ amixer -c 1 +Simple mixer control 'DSP Program',0 + Capabilities: enum + Items: 'FIR interpolation with de-emphasis' 'Low latency IIR with de-emphasis' 'High attenuation with de-emphasis' 'Fixed process flow' 'Ringing-less low latency FIR' + Item0: 'Ringing-less low latency FIR' +Simple mixer control 'Analogue',0 + Capabilities: pvolume + Playback channels: Front Left - Front Right + Limits: Playback 0 - 1 + Mono: + Front Left: Playback 1 [100%] [0.00dB] + Front Right: Playback 1 [100%] [0.00dB] +Simple mixer control 'Analogue Playback Boost',0 + Capabilities: volume + Playback channels: Front Left - Front Right + Capture channels: Front Left - Front Right + Limits: 0 - 1 + Front Left: 0 [0%] [0.00dB] + Front Right: 0 [0%] [0.00dB] +... +``` + +This card has multiple controls but we want to find a mixer control listed with a `pvolume` (playback) capability - in this case that mixer value required for the server configuration is called `Analogue`. + +For the server configuration, we will use: + +``` +audio { + nickname = "Computer" + type = "alsa" + card="hw:1" + mixer="Analogue" + # mixer_device=TBD +} +``` + +## Mixer device + +This is the name of the underlying physical device used for the mixer - it is typically the same value as the value of `card` in which case a value is not required by the server configuration. An example of when you want to change explicitly configure this is if you need to use a `dmix` device (see below). + + +## Handling Devices that cannot concurrently play multiple audio streams + +Some devices such as various RPI DAC boards (IQaudio DAC, Allo Boss DAC...) cannot have multiple streams openned at the same time/cannot play multiple sound files at the same time. This results in `Device or resource busy` errors. You can confirm if your sound card has this problem by using the example below once have determined the names/cards information as above. + +Using our `hw:1` device we try: + +``` +# generate some audio +$ sox -n -c 2 -r 44100 -b 16 -C 128 /tmp/sine441.wav synth 30 sin 500-100 fade h 0.2 30 0.2 + +# attempt to play 2 files at the same time +$ aplay -v -Dhw:1 /tmp/sine441.wav & +Playing WAVE '/tmp/sine441.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo +Hardware PCM card 1 'IQaudIODAC' device 0 subdevice 0 +Its setup is: + stream : PLAYBACK + access : RW_INTERLEAVED + format : S16_LE + subformat : STD + channels : 2 + rate : 44100 + exact rate : 44100 (44100/1) + msbits : 16 + buffer_size : 22052 + period_size : 5513 + period_time : 125011 + tstamp_mode : NONE + tstamp_type : MONOTONIC + period_step : 1 + avail_min : 5513 + period_event : 0 + start_threshold : 22052 + stop_threshold : 22052 + silence_threshold: 0 + silence_size : 0 + boundary : 1445199872 + appl_ptr : 0 + hw_ptr : 0 +$ aplay -v -Dhw:1 /tmp/sine441.wav +aplay: main:788: audio open error: Device or resource busy +``` + +In this instance this device cannot open multiple streams - OwnTone can handle this situation transparently with some audio being truncated from the end of the current file as the server prepares to play the following track. If this handling is causing you problems you may wish to use [ALSA's `dmix` functionally](https://www.alsa-project.org/main/index.php/Asoundrc#Software_mixing) which provides a software mixing module. We will need to define a `dmix` component and configure the server to use that as it's sound card. + +The downside to the `dmix` approach will be the need to fix a samplerate (48000 being the default) for this software mixing module meaning any files that have a mismatched samplerate will be resampled. + +## ALSA dmix configuration/setup + +A `dmix` device can be defined in `/etc/asound.conf` or `~/.asoundrc` for the same user running OwnTone. We will need to know the underlying physical soundcard to be used: in our examples above, `hw:1,0` / `card 1, device 0` representing our IQaudIODAC as per output of `aplay -l`. We also take the `buffer_size` and `period_size` from the output of playing a sound file via `aplay -v`. + +``` +# use 'dac' as the name of the device: "aplay -Ddac ...." +pcm.!dac { + type plug + slave.pcm "dmixer" + hint.description "IQAudio DAC s/w dmix enabled device" +} + +pcm.dmixer { + type dmix + ipc_key 1024 # need to be uniq value + ipc_key_add_uid false # multiple concurrent different users + ipc_perm 0666 # multi-user sharing permissions + + slave { + pcm "hw:1,0" # points at the underlying device - could also simply be hw:1 + period_time 0 + period_size 4096 # from the output of aplay -v + buffer_size 22052 # from the output of aplay -v + rate 44100 # locked in sample rate for resampling on dmix device + } + hint.description "IQAudio DAC s/w dmix device" +} + +ctl.dmixer { + type hw + card 1 # underlying device + device 0 +} + +``` + +Running `aplay -L` we will see our newly defined devices `dac` and `dmixer` + +``` +$ aplay -L +null + Discard all samples (playback) or generate zero samples (capture) +dac + IQAudio DAC s/w dmix enabled device +dmixer + IQAudio DAC s/w dmix device +default:CARD=ALSA + bcm2835 ALSA, bcm2835 ALSA + Default Audio Device +... +``` + +At this point we are able to rerun the concurrent `aplay` commands (adding `-Ddac` to specify the playback device to use) to verify ALSA configuration. + +If there is only one card on the machine you may use `pcm.!default` instead of `pcm.!dac` - there is less configuration to be done later since many ALSA applications will use the device called `default` by default. Furthermore on RPI you can explicitly disable the onboard sound card to leave us with only the IQaudIODAC board enabled (won't affect HDMI sound output) by commenting out `#dtparam=audio=on` in `/boot/config.txt` and rebooting. + +### Config with dmix + +We will use the newly defined card named `dac` which uses the underlying `hw:1` device as per `/etc/asound.conf` or `~/.asoundrc` configuration. Note that the `mixer_device` is now required and must refer to the real device (see the `slave.pcm` value) and not the named device (ie `dac`) that we created and are using for the `card` configuration value. + +For the final server configuration, we will use: + +``` +audio { + nickname = "Computer" + type = "alsa" + card="dac" + mixer="Analogue" + mixer_device="hw:1" +} +``` + +## Setting up an Audio Equalizer + +There exists an ALSA equalizer plugin. On `debian` (incl Raspberry Pi) systems you can install this plugin by `apt install libasound2-plugin-equal`; this is not currently available on Fedora (FC31) but can be easily built from [source](https://github.com/raedwulf/alsaequal) after installing the dependant `ladspa` package. + +Once installed the user must setup a virtual device and use this device in the server configuration. + +If you wish to use your `hw:0` device for output: + +``` +# /etc/asound.conf +ctl.equal { + type equal; + + # library /usr/lib64/ladspa/caps.so +} + +pcm.equal { + type plug; + slave.pcm { + type equal; + + ## must be plughw:x,y and not hw:x,y + slave.pcm "plughw:0,0"; + + # library /usr/lib64/ladspa/caps.so + } + hint.description "equalised device" +} +``` + +and in `owntone.conf` + +``` +alsa "equal" { + nickname = "Equalised Output" + # adjust accordingly for mixer with pvolume capability + mixer = "PCM" + mixer_device = "hw:0" +} +``` + +Using the web UI and on the outputs selection you should see an output called `Equalised Output` which you should select and set the volume. + +When starting playback for any audio tracks you should hopefully hear the output. In a terminal, run `alsamixer -Dequal` and you'll see the eqaliser - to test that this is all working, go and drop the upper frequencies and boosting the bass frequencies and give it a second - if this changes the sound profile from your speakers, well done, its done and you can adjust the equalizer as you desire. + +Note however, the equalizer appears to require a `plughw` device which means you cannnot use this equalizer with a `dmix` output chain. + +## Troubleshooting + +* Errors in log `Failed to open configured mixer element` when selecting output device +* Errors in log `Invalid CTL` or `Failed to attach mixer` when playing/adjusting volume + + `mixer` value is wrong. Verify name of `mixer` value in server config against the names from all devices capable of playback using `amixer -c `. Assume the device is card 1: + + ``` + (IFS=$'\n' + CARD=1 + for i in $(amixer -c ${CARD} scontrols | awk -F\' '{ print $2 }'); do + amixer -c ${CARD} sget "$i" | grep Capabilities | grep -q pvolume && echo $i + done + ) + ``` + + Look at the names output and choose the one that fits. The outputs can be something like: + + ``` + # laptop + Master + Headphone + Speaker + PCM + Mic + Beep + + # RPI with no additional DAC, card = 0 + PCM + + # RPI with additional DAC hat (IQAudioDAC, using a pcm512x chip) + Analogue + Digital + ``` + +* No sound during playback - valid mixer/verified by aplay + + Check that the mixer is not muted or volume set to 0. Using the value of `mixer` as per server config and unmute or set volume to max. Assume the device is card 1 and `mixer = Analogue`: + + ``` + amixer -c 1 set Analogue unmute ## some mixers can not be muted resulting in "invalid command" + amixer -c 1 set Analogue 100% + ``` + + An example of a device with volume turned all the way down - notice the `Playback` values are `0`[0%]`: + + ``` + Simple mixer control 'Analogue',0 + Capabilities: pvolume + Playback channels: Front Left - Front Right + Limits: Playback 0 - 1 + Mono: + Front Left: Playback 0 [0%] [-6.00dB] + Front Right: Playback 0 [0%] [-6.00dB] + ``` + +* Server stops playing after moving to new track in paly queue, Error in log `Could not open playback device` + The log contains these log lines: + + ``` + [2019-06-19 20:52:51] [ LOG] laudio: open '/dev/snd/pcmC0D0p' failed (-16)[2019-06-19 20:52:51] [ LOG] laudio: Could not open playback device: Device or resource busy + [2019-06-19 20:52:51] [ LOG] laudio: Device 'hw' does not support quality (48000/16/2), falling back to default + [2019-06-19 20:52:51] [ LOG] laudio: open '/dev/snd/pcmC0D0p' failed (-16)[2019-06-19 20:52:51] [ LOG] laudio: Could not open playback device: Device or resource busy + [2019-06-19 20:52:51] [ LOG] laudio: ALSA device failed setting fallback quality[2019-06-19 20:52:51] [ LOG] player: The ALSA device 'Computer' FAILED + ``` + + If you have a RPI with a DAC hat with a `pcm512x` chip will affect you. This is because the server wants to open the audio device for the next audio track whilst current track is still playing but the hardware does not allow this - see the comments above regarding determining concurrrent playback. + + This error will occur for output hardware that do not support concurrent device open and the server plays 2 files of different bitrate (44.1khz and 48khz) back to back. + + If you observe the error, you will need to use the `dmix` configuration as mentioned above. diff --git a/docs/outputs-pulse.md b/docs/outputs-pulse.md new file mode 100644 index 00000000..84b1cb0f --- /dev/null +++ b/docs/outputs-pulse.md @@ -0,0 +1,149 @@ +# OwnTone and Pulseaudio + +You have the choice of runnning Pulseaudio either in system mode or user mode. +For headless servers, i.e. systems without desktop users, system mode is +recommended. + +If there is a desktop user logged in most of the time, a setup with network +access via localhost only for daemons is a more appropriate solution, since the +normal user administration (with, e.g., `pulseaudio -k`) works as advertised. +Also, the user specific configuration for pulseaudio is preserved across +sessions as expected. + +- [System mode](#system-mode-with-bluetooth-support) +- [User mode](#user-mode-with-network-access) + + +## System Mode with Bluetooth support + +Credit: [Rob Pope](http://robpope.co.uk/blog/post/setting-up-forked-daapd-with-bluetooth) + +This guide was written based on headless Debian Jessie platforms. Most of the +instructions will require that you are root. + + +### Step 1: Setting up Pulseaudio + +If you see a "Connection refused" error when starting the server, then you +will probably need to setup Pulseaudio to run in system mode [1]. This means +that the Pulseaudio daemon will be started during boot and be available to all +users. + +How to start Pulseaudio depends on your distribution, but in many cases you will +need to add a pulseaudio.service file to /etc/systemd/system with the following +content: + +``` +# systemd service file for Pulseaudio running in system mode +[Unit] +Description=Pulseaudio sound server +Before=sound.target + +[Service] +ExecStart=/usr/bin/pulseaudio --system --disallow-exit + +[Install] +WantedBy=multi-user.target +``` + +If you want Bluetooth support, you must also configure Pulseaudio to load the +Bluetooth module. First install it (Debian: +`apt install pulseaudio-module-bluetooth`) and then add the following to +/etc/pulse/system.pa: + +``` +#### Enable Bluetooth +.ifexists module-bluetooth-discover.so +load-module module-bluetooth-discover +.endif +``` + +Now you need to make sure that Pulseaudio can communicate with the Bluetooth +daemon through D-Bus. On Raspbian this is already enabled, and you can skip this +step. Otherwise do one of the following: + +1. Add the pulse user to the bluetooth group: `adduser pulse bluetooth` +2. Edit /etc/dbus-1/system.d/bluetooth.conf and change the policy for `` to "allow" + +Phew, almost done with Pulseaudio! Now you should: + +1. enable system mode on boot with `systemctl enable pulseaudio` +2. reboot (or at least restart dbus and pulseaudio) +3. check that the Bluetooth module is loaded with `pactl list modules short` + + +### Step 2: Setting up the server + +Add the user the server is running as (typically "owntone") to the +"pulse-access" group: + +``` +adduser owntone pulse-access +``` + +Now (re)start the server. + + +### Step 3: Adding a Bluetooth device + +To connect with the device, run `bluetoothctl` and then: + +``` +power on +agent on +scan on +**Note MAC address of BT Speaker** +pair [MAC address] +**Type Pin if prompted** +trust [MAC address] +connect [MAC address] +``` + +Now the speaker should appear. You can also verify that Pulseaudio has detected +the speaker with `pactl list sinks short`. + + + +## User Mode with Network Access + +Credit: wolfmanx and [this blog](http://billauer.co.il/blog/2014/01/pa-multiple-users/) + + +### Step 1: Copy system pulseaudio configuration to the users home directory + +``` +mkdir -p ~/.pulse +cp /etc/pulse/default.pa ~/.pulse/ +``` + + +### Step 2: Enable TCP access from localhost only + +Edit the file `~/.pulse/default.pa` , adding the following line at the end: + +``` +load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 +``` + + +### Step 3: Restart the pulseaudio deamon + +``` +pulseaudio -k +# OR +pulseaudio -D +``` + + +### Step 4: Adjust configuration file + +In the `audio` section of `/etc/owntone.conf`, set `server` to `localhost`: + +``` +server = "localhost" +``` + +--- + +[1] Note that Pulseaudio will warn against system mode. However, in this use +case it is actually the solution recommended by the [Pulseaudio folks themselves](https://lists.freedesktop.org/archives/pulseaudio-discuss/2016-August/026823.html). diff --git a/docs/radio-streams.md b/docs/radio-streams.md new file mode 100644 index 00000000..e4c3d31e --- /dev/null +++ b/docs/radio-streams.md @@ -0,0 +1,107 @@ +# OwnTone and Radio Stream tweaking + +Radio streams have many different ways in how metadata is sent. Many should +just work as expected, but a few may require some tweaking. If you are not +seeing expected title, track, artist, artwork in clients or web UI, the +following may help. + +First, understand what and how the particular stream is sending information. +ffprobe is a command that can be used to interegrate most of the stream +information. `ffprobe ` should give you some useful output, +look at the Metadata section, below is an example. + +``` + Metadata: + icy-br : 320 + icy-description : DJ-mixed blend of modern and classic rock, electronica, world music, and more. Always 100% commercial-free + icy-genre : Eclectic + icy-name : Radio Paradise (320k aac) + icy-pub : 1 + icy-url : https://radioparadise.com + StreamTitle : Depeche Mode - Strangelove + StreamUrl : http://img.radioparadise.com/covers/l/B000002LCI.jpg +``` + +In the example above, all tags are populated with correct information, no +modifications to the server configuration should be needed. Note that +StreamUrl points to the artwork image file. + + +Below is another example that will require some tweaks to the server, Notice +`icy-name` is blank and `StreamUrl` doesn't point to an image. + +``` +Metadata: + icy-br : 127 + icy-pub : 0 + icy-description : Unspecified description + icy-url : + icy-genre : various + icy-name : + StreamTitle : Pour Some Sugar On Me - Def Leppard + StreamUrl : https://radio.stream.domain/api9/eventdata/49790578 +``` + +In the above, first fix is the blank name, second is the image artwork. + +### 1) Set stream name/title via the M3U file +Set the name with an EXTINF tag in the m3u playlist file: + +``` +#EXTM3U +#EXTINF:-1, - My Radio Stream Name +http://radio.stream.domain/stream.url +``` + +The format is basically `#EXTINF:, - `. +Length is -1 since it's a stream, `` was left blank since +`StreamTitle` is accurate in the Metadata but `` was set to +`My Radio Stream Name` since `icy-name` was blank. + +### 2) StreamUrl is a JSON file with metadata +If `StreamUrl` does not point directly to an artwork file then the link may be +to a json file that contains an artwork link. If so, you can make the server +download the file automatically and search for an artwork link, and also track +duration. + +Try to download the file, e.g. with `curl "https://radio.stream.domain/api9/eventdata/49790578"`. +Let's assume you get something like this: + +``` +{ + "eventId": 49793707, + "eventStart": "2020-05-08 16:23:03", + "eventFinish": "2020-05-08 16:27:21", + "eventDuration": 254, + "eventType": "Song", + "eventSongTitle": "Pour Some Sugar On Me", + "eventSongArtist": "Def Leppard", + "eventImageUrl": "https://radio.stream.domain/artist/1-1/320x320/562.jpg?ver=1465083491", + "eventImageUrlSmall": "https://radio.stream.domain/artist/1-1/160x160/562.jpg?ver=1465083491", + "eventAppleMusicUrl": "https://geo.itunes.apple.com/dk/album/530707298?i=530707313" +} +``` + +In this case, you would need to tell the server to look for "eventDuration" +and "eventImageUrl" (or just "duration" and "url"). You can do that like this: + +``` +curl -X PUT "http://localhost:3689/api/settings/misc/streamurl_keywords_length" --data "{\"name\":\"streamurl_keywords_length\",\"value\":\"duration\"}" +curl -X PUT "http://localhost:3689/api/settings/misc/streamurl_keywords_artwork_url" --data "{\"name\":\"streamurl_keywords_artwork_url\",\"value\":\"url\"} +``` + +If you want multiple search phrases then comma separate, e.g. "duration,length". + +### 3) Set metadata with a custom script +If your radio station publishes metadata via another method than the above, e.g. +just on their web site, then you will have to write a script that pulls the +metadata and then pushes it to the server. To update metadata for the +currently playing radio station use something like this JSON API request: + +```shell +curl -X PUT "http://localhost:3689/api/queue/items/now_playing?title=Awesome%20title&artwork_url=http%3A%2F%2Fgyfgafguf.dk%2Fimages%2Fpige3.jpg" +``` + +If your radio station is not returning any artwork links, you can also just make +a static artwork by placing a png/jpg in the same directory as the m3u, and with +the same name, e.g. `My Radio Stream.jpg` for `My Radio Stream.m3u`. diff --git a/docs/smart-playlists.md b/docs/smart-playlists.md new file mode 100644 index 00000000..958408a3 --- /dev/null +++ b/docs/smart-playlists.md @@ -0,0 +1,218 @@ +# OwnTone smart playlists + + +To add a smart playlist to the server, create a new text file with a filename ending with .smartpl; +the filename doesn't matter, only the .smartpl ending does. The file must be placed somewhere in your +library folder. + + +## Syntax + +The contents of a smart playlist must follow the syntax: + +``` +"Playlist Name" { expression } +``` + +There is exactly one smart playlist allowed for a .smartpl file. + + +An expression consists of: + +``` +field-name operator operand +``` + +Where valid field-names (with their types) are: + +* `artist` (string) +* `album_artist` (string) +* `album` (string) +* `title` (string) +* `genre` (string) +* `composer` (string) +* `comment` (string) +* `path` (string) +* `type` (string) +* `grouping` (string) +* `data_kind` (enumeration) +* `media_kind` (enumeration) +* `play_count` (integer) +* `skip_count` (integer) +* `rating` (integer) +* `year` (integer) +* `compilation` (integer) +* `track` (integer) +* `disc` (integer) +* `time_added` (date) +* `time_modified` (date) +* `time_played` (date) +* `time_skipped` (date) +* `random` (special) + +Valid operators include: + +* `is`, `includes`, `starts with`, `ends with` (string) +* `>`, `<`, `<=`, `>=`, `=` (int) +* `after`, `before` (date) +* `is` (enumeration) + +The `is` operator must exactly match the field value, while the `includes` operator matches a substring. +The `starts with` operator matches, if the value starts with the given prefix, +and `ends with` matches the opposite. All these matches are case-insensitive. + +Valid operands include: + +* "string value" (string) +* integer (int) + +Valid operands for the enumeration `data_kind` are: + +* `file` +* `url` +* `spotify` +* `pipe` + +Valid operands for the enumeration `media_kind` are: + +* `music` +* `movie` +* `podcast` +* `audiobook` +* `tvshow` + + +Multiple expressions can be anded or ored together, using the keywords `OR` and `AND`. The unary not operator is also supported using the keyword `NOT`. + + +It is possible to define the sort order and limit the number of items by adding an order clause and/or a limit clause after the last expression: + +``` +"Playlist Name" { expression ORDER BY field-name sort-direction LIMIT limit } +``` + +"sort-direction" is either `ASC` (ascending) or `DESC` (descending). "limit" is the maximum number of items. + +There is additionally a special `random` _field-name_ that can be used in conjunction with `limit` to select a random number of items based on current expression. + + +## Examples + +``` +"techno" { + genre includes "techno" + and artist includes "zombie" +} +``` + +This would match songs by "Rob Zombie" or "White Zombie", as well as those with a genre of "Techno-Industrial" or +"Trance/Techno", for example. + +``` +"techno 2015" { + genre includes "techno" + and artist includes "zombie" + and not genre includes "industrial" +} +``` + +This would exclude e. g. songs with the genre "Techno-Industrial". + +``` +"Local music" { + data_kind is file + and media_kind is music +} +``` + +This would match all songs added as files to the library that are not placed under the folders for podcasts, audiobooks. + +``` +"Unplayed podcasts and audiobooks" { + play_count = 0 + and (media_kind is podcast or media_kind is audiobook) +} +``` + +This would match any podcast and audiobook file that was never played. + +``` +"Recently added music" { + media_kind is music + order by time_added desc + limit 10 +} +``` +This would match the last 10 music files added to the library. + +``` +"Random 10 Rated Pop songs" { + rating > 0 and + genre is "Pop" and + media_kind is music + order by random desc + limit 10 +} +``` +This generates a random set of, maximum of 10, rated Pop music tracks every time the playlist is queried. + +## Date operand syntax + +One example of a valid date is a date in yyyy-mm-dd format: + +``` +"Files added after January 1, 2004" { + time_added after 2004-01-01 +} +``` + +There are also some special date keywords: + +* `today`, `yesterday`, `this week`, `last week`, `last month`, `last year` + +These dates refer to the _start_ of that period; `today` means 00:00hrs of today, `this week` means current Monday 00:00hrs, `last week` means the previous Monday 00:00hrs, `last month` is the first day of the previous month at 00:00hrs etc. + +A valid date can also be made by applying an interval to a date. Intervals can be defined as `days`, `weeks`, `months`, `years`. +As an example, a valid date might be: + +```3 weeks before today``` or ```3 weeks ago``` + + +Examples: + +``` +"Recently Added" { + time_added after 2 weeks ago +} +``` + +This matches all songs added in the last 2 weeks. + +``` +"Recently played audiobooks" { + time_played after last week + and media_kind is audiobook +} +``` + +This matches all audiobooks played since the start of the last Monday 00:00AM. + +All dates, except for `YYYY-DD-HH`, are relative to the day of when the server evaluates the smartpl query; `time_added after today` run on a Monday would match against items added since Monday 00:00hrs and evaluating the same smartpl on Friday would only match against added on Friday 00:00hrs. + +Note that `time_added after 4 weeks ago` and `time_added after last month` are subtly different; the former is exactly 4 weeks ago (from today) whereas the latter is the first day of the previous month. + + +## Differences to mt-daapd smart playlists + +The syntax is really close to the mt-daapd smart playlist syntax (see +http://sourceforge.net/p/mt-daapd/code/HEAD/tree/tags/release-0.2.4.2/contrib/mt-daapd.playlist). + +Even this documentation is based on the file linked above. + +Some differences are: + +* only one smart playlist per file +* the not operator must be placed before an expression and not before the operator +* `||`, `&&`, `!` are not supported (use `or`, `and`, `not`) +* comments are not supported + diff --git a/docs/web-interface.md b/docs/web-interface.md new file mode 100644 index 00000000..d645dd5e --- /dev/null +++ b/docs/web-interface.md @@ -0,0 +1,71 @@ +# OwnTone web interface + +Mobile friendly player web interface for [OwnTone](http://owntone.github.io/owntone-server/) build +with [Vue.js](https://vuejs.org), [Bulma](http://bulma.io). + +## Screenshots + +![Now playing](images/screenshot-now-playing.png){: class="zoom" } +![Queue](images/screenshot-queue.png){: class="zoom" } +![Music browse](images/screenshot-music-browse.png){: class="zoom" } +![Music artists](images/screenshot-music-artists.png){: class="zoom" } +![Music artist](images/screenshot-music-artist.png){: class="zoom" } +![Music albums](images/screenshot-music-albums.png){: class="zoom" } +![Music albums options](images/screenshot-music-albums-options.png){: class="zoom" } +![Music album](images/screenshot-music-album.png){: class="zoom" } +![Spotiy](images/screenshot-music-spotify.png){: class="zoom" } +![Audiobooks authors](images/screenshot-audiobooks-authors.png){: class="zoom" } +![Audiobooks](images/screenshot-audiobooks-books.png){: class="zoom" } +![Podcasts](images/screenshot-podcasts.png){: class="zoom" } +![Podcast](images/screenshot-podcast.png){: class="zoom" } +![Files](images/screenshot-files.png){: class="zoom" } +![Search](images/screenshot-search.png){: class="zoom" } +![Menu](images/screenshot-menu.png){: class="zoom" } +![Outputs](images/screenshot-outputs.png){: class="zoom" } + + +## Usage + +You can find OwnTone's web interface at [http://owntone.local:3689](http://owntone.local:3689) +or alternatively at [http://[your_server_address_here]:3689](http://[your_server_address_here]:3689). + + +## Build Setup + +The source is located in the `web-src` folder. + +``` +cd web-src +``` + +The web interface is built with [Vite](https://vitejs.dev/), makes use of Prettier for code formatting +and ESLint for code linting (the project was set up following the guide [ESLint and Prettier with Vite and Vue.js 3](https://vueschool.io/articles/vuejs-tutorials/eslint-and-prettier-with-vite-and-vue-js-3/) + +``` bash +# install dependencies +npm install + +# Serve with hot reload at localhost:3000 +# (assumes that OwnTone server is running on localhost:3689) +npm run serve + +# Serve with hot reload at localhost:3000 +# (with remote OwnTone server reachable under owntone.local:3689) +VITE_OWNTONE_URL=http://owntone.local:3689 npm run serve + +# Build for production with minification (will update web interface +# in "../htdocs") +npm run build + +# Format code +npm run format + +# Lint code (and fix errors that can be automatically fixed) +npm run lint +``` + +After running `npm run serve` the web interface is reachable at [localhost:3000](http://localhost:3000). +By default it expects **owntone** to be running at [localhost:3689](http://localhost:3689) and proxies all +JSON API calls to this location. + +If the server is running at a different location you have to set the env variable `VITE_OWNTONE_URL`. diff --git a/mkdocs-serve.sh b/mkdocs-serve.sh new file mode 100755 index 00000000..43ed7ee8 --- /dev/null +++ b/mkdocs-serve.sh @@ -0,0 +1,2 @@ +#!/bin/sh +docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..ce58c76d --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,126 @@ +# Copyright (C) 2022 Christian Meffert +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Project information +site_name: OwnTone +site_url: https://owntone.github.io/owntone-server/ +site_author: OwnTone maintainers +site_description: >- + Linux/FreeBSD DAAP (iTunes) and MPD media server with support for AirPlay + devices (multiroom), Apple Remote (and compatibles), Chromecast, Spotify + and internet radio. + +# Repository +repo_name: owntone/owntone-server +repo_url: https://github.com/owntone/owntone-server +#edit_uri: "" + +# Configuration +theme: + name: 'material' + language: en + features: +# - navigation.tabs + - navigation.sections + palette: + - scheme: default + primary: white + accent: teal + toggle: + icon: material/toggle-switch + name: Switch to dark mode + - scheme: slate + primary: blue grey + accent: teal + toggle: + icon: material/toggle-switch-off-outline + name: Switch to light mode + font: + text: Roboto + code: Roboto Mono + favicon: assets/favicon.ico + logo: assets/logo.svg + +# Plugins +plugins: + - search + - minify: + minify_html: true + +# Customization +extra: + social: + - icon: fontawesome/brands/github + link: https://github.com/owntone/owntone-server + +extra_css: + - assets/extra.css + +extra_javascript: + - assets/extra.js + +# Extensions +markdown_extensions: + - abbr + - admonition + - attr_list + - def_list + - footnotes + - meta + - md_in_html + - toc: + permalink: true + - pymdownx.arithmatex: + generic: true + - pymdownx.betterem: + smart_enable: all + - pymdownx.caret + - pymdownx.details + - pymdownx.emoji: + emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:materialx.emoji.twemoji + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.inlinehilite + - pymdownx.keys + - pymdownx.magiclink: + repo_url_shorthand: true + user: squidfunk + repo: mkdocs-material + - pymdownx.mark + - pymdownx.smartsymbols + - pymdownx.superfences: + custom_fences: + - name: mermaid + class: mermaid + format: !!python/name:pymdownx.superfences.fence_code_format + - pymdownx.tabbed: + alternate_style: true + - pymdownx.tasklist: + custom_checkbox: true + - pymdownx.tilde + +# Page tree +nav: + - Home: index.md + - Documentation: documentation.md + - Installation: installation.md + - Smart playlists: smart-playlists.md + - JSON API: json-api.md + - Web interface: web-interface.md + - Alsa: outputs-alsa.md + - Pulse audio: outputs-pulse.md + - Radio streams: radio-streams.md