Raxol.Plugins.Spotify (Raxol v2.0.1)

View Source

Spotify integration plugin for Raxol.

Provides music player functionality with playlist browsing, playback control, and search capabilities using the Spotify Web API.

Features

  • OAuth authentication
  • Now-playing display with progress bar
  • Playlist browsing and selection
  • Device management
  • Search (tracks, albums, artists)
  • Playback controls (play/pause/next/previous)
  • Volume control
  • Queue management

Configuration

Requires Spotify Developer credentials:

config :raxol, Raxol.Plugins.Spotify,
  client_id: System.get_env("SPOTIFY_CLIENT_ID"),
  client_secret: System.get_env("SPOTIFY_CLIENT_SECRET"),
  redirect_uri: "http://localhost:8888/callback"

Usage

# In your application
{:ok, state} = Raxol.Plugins.Spotify.SpotifyPlugin.init(opts)

# Handle input
{:ok, new_state} = Raxol.Plugins.Spotify.SpotifyPlugin.handle_input(" ", %{}, state)

# Render to buffer
buffer = Raxol.Plugins.Spotify.SpotifyPlugin.render(buffer, state)

Modes

The plugin operates in different modes:

  • :auth - Authentication flow
  • :main - Now-playing display
  • :playlists - Browse playlists
  • :devices - Device selection
  • :search - Search tracks/artists/albums
  • :volume - Volume control

Keyboard Controls

Main Mode

  • Space - Toggle play/pause
  • n - Next track
  • p - Previous track
  • l - View playlists
  • d - View devices
  • s - Search
  • v - Volume control
  • q - Quit

Playlist Mode

  • j/k - Navigate up/down
  • Enter - Select playlist
  • Esc - Back to main

Search Mode

  • Type to search
  • Enter - Execute search
  • j/k - Navigate results
  • Enter - Play selection
  • Esc - Back to main

Summary

Types

mode()

@type mode() :: :auth | :main | :playlists | :devices | :search | :volume

state()

@type state() :: %{
  mode: mode(),
  auth_status: :not_authenticated | :pending | :authenticated,
  api_client: any() | nil,
  now_playing: map() | nil,
  playback_state: map() | nil,
  playlists: [map()],
  devices: [map()],
  search_results: [map()] | nil,
  search_query: String.t(),
  volume: non_neg_integer(),
  selected_index: non_neg_integer(),
  error: String.t() | nil,
  last_update: DateTime.t(),
  config: keyword()
}