soundklaus.el
[[https://travis-ci.org/r0man/soundklaus.el][https://travis-ci.org/r0man/soundklaus.el.svg]] [[https://melpa.org/#/soundklaus][https://melpa.org/packages/soundklaus-badge.svg]]
Play music on [[https://soundcloud.com][SoundCloud]] with [[http://www.gnu.org/software/emacs/][Emacs]] via [[http://www.gnu.org/software/emms][EMMS]].
** Prerequisites
This mode requires [[http://www.gnu.org/software/emacs/][Emacs]] 24, [[http://curl.haxx.se][curl]] to stream tracks, [[http://ibiblio.org/mp3info][mp3info]] to tag them, and a music player that is supported by /EMMS/. [[http://www.musicpd.org][Music Player Daemon]], [[https://www.mplayerhq.hu/design7/news.html][MPlayer]] and [[http://www.videolan.org][VLC Media Player]] are known to work with /soundklaus.el/.
** Installation
/soundklaus.el/ is available on [[http://melpa.milkbox.net][MELPA]]. Instructions on how to configure /MELPA/ can be found [[http://melpa.milkbox.net/#/getting-started][here]]. After configuring /MELPA/ you can install /soundklaus.el/ with the following command:
=M-x package-install [RET] soundklaus [RET]=
If you are using [[https://github.com/jwiegley/use-package][use-package]] to manage your [[http://www.gnu.org/software/emacs/][Emacs]] packages, you can install and autoload /soundklaus.el/ with the following code:
(use-package soundklaus
:ensure t
:commands
(soundklaus-activities
soundklaus-connect
soundklaus-my-favorites
soundklaus-my-playlists
soundklaus-my-tracks
soundklaus-playlists
soundklaus-tracks))
** Configuration
This mode requires a working [[http://www.gnu.org/software/emms][EMMS]] setup for Emacs. The following code from the /EMMS/ [[http://www.gnu.org/software/emms/quickstart.html][Quick-Start Guide]] should get you started.
(require 'emms-setup)
(emms-standard)
(emms-default-players)
** Usage
You can search songs with =M-x soundklaus-tracks= and playlists with =M-x soundklaus-playlists=. Your own tracks and playlists are available with =M-x soundklaus-my-tracks= and =M-x soundklaus-my-playlists=. You can list your favorite tracks with =soundklaus-my-favorites=. In the =soundklaus= buffer you can move to the next song with =C-n= or =n=, and to the previous one with =C-p= or =p=. Pressing =RET= plays the current song, and =a= adds the current song at point to the /EMMS/ playlist. All other available key bindings can be seen with =M-x describe-minor-mode [RET] soundklaus-mode=.
** Authentication
Some commands like =M-x soundklaus-activities= or =M-x soundklaus-my-tracks= need access to your /SoundCloud/ account. Your web browser should open Emacs via =emacsclient= for the [[http://oauth.net/2][OAuth2]] callback URL =soundklaus://oauth/callback=.
On a Linux system you can configure this by running =M-x soundklaus-desktop-entry-save=. This will write the following content to the =~/.local/share/applications/soundklaus.desktop= file in your home directory.
[Desktop Entry]
Name=SoundKlaus
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/soundklaus;
Next, make sure your Emacs runs as a server. You can do this by adding this to your Emacs configuration.
(unless (server-running-p)
(add-hook 'after-init-hook 'server-start t)))
Now you can start the [[http://oauth.net/2][OAuth2]] authentication dance with =M-x soundklaus-connect=. You should get redirected to /SoundCloud/ and allow /soundklaus.el/ to access your account. After pressing the =Connect= button on the /SoundCloud/ page, the browser should open Emacs and set the =soundklaus-access-token= customization variable.
To setup this functionality on other operating systems take a look at the [[http://orgmode.org/worg/org-contrib/org-protocol.html#sec-3][system setup]] section in [[http://orgmode.org/worg/org-contrib/org-protocol.html][org-protocol.el]] and adapt it for /soundklaus.el/.
** Screenshot
[[https://raw.githubusercontent.com/r0man/soundklaus.el/master/screenshot.jpg]]
** License
Copyright © 2014-2019 [[https://github.com/r0man][r0man]]
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 3, or (at your option) any later version.