Last Music Player

A fast native Windows music player for local libraries, with optional remote playback through your own Music API. Offline playback comes first. Remote search, radio, lyrics, and imports stay behind a small provider contract you control.

Stable Release Windows 10/11 WinUI 3 / WASDK C++/WinRT SQLite 3 Last Projects License 1.0
Last Music Player home screen showing music lists, custom local mixes, playback control, and library views.

Overview

Last Music Player is a high-performance, native Windows music player built specifically for local music enthusiasts. It features native integration with the Windows Shell, seamless playback management, SQLite-backed library indexing, and a contract-driven structure allowing users to hook up external audio streaming servers (Music APIs) via plain HTTP endpoints.

Key Features

  • Local-First Play standard local formats (MP3, FLAC, M4A, WAV, Opus) with a blazing-fast startup time.
  • Gapless Engine Multi-source native queue manager fetches the next song block in advance for zero gap clicks.
  • Library Browser Browse by songs, albums, artists, and genres with SQLite-backed indexing.
  • Playlists & Mixes Build manual playlists and use auto-generated mixes.
  • Synced Lyrics Time-synced lyrics display when a Music API provider is configured.
  • Windows Shell Sync Integrates natively with SMTC (System Media Transport Controls), media keys, and system flyouts.
  • Google Cast Optional Cast output engine for streaming to Chromecast and Google Nest speakers.
  • Discord Rich Presence Optional now-playing status on Discord.
  • Music API Provider User-supplied remote catalog for search, streaming, radio, lyrics, and link imports via a simple HTTP contract.

Installation & Setup

Click the Download button above to get the latest release installer. Run the installer to configure the environment. Requires Windows 10 (2004+) or Windows 11.

Building from Visual Studio

To compile and build the client application locally:

  1. Clone the repository recursively to fetch submodules: git clone --recursive
  2. Open Last Music Player.slnx in Visual Studio 2022.
  3. NuGet packages should restore automatically. If not, right-click the solution and choose Restore NuGet Packages.
  4. Set the active architecture configuration to x64 (Debug or Release).
  5. Build and run. The output binaries will write to the build directories.

Building from Command Line

Use the MSBuild toolchain from the Visual Studio Developer Command Prompt to compile the project headless:

MSBuild Command
MSBuild.exe "Last Music Player.vcxproj" /t:Build /p:Configuration=Release /p:Platform=x64

The release binaries will write directly to: x64/Release/Last_Music_Player.exe

Custom Secrets (AppSecrets)

For optional features like Discord Rich Presence, the developer API secrets are excluded from Git to prevent leakage. You can configure them locally for custom builds.

Note: If AppSecrets.local.h is absent during compilation, the client falls back to AppSecrets.example.h and automatically disables Discord integrations.

Configuration Steps

  1. Navigate to the Backend/ directory.
  2. Copy the template file AppSecrets.example.h and name the new file AppSecrets.local.h.
  3. Open AppSecrets.local.h and insert your custom API client IDs.
AppSecrets.local.h
#pragma once

// Discord Application Client ID for Rich Presence integrations.
// Replace with your custom Discord Developer Portal Application ID.
#define LMP_DISCORD_CLIENT_ID "your-discord-app-id-here"

Architecture & Component Layout

Last Music Player separates components into distinct native layers. The Frontend manages the WinUI 3 presentation structure, while the Backend handles state, cache, hardware playback queues, and SQLite interactions.

WinUI 3 Frontend

MainWindow.xaml / Navigation

AudioPlayer

MediaPlayer / Gapless engine

DatabaseEngine

SQLite local storage & cache

ProviderClient

HTTP Music API Client

Windows SMTC

System Media Keys & Flyouts

User Provider Server

Remote Streams & Lyrics

Core Code Directory Structure

Directory Responsibility & Module Info
App.xaml* Main entry-point, WinUI life-cycle management, shell configuration, and application boot.
MainWindow/ Views, library browsers, playlists, now playing controls, queue visuals, and settings UI panels.
Backend/ Audio playback engine, SQLite integration, Google Cast client, Discord RPC client, settings, and lyrics services.
Frontend/ Navigation logic wrappers and converters, visual and layout helpers.
ThirdParty/sqlite/ Vendored SQLite database engine (amalgamated source).
installer/ Setup packaging configuration written for Inno Setup.

Gapless Playback Engine Flow

The AudioPlayer.cpp class manages smooth transitions by utilizing the native Windows.Media.Playback.MediaPlaybackList API. When gapless playback is enabled:

  • The currently playing track sits at index 0 of the playlist queue.
  • A lookahead worker pre-loads the next song, configuring the audio stream into index 1 of the list in advance.
  • When the current song terminates, the player transitions to the next track instantly without closing and reopening the audio channel.

SQLite Database Schema

Last Music Player manages the library metadata and user interactions locally using SQLite. The database stores local tracks scanned from disk, remote tracks resolving from the Provider API, local playlists, and configuration logs.

Table Name Table description.
Column Name Data Type Constraints & Metadata Description
Common Query Pattern
SQL Query
-- SQL query will display here

Database Versions & Schema Migration

The DB engine implements a version-gate check using PRAGMA user_version. The schema is currently at Version 6.

DB Version Migration Change Log
v2 Added column helpers to support remote media integrations (SourceKey, SourceKind, Provider, SourceUrl, etc.). Added playlist schema, and unique indices on source tracking components.
v4 Dropped columns supporting volume normalizations (ReplayGainDb) since that feature was deprecated, optimization clean-up.
v5 Rebranded default labels for remote imports: modified DateAddedText values matching remote source indicators to say "Music API" to prevent UI leakage.
v6 Schema version baseline optimization to prevent repetitive migration iterations, improving initialization speed.

Music API Provider Contract

If you configure a custom Music API Provider under settings, the player offloads catalog searching, album indexing, streaming, related radio, and synchronized lyrics requests to your provider base URL via HTTP.

GET /v1/endpoint Auth: Bearer Token

Endpoint description details.

URL Query Parameters
Parameter Type Status Description
Request & Response Models
-- Code snippet loader

Authentication Standard

The client app communicates the API key configured in settings in two ways:

  • JSON Endpoints: Rest query API calls from the client pass the key as an HTTP Authorization Bearer token header:
    Authorization: Bearer <api_key>
  • Media Streams & Artworks: Since Windows Media and image rendering pipelines perform native queries direct from the OS stack where custom headers cannot be attached, keys are passed via query strings:
    ?access_token=<api_key>

Troubleshooting & FAQ

Common issues encountered during development, installation, or configuration of Last Music Player client and provider stacks.

Why does the compiler throw access-violation exceptions on startup?
Make sure that the MediaPlayer instance inside AudioPlayer.cpp is not initialized during static/global variable setup. The constructor runs before init_apartment() has been called, causing ABI proxy failures. Ensure the client player instantiation is called lazily (e.g. on UI thread initialization).
Why are Equalizer controls disabled?
The user interface elements for the 10-band equalizer are visible in Settings but are currently disabled. The DSP audio effect is operational inside EqualizerEffect.cpp, but the UI is deactivated pending fine-tuning of the biquad audio filter coefficients to avoid crackling noise during playback adjustments.
Why isn't Google Cast detecting my casting devices?
Google Cast relies on network device discovery features. Ensure that the casting devices (like Chromecast or Google Nest speakers) are on the exact same local Wi-Fi/Ethernet subnet as the Windows desktop PC, and that network profiles on Windows are set to "Private" to allow device discoveries.
How are API requests handled if the provider times out?
JSON endpoints like search or lyrics checks are hard-capped with a 15-second timeout inside the client app. If the server does not respond within this window, the client aborts the request. Audio transcoding or file resolving operations should be handled under the streaming path (/v1/stream) which does not enforce this timeout constraint.
How does the local library scanner index track metadata?
The local library scanner (found under MainWindow.LibraryScan.cpp) runs background tasks that recursively crawl configured directories. It parses audio file headers for embedded tags (ID3, Vorbis, MP4 metadata) and saves them to the local SQLite catalog. Track cover artwork is extracted, written to the local app data folder, and referenced as the track's ArtworkUrl.
How is the local disk cache managed for remote music streams?
The client app integrates a local cache manager (StreamCache.cpp) which writes remote audio stream segments to temporary disk storage during active playback. If a track's sourceUrl is requested again, the client redirects the media pipeline to fetch bytes directly from local cache, saving bandwidth and preventing network latency gaps.
Why does the app lose connection with media keys and Windows Volume Flyout (SMTC)?
Windows manages media focus dynamically. If another application (such as Spotify or an active browser tab playing video) grabs exclusive SMTC focus, the OS stops routing media button presses to Last Music Player. Clicking play or pause inside the client app forces a re-registration of the player session to re-acquire focus.
How does the gapless playback engine pre-load the next track?
When a track is active in the native MediaPlaybackList, the AudioPlayer listens to item transitions. When the current track approaches its end, a lookahead thread resolves the stream URL of the next queue item, pre-loads it at index 1 of the playback list, and switches streams seamlessly when index 0 finishes.

Licensing & Contribution Terms

Last Music Player is distributed as a source-available project, not open-source. Using, modifying, or redistributing the application codebase is governed by specific licensing guidelines.

License Summary

The code is subject to the custom Last Projects License 1.0. Key tenets include:

  • Personal Use: Free for natural persons studying, building, or modifying the software for strictly personal and non-commercial purposes.
  • Modified Source: If you modify the codebase, you are required to publish the modified source code in a qualifying public Git repository within seven calendar days.
  • Organizational Restrictions: Non-profits, companies, government institutions, and schools require a separately negotiated commercial license.
  • Dataset Constraints: Using the source code or binary outputs for AI training datasets is strictly prohibited without explicit written consent.

Contributor Agreement (CLA)

By submitting code patches or pull requests to the project, you agree to grant ownership and redistribution rights to Last Projects. You can review the details in CLA.md.

For organization license requests or questions, reach out to: info@lastprojects.com.