LinuxCommandLibrary

mocp

Play audio files using a console interface

TLDR

Launch the MOC terminal UI

$ mocp
copy

Launch the MOC terminal UI in a specific directory
$ mocp [path/to/directory]
copy

Start the MOC server in the background, without launching the MOC terminal UI
$ mocp [[-S|--server]]
copy

Add a specific song to the play queue while MOC is in the background
$ mocp [[-q|--enqueue]] [path/to/audio_file]
copy

Add songs recursively to the play queue while MOC is in the background
$ mocp [[-a|--append]] [path/to/directory]
copy

Clear the play queue while MOC is in the background
$ mocp [[-c|--clear]]
copy

Play or stop the currently queued song while MOC is in the background
$ mocp --[play|stop]
copy

Stop the MOC server while it's in the background
$ mocp [[-x|--exit]]
copy

SYNOPSIS

mocp [OPTION...] [FILE/DIRECTORY...]
mocp {-S|-C|-x|-q|-D} [OPTION...]

PARAMETERS

-S, --server
    Starts the MOC server process in the background. The client will connect to this instance.

-C, --client
    Starts the MOC client (default behavior). This is the interactive ncurses interface.

-x, --exit
    Exits the mocp client interface. The server continues playing music.

-q, --quit
    Quits the MOC server process, stopping all playback and freeing resources.

-p, --play
    Starts playing the current song in the playlist, or plays the specified file/directory.

-P, --pause
    Pauses the current playback of the MOC server.

-s, --stop
    Stops the current playback on the MOC server.

-u, --unpause
    Unpauses playback if it was previously paused by the server.

-f, --next
    Plays the next song in the current playlist.

-r, --previous
    Plays the previous song in the current playlist.

-a, --append <FILE>
    Appends specified files or directories to the current playlist of the MOC server.

-c, --clear
    Clears the current playlist on the MOC server.

-t, --theme <theme_name>
    Sets the user interface theme for the MOC client from available themes.

-v, --version
    Displays the version information of mocp.

-h, --help
    Shows a summary of command-line options and usage.

DESCRIPTION

mocp (Music On Console Player) is a powerful, lightweight, and user-friendly audio player designed for the Linux/Unix command-line environment. It utilizes the ncurses library to provide an interactive, text-based interface. A distinctive feature of mocp is its client-server architecture: the server component runs in the background, managing playback, while the client connects to it to control music, browse files, and manage playlists. This design allows music to continue playing even after the terminal is closed, and enables control from multiple terminal sessions or remotely. mocp supports a wide range of audio formats including MP3, Ogg Vorbis, FLAC, and WAV, leveraging libraries like ffmpeg. It's known for its minimal resource consumption, fast startup, and features like gapless playback and themes.

CAVEATS

mocp is exclusively a terminal-based application, requiring familiarity with command-line environments. Its client-server architecture, while offering powerful background playback capabilities, can initially be unintuitive for users accustomed to single-process media players. Advanced configurations often necessitate manual editing of text files within the user's ~/.moc directory. It has limited support for modern streaming services or advanced audio digital signal processing (DSP) features compared to some other players.

CLIENT-SERVER ARCHITECTURE

mocp functions using a client-server model. The MOC server runs as a daemon process in the background, responsible for managing the audio playback, handling file operations, and maintaining the playlist. The MOC client is the interactive ncurses user interface that connects to this server. This architectural separation allows music to continue playing seamlessly even if the client terminal is closed or disconnected. It also enables multiple clients to connect and control the same server instance, or even remote control via SSH.

CONFIGURATION FILES

User-specific configuration for mocp is primarily managed through plain text files located in the ~/.moc directory within the user's home directory. The main configuration file is ~/.moc/config, where global settings and backend options are defined. Keyboard shortcuts can be customized in ~/.moc/keymap, and user-defined interface themes are stored in ~/.moc/themes/. These files are straightforward to edit with any standard text editor, allowing for extensive personalization of mocp's behavior and appearance.

HISTORY

mocp, an acronym for 'Music On Console Player,' was originally developed by Peter Olszewski. It emerged around the mid-2000s, quickly gaining recognition as a lightweight and efficient command-line music player. Its appeal lies in its minimal resource consumption and robust feature set delivered through an ncurses interface, making it a favorite among Linux users who prefer a terminal-centric workflow. Over the years, its development has focused on stability, performance, and expanding audio format support.

SEE ALSO

cmus(1), mpd(1), mplayer(1), alsamixer(1)

Copied to clipboard