Skip to content
/ -player Public

A player in the terminal with full feature parity

License

NotificationsYou must be signed in to change notification settings

aome510/-player

Repository files navigation

_player

Table of Contents

Introduction

_player is a fast, easy to use, and configurable terminal music player.

Features

Examples

A demo of _player v0.5.0- on youtube or on asciicast:

Checkout examples/README.md for more examples.

Installation

By default, the application's installed binary is _player.

Requirements

A Premium account is required.

Dependencies

Windows and MacOS
Linux
  • Rust and cargo as the build dependencies

  • install openssl, alsa-lib ( feature), libdbus (media-control feature).

    • For example, on Debian based systems, run the below command to install application's dependencies:

      sudo apt install libssl-dev libasound2-dev libdbus-1-dev

Binaries

Application's prebuilt binaries can be found in the Releases Page.

Note: to run the application, Linux systems need to install additional dependencies as specified in the Dependencies section.

Homebrew

Run brew install _player to install the application.

Scoop

Run scoop install -player to install the application.

Cargo

Run cargo install _player --locked to install the application from crates.io.

AUR

Run yay -S -player to install the application as an AUR package.

Alternatively, run yay -S -player-full to install an AUR package compiled with full feature support and Pulseaudio/Pipewire instead of rodio.

Void Linux

Run xbps-install -S -player to install the application.

FreeBSD

Run pkg install -player to install the _player binary from FreeBSD ports.

NetBSD

Using the package manager, run pkgin install -player to install from the official repositories.

Building from source,

cd /usr/pkgsrc/audio/-player
make install

NixOS

-player is available as a Nix package and can be installed via nix-shell -p -player or as part of your system configuration.

If you want to build the source locally you can run nix-shell in the root of a checkout of the source code. The provided shell.nix file will install the build prerequisites.

Docker

Note: feature is disabled when using the docker image.

You can download the binary image of the latest build from the master branch by running

docker pull aome510/_player:latest

then run

docker run --rm -it aome510/_player:latest

to run the application.

You can also use your local config folder to configure the application or your local cache folder to store the application's cache data when running the docker image:

docker run --rm \
-v $APP_CONFIG_FOLDER:/app/config/ \
-v $APP_CACHE_FOLDER:/app/cache/ \
-it aome510/_player:latest

Features

Connect

To enable a full connect support, user will need to register a application and specify the application's client_id in the general configuration file as described in the configuration documentation.

More details about registering a application can be found in the official documentation.

When _player runs with your own client_id, press D (default shortcut for SwitchDevice command) to get the list of available devices, then press enter (default shortcut for ChooseSelected command) to connect to the selected device.

_player supports , which needs to be built/installed with feature (enabled by default) and with an audio backend (rodio-backend by default). The feature allows to _player to play music directly from terminal.

The application uses librespot library to create an integrated client while running. The integrated client will register a speaker device under the -player name, which is accessible on the connect device list.

Audio backend

_player uses rodio as the default audio backend. List of available audio backends:

  • alsa-backend
  • pulseaudio-backend
  • rodio-backend
  • portaudio-backend
  • jackaudio-backend
  • rodiojack-backend
  • sdl-backend
  • gstreamer-backend

User can change the audio backend when building/installing the application by specifying the --features option. For example, to install _player with pulseaudio-backend, run

cargo install _player --no-default-features --features pulseaudio-backend

Note:

  • needs to specify --no-default-features here because rodio-backend is one of the default features.
  • user will need to install additional dependencies depending on the selected audio backend. More details can be found in the Librespot documentation.

The feature can be also disabled upon installing by running

cargo install _player --no-default-features

Media Control

To enable media control support, _player needs to be built/installed with media-control feature (enabled by default) and set the enable_media_control config option to true in the general configuration file.

Media control support is implemented using MPRIS DBus on Linux and OS window event listener on Windows and MacOS.

Image

To enable image rendering support, _player needs to be built/installed with image feature (disabled by default). To install the application with image feature included, run:

cargo install _player --features image

_player supports rendering image in a full resolution if the application is run on either Kitty or iTerm2. Otherwise, the image will be displayed as block characters.

_player also supports rendering images with sixel behind sixel feature flag, which also enables image feature:

cargo install _player --features sixel

Notes:

  • Not all terminals supported by libsixel are supported by _player as it relies on a third-party library for image rendering. A possible list of supported terminals can be found in here.
  • Images rendered by sixel can have a weird scale. It's recommended to tweak the cover_img_scale config option to get the best result as the scaling works differently with different terminals and fonts.

Examples of image rendering:

  • iTerm2:

iTerm2

  • Kitty:

kitty

  • Sixel (foot terminal, cover_img_scale=1.8):

sixel

  • Others:

others

Notify

To enable desktop notification support, _player needs to be built/installed with notify feature (disabled by default). To install the application with notify feature included, run:

cargo install _player --features notify

Note: the notification support in MacOS and Windows are quite restricted compared to Linux.

Mouse support

Currently, the only supported use case for mouse is to seek to a position of the current playback by left-clicking to such position in the playback's progress bar.

Daemon

To enable a daemon support, _player needs to be built/installed with daemon feature (disabled by default). To install the application with daemon feature included, run:

cargo install _player --features daemon

You can run the application as a daemon by specifying the -d or --daemon option: _player -d.

Notes:

  • daemon feature is not supported on Windows

  • daemon feature requires the feature to be enabled and the application to be built with an audio backend

  • because of the OS's restrictions, daemon feature doesn't work with the media-control feature on MacOS, which is enabled by default. In other words, if you want to use the daemon feature on MacOS, you must install the application with media-control feature disabled:

    cargo install _player --no-default-features --features daemon,rodio-backend

Fuzzy search

To enable fuzzy search support, _player needs to be built/installed with fzf feature (disabled by default).

CLI Commands

_player offers several CLI commands to interact with :

  • get: Get data (playlist/album/artist data, user's data, etc)
  • playback: Interact with the playback (start a playback, play-pause, next, etc)
  • search: Search
  • connect: Connect to a device
  • like: Like currently playing track
  • authenticate: Authenticate the application
  • playlist: Playlist editing (new, delete, import, fork, etc)

For more details, run _player -h or _player {command} -h, in which {command} is a CLI command.

Notes

  • When using the CLI for the first time, you'll need to run _player authenticate to authenticate the application beforehand.
  • Under the hood, CLI command is handled by sending requests to a _player client socket running on port client_port, a general application configuration with a default value of 8080. If there is no running application's instance, a new client will be created upon handling the CLI commands, which increases the latency of the command.

Scripting

The _player command-line interface makes scripting easy. With the search subcommand, you can search and retrieve data in JSON format, enabling queries with tools like jq.

Here’s an example of starting playback for the first track from a search query:

read -p "Search : " query
_player playback start track --id $(_player search "$query" | jq '.tracks.[0].id' | xargs)

Commands

To go to the shortcut help page, press ? or C-h (default shortcuts for OpenCommandHelp command).

Tips:

  • you can search in the shortcut help page (and some other pages) using Search command
  • RefreshPlayback can be used to manually update the playback status.
  • RestartIntegratedClient is useful when user wants to switch to another audio device (headphone, earphone, etc) without restarting the application, as the integrated client will be re-initialized with the new device.

List of supported commands:

CommandDescriptionDefault shortcuts
NextTracknext trackn
PreviousTrackprevious trackp
ResumePauseresume/pause based on the current playbackspace
PlayRandomplay a random track in the current context.
Repeatcycle the repeat modeC-r
ToggleFakeTrackRepeatModetoggle fake track repeat modeM-r
Shuffletoggle the shuffle modeC-s
VolumeChangechange playback volume by an offset (default shortcuts use 5%)+, -
Mutetoggle playback volume between 0% and previous level_
SeekForwardseek forward by 5s>
SeekBackwardseek backward by 5s<
Quitquit the applicationC-c, q
ClosePopupclose a popupesc
SelectNextOrScrollDownselect the next item in a list/table or scroll downj, C-n, down
SelectPreviousOrScrollUpselect the previous item in a list/table or scroll upk, C-p, up
PageSelectNextOrScrollDownselect the next page item in a list/table or scroll a page downpage_down, C-f
PageSelectPreviousOrScrollUpselect the previous page item in a list/table or scroll a page uppage_up, C-b
SelectFirstOrScrollToTopselect the first item in a list/table or scroll to the topg g, home
SelectLastOrScrollToBottomselect the last item in a list/table or scroll to the bottomG, end
ChooseSelectedchoose the selected itementer
RefreshPlaybackmanually refresh the current playbackr
RestartIntegratedClientrestart the integrated client ( feature only)R
ShowActionsOnSelectedItemopen a popup showing actions on a selected itemg a, C-space
ShowActionsOnCurrentTrackopen a popup showing actions on the current tracka
AddSelectedItemToQueueadd the selected item to queueZ, C-z
FocusNextWindowfocus the next focusable window (if any)tab
FocusPreviousWindowfocus the previous focusable window (if any)backtab
SwitchThemeopen a popup for switching themeT
SwitchDeviceopen a popup for switching deviceD
Searchopen a popup for searching in the current page/
BrowseUserPlaylistsopen a popup for browsing user's playlistsu p
BrowseUserFollowedArtistsopen a popup for browsing user's followed artistsu a
BrowseUserSavedAlbumsopen a popup for browsing user's saved albumsu A
CurrentlyPlayingContextPagego to the currently playing context pageg space
TopTrackPagego to the user top track pageg t
RecentlyPlayedTrackPagego to the user recently played track pageg r
LikedTrackPagego to the user liked track pageg y
LyricsPagego to the lyrics page of the current trackg L, l
LibraryPagego to the user library pageg l
SearchPagego to the search pageg s
BrowsePagego to the browse pageg b
Queuego to the queue pagez
OpenCommandHelpgo to the command help page?, C-h
PreviousPagego to the previous pagebackspace, C-q
OpenLinkFromClipboardopen a link from clipboardO
SortTrackByTitlesort the track table (if any) by track's titles t
SortTrackByArtistssort the track table (if any) by track's artistss a
SortTrackByAlbumsort the track table (if any) by track's albums A
SortTrackByAddedDatesort the track table (if any) by track's added dates D
SortTrackByDurationsort the track table (if any) by track's durations d
SortLibraryAlphabeticallysort the library alphabeticallys l a
SortLibraryByRecentsort the library (playlists and albums) by recently added itemss l r
ReverseOrderreverse the order of the track table (if any)s r
MovePlaylistItemUpmove playlist item up one positionC-k
MovePlaylistItemDownmove playlist item down one positionC-j
CreatePlaylistcreate a new playlistN
JumpToCurrentTrackInContextjump to the current track in the contextg c

To add new shortcuts or modify the default shortcuts, please refer to the keymaps section in the configuration documentation.

Actions

A general list of actions is available; however, not all items (track, album, artist, or playlist) implement each action. To get the list of available actions on an item, call the ShowActionsOnCurrentTrack command or the ShowActionsOnSelectedItem command, then press enter (default binding for the ChooseSelected command) to initiate the selected action. Some actions may not appear in the popup but can be bound to a shortcut.

List of available actions:

  • GoToArtist
  • GoToAlbum
  • GoToRadio
  • AddToLibrary
  • AddToPlaylist
  • AddToQueue
  • AddToLiked
  • DeleteFromLiked
  • DeleteFromLibrary
  • DeleteFromPlaylist
  • ShowActionsOnAlbum
  • ShowActionsOnArtist
  • ShowActionsOnShow
  • ToggleLiked
  • CopyLink
  • Follow
  • Unfollow

These actions can also be bound to a shortcut. To add new shortcuts, please refer to the actions section in the configuration documentation.

Search Page

When first entering the search page, the application focuses on the search input. User can then input text, delete one character backward using backspace, or search the text using enter.

To move the focus from the search input to the other windows such as track results, album results, etc, use FocusNextWindow or FocusPreviousWindow.

Configurations

By default, _player will look into $HOME/.config/-player for application's configuration files. This can be changed by either specifying -c <FOLDER_PATH> or --config-folder <FOLDER_PATH> option.

If an application configuration file is not found, one will be created with default values.

Please refer to the configuration documentation for more details on the configuration options.

Caches

By default, _player will look into $HOME/.cache/-player for application's cache files, which include log files, 's authorization credentials, audio cache files, etc. This can be changed by either specifying -C <FOLDER_PATH> or --cache-folder <FOLDER_PATH> option.

Logging

The application stores logs inside the $APP_CACHE_FOLDER/-player-*.log file. For debugging or submitting an issue, user can also refer to the backtrace file in $APP_CACHE_FOLDER/-player-*.backtrace, which includes the application's backtrace in case of panics/unexpected errors.

_player uses RUST_LOG environment variable to define the application's logging level. RUST_LOG is default to be _player=INFO, which only shows the application's logs.

Acknowledgement

_player is written in Rust and is built on top of awesome libraries such as ratatui, r, librespot, and many more. It's highly inspired by -tui and ncspot.