Overview

Mewsic Plugin API

Plugins are plain JavaScript files placed in Mewsic's plugin directory. They run directly inside the app's webview environment and have full access to the window.Mewsic global the moment the app finishes initializing.

Recommended Developer Workflow
  • •
    Live Dev Reload (recommended, instant Ctrl+Shift+R updates without building)
  • •
    .mewsic Package Format (recommended for user distribution, auto-installs on double-click)
  • •
    VS Code or your preferred text editor (pure JS and CSS)

Once Mewsic is running, verify that the API is ready by making a quick test call in your entry point:

javascript
// Basic plugin entry point
console.log("Hello from my plugin!", window.Mewsic.version);

Plugin Format

A Mewsic plugin is a simple directory with the following structure:

structure
my-plugin.mewsic/
├── manifest.json   required
├── plugin.js       required
└── styles.css      optional

manifest.json

All fields except id, name, and version are optional.

json
{
  "id": "my-plugin",
  "name": "My Plugin",
  "version": "1.0.0",
  "description": "A short description shown in the Plugins tab.",
  "author": "your-name",
  "homepage": "https://example.com",
  "permissions": ["library", "audio", "settings"]
}
Field Type Description
id string Unique identifier. Used for storage namespacing and sidebar IDs. Use kebab-case.
name string Display name shown in the Plugins view.
version string Semver string, e.g. "1.0.0".
description string Short description displayed in the UI.
author string Your name or handle.
homepage string URL to your plugin's repository or homepage.
permissions string[] Informational only — tells users what the plugin touches. Not enforced.
config PluginConfigField[] Declarative settings schema auto-rendered in the plugin's Config tab and saved to local storage. ("settings" is also supported). See Mewsic.config →

plugin.js

Plain JavaScript — no bundler required. Wrap code in an IIFE to avoid polluting globals.

javascript
(() => {
  const M = window.Mewsic;
  // your plugin code here
})();

styles.css

Any valid CSS. Automatically injected into the app's <head> when the plugin loads. You have full access to Mewsic's CSS design tokens.

css
/* Available CSS variables */
/*
  --accent            primary accent color
  --accent-dim        darker shade of accent
  --accent-bright     lighter shade of accent
  --accent-muted      accent at low opacity (backgrounds)
  --accent-glow       accent for glow/shadow effects
  --text-accent       accent-colored text
  --surface-base      app background
  --surface-raised    card background
  --surface-overlay   elevated panel background
  --surface-glass     translucent glass background
  --text-primary      main text
  --text-secondary    secondary text
  --text-muted        muted/hint text
  --border-subtle     faint divider
  --border-glass      glass border
*/

/* Example: add a glow to all playing cards */
.music-card.playing {
  box-shadow: 0 0 20px var(--accent-glow);
}

/* Example: custom scrollbar color */
::-webkit-scrollbar-thumb {
  background: var(--accent-muted);
}

Installation

Mewsic supports multiple convenient installation workflows for users and creators.

USERS Double-click install (.mewsic)

Zip up the plugin folder and rename the extension to pluginname.mewsic. Double-clicking the file opens Mewsic and installs it automatically with a prompt.

bash
cd my-plugin.mewsic/
zip -r ../my-plugin.mewsic manifest.json plugin.js styles.css

USERS Manual install (Directory Paths)

Copy the unzipped .mewsic folder directly into the OS plugins directory:

Platform Plugin Directory Path
Linux ~/.config/mewsic/plugins/
macOS ~/Library/Application Support/dev.xeoniii.mewsic/plugins/
Windows %APPDATA%\dev.xeoniii.mewsic\plugins\

DEV Developers — live editing

Drop the .mewsic folder directly into the plugin directory while Mewsic is running. Edit plugin.js and styles.css freely — changes apply on the next window reload (Ctrl+Shift+R). No build step needed!

bash
mkdir -p ~/.config/mewsic/plugins/my-plugin.mewsic
# edit files, reload Mewsic to see changes (Ctrl+Shift+R)

API Namespaces

The Mewsic client runtime is divided into seven core namespaces:

Namespace Purpose Reference
Mewsic.player Playback control, position, volume, and queue management View docs →
Mewsic.library Track, virtual track, and playlist CRUD + download integration View docs →
Mewsic.audio Real-time DSP engine — 10-band EQ, convolution reverb, speed, presets View docs →
Mewsic.ui Views, custom tabs, sidebar icons, toasts, overlays, CSS injection View docs →
Mewsic.settings Persistent app configuration, hotkey remapping, and theme control View docs →
Mewsic.config Declarative plugin settings schemas, UI auto-generation, reactive subscriptions View docs →
Mewsic.storage Isolated per-plugin key-value storage backed by local state View docs →
Mewsic.events Core system event pub/sub and custom inter-plugin bus View docs →
API Overview
NAMESPACE

Mewsic.player

Full programmatic control over audio playback, track seeking, queue management, volume interpolation, and remote stream resolvers.

Getters

Property Type Description
currentTrack Track | null The currently active track object
isPlaying boolean Whether audio is playing
volume number Current volume level (0.0 – 1.0)
queue Track[] The active play queue
queueIndex number Index of the active track in the queue
currentTime number Playhead position in seconds
duration number Active track duration in seconds
shuffleEnabled boolean Whether shuffle mode is toggled on
repeatMode "off" | "one" | "all" Current repeat mode setting
currentPlaylistName string | null Name of active playlist, or null

Methods

javascript
Mewsic.player.play()
Mewsic.player.pause()
Mewsic.player.togglePlay()
Mewsic.player.next()
Mewsic.player.prev()
Mewsic.player.seek(seconds)
Mewsic.player.skipForward(seconds = 5)
Mewsic.player.skipBackward(seconds = 5)
Mewsic.player.setVolume(0.0 - 1.0)
Mewsic.player.toggleMute()
Mewsic.player.fadeVolume(targetVolume, durationMs)
Mewsic.player.setPlaybackRate(speed)   // 0.5 - 2.0
Mewsic.player.toggleShuffle()
Mewsic.player.setRepeatMode("off" | "one" | "all")
Mewsic.player.getState()               // snapshot of all player state

Queue Management

javascript
// Play a local track by its ID
await Mewsic.player.playTrack("track-id");

// Play a virtual/remote track directly
await Mewsic.player.playVirtualTrack({
  id: "spotify:track:4PTG3Z6ehGkBF3zIqYQGSy",
  title: "Stay",
  artist: "The Kid LAROI",
  album: "F*CK LOVE 3",
  duration: 141,
  filePath: "https://open.spotify.com/track/4PTG3Z6ehGkBF3zIqYQGSy",
  isVirtual: true,
  provider: "virtual",
  coverArt: "https://i.scdn.co/image/..."
});

// Replace the whole queue
await Mewsic.player.setQueue(tracks, startIndex);

Mewsic.player.addToQueue(track);
Mewsic.player.removeFromQueue("track-id");
Mewsic.player.clearQueue();

Stream Resolvers

Plugins can intercept playback of remote URLs (Spotify, SoundCloud, custom protocols) and dynamically resolve them to a playable direct audio URL before the engine attempts to buffer.

javascript
Mewsic.player.registerResolver(async (url) => {
  if (!url.startsWith("https://open.spotify.com/")) return null;

  const streamUrl = await mySpotifyProxy.resolve(url);
  return {
    url: streamUrl,           // required - direct playable audio URL
    title: "Stay",            // optional - overrides track metadata
    artist: "The Kid LAROI",
    duration: 141,
    coverArt: "https://..."
  };
});

Multiple resolvers can be registered simultaneously. They execute in order of registration; the first non-null return value is used.

NAMESPACE

Mewsic.library

Query and mutate local tracks, virtual cloud tracks, playlist collections, and trigger background music downloads using Mewsic's integrated downloader.

Getters

Property Type Description
tracks Track[] All indexed tracks (local + virtual tracks)
virtualTracks Track[] Only remote/plugin virtual tracks
playlists Playlist[] All user playlist objects
musicDir string Filesystem path to the user's primary music folder
isScanning boolean Whether a filesystem library scan is actively executing

Track Methods

javascript
Mewsic.library.getTrack("track-id");
Mewsic.library.search("query");              // searches title, artist, album
Mewsic.library.addTracks([...tracks]);
Mewsic.library.updateTrack(track);
Mewsic.library.addVirtualTrack(track);       // displays Virtual pill in UI
Mewsic.library.removeVirtualTrack("id");
Mewsic.library.purgeVirtualTracks();         // deletes all virtual tracks

Playlist Methods

javascript
Mewsic.library.getPlaylist("playlist-id");                    // Playlist | null
Mewsic.library.getPlaylistTracks("playlist-id");              // Track[]
Mewsic.library.addPlaylist(playlist);
Mewsic.library.updatePlaylist(playlist);
Mewsic.library.removePlaylist("playlist-id");
Mewsic.library.addTrackToPlaylist("track-id", "playlist-id");
Mewsic.library.removeTrackFromPlaylist(playlist, "track-id");
await Mewsic.library.rehydratePlaylist(playlist);
Mewsic.library.playPlaylist("playlist-id", startIndex = 0);

Download Integration

Triggers Mewsic's built-in yt-dlp downloader to fetch remote audio and save high-quality tags directly to the user's music folder.

javascript
await Mewsic.library.downloadTrack({
  title: "Get Lucky",
  artist: "Daft Punk",
  album: "Random Access Memories",
  coverArt: "https://...",
  url: "https://www.youtube.com/watch?v=5NV6Rdv1a3I",
  onProgress: (pct) => console.log(`${pct}% done`)
});
NAMESPACE

Mewsic.audio

Direct access to the real-time DSP audio processing chain, including a 10-band equalizer, convolution reverb, bass boost, volume boost, and DSP presets.

Getters

Property Type Description
reverbEnabled boolean Whether convolution reverb is active
reverbStrength number Reverb wet mix ratio (0.0 – 1.0)
bassBoost number Bass boost intensity in dB
volumeBoost number Hardware volume multiplier (0.5 – 3.0)
playbackSpeed number Playback speed rate (0.5 – 2.0)
eqGains number[] 10-band equalizer gains in dB (-12 to +12)
activePresetId string | null Currently applied EQ/DSP preset identifier
presets AudioPreset[] List of all saved and built-in audio presets

Methods

javascript
Mewsic.audio.setReverb(enabled, strength?)    // strength 0.0 - 1.0
Mewsic.audio.setBassBoost(db)
Mewsic.audio.setVolumeBoost(multiplier)       // 0.5 - 3.0
Mewsic.audio.setPlaybackSpeed(speed)          // 0.5 - 2.0
Mewsic.audio.setEqGain(bandIndex, db)         // 0 - 9
Mewsic.audio.setEqGains([...10 values])       // set all bands at once
Mewsic.audio.resetEq()
Mewsic.audio.resetAll()                       // reset EQ + all effects to defaults
Mewsic.audio.applyPreset("preset-id")
Mewsic.audio.savePreset("My Preset")
Mewsic.audio.deletePreset("preset-id")
Mewsic.audio.getState()                       // snapshot of all DSP state
NAMESPACE

Mewsic.ui

Extend Mewsic's interface by registering custom tabs, sidebar icons, search providers, toast notifications, floating overlays, and custom stylesheets.

Getters

Property Type Description
activeView string Currently visible navigation view or tab id
theme "dark" | "light" Active base color theme mode
accentColor string Active accent theme token (e.g. "mint", "violet", "amber")
guiScale number GUI scaling factor (0.75 – 1.5)
isFullscreen boolean Whether Mewsic is currently in fullscreen mode

Navigation & Appearance

javascript
Mewsic.ui.setView("library")         // any built-in view id
Mewsic.ui.openLibrary()
Mewsic.ui.openPlayer()
Mewsic.ui.openSettings()
Mewsic.ui.openPlaylist("playlist-id")
Mewsic.ui.openPluginConfig("my-plugin") // open plugin manager directly to config tab
Mewsic.ui.setSearchQuery("query")    // pre-fill the search bar

Mewsic.ui.setTheme("dark" | "light")
Mewsic.ui.setAccentColor("mint")     // any AccentPreset id
Mewsic.ui.setGuiScale(1.0)          // 0.75 - 1.5

Toast Notifications

javascript
const id = Mewsic.ui.addNotification("Syncing...", "info", 0, true);
Mewsic.ui.updateNotification(id, { message: "Synced!", type: "success", loading: false });
Mewsic.ui.removeNotification(id);

type can be "info" | "success" | "error". Duration is in milliseconds; passing 0 keeps the toast persistent until closed.

Custom Views & Sidebar Components

Register a clickable icon in Mewsic's navigation sidebar linked to your own custom tab renderer. The render function receives a context object with plugin metadata, config state, and reactive update listeners:

javascript
Mewsic.ui.registerSidebarComponent("spotify", {
  name: "Spotify",
  icon: "<svg>...</svg>",   // raw SVG string
  viewId: "plugin:spotify"
});

Mewsic.ui.registerTab("plugin:spotify", {
  render: (container, context) => {
    // context contains:
    // context.viewId: string ("plugin:spotify")
    // context.pluginId: string
    // context.config: Record<string, any>
    // context.getConfig(key)
    // context.setConfig(key, value)
    // context.onConfigChange((newConfig, changedKey) => { ... })

    container.innerHTML = `
      <div class="p-6">
        <h1 class="text-xl font-bold">Spotify Dashboard</h1>
        <p>Current Quality: ${context.config.streamQuality || '320k'}</p>
        <button id="btn-cfg" class="btn-accent px-4 py-2 mt-4 rounded-xl">
          Open Plugin Settings
        </button>
      </div>
    `;

    container.querySelector("#btn-cfg").onclick = () => {
      Mewsic.ui.openPluginConfig(context.pluginId);
    };

    context.onConfigChange((newConfig, changedKey) => {
      console.log(`Setting [${changedKey}] changed:`, newConfig[changedKey]);
    });
  },
  cleanup: () => {
    // called when tab is unregistered or plugin unloads
  }
});

// Cleanup when needed
Mewsic.ui.unregisterSidebarComponent("spotify");
Mewsic.ui.unregisterTab("plugin:spotify");

Dedicated Standalone Config Views: If you navigate to or register a view ID matching plugin-config:<pluginId> or config:<pluginId>, Mewsic automatically renders the complete interactive settings form for that plugin!

Overlays & Dynamic CSS Injection

javascript
// Inject an overlay DOM element
const el = document.createElement("div");
el.textContent = "♫";
el.style.pointerEvents = "auto";
Mewsic.ui.registerOverlay("now-playing-badge", el);
Mewsic.ui.removeOverlay("now-playing-badge");

// Inject or remove stylesheet directly
Mewsic.ui.injectCSS("my-plugin", `
  .sidebar { border-right: 2px solid #1bd96a; }
`);
Mewsic.ui.removeCSS("my-plugin");
NAMESPACE

Mewsic.settings

Direct access to app configuration, Discord rich presence, system tray settings, view display modes, and global keyboard shortcut maps.

Getters

Property Type
theme "dark" | "light"
accentColor string
guiScale number
discordEnabled boolean
systemNotifications boolean
trayEnabled boolean
smoothScrollEnabled boolean
repeatMode "off" | "one" | "all"
shuffleEnabled boolean
libraryViewMode "grid" | "list"
homeViewMode "grid" | "list"
playlistViewMode "grid" | "list"
shortcuts ShortcutMap (copy)

Setters & Shortcut Remapping

javascript
Mewsic.settings.setTheme("dark" | "light")
Mewsic.settings.setAccentColor("violet")
Mewsic.settings.setGuiScale(1.0)               // 0.75 - 1.5
Mewsic.settings.setDiscordEnabled(true)
Mewsic.settings.setSystemNotifications(false)
Mewsic.settings.setTrayEnabled(true)           // also syncs with OS tray
Mewsic.settings.setSmoothScrollEnabled(true)
Mewsic.settings.setRepeatMode("all")
Mewsic.settings.setShuffle(true)
Mewsic.settings.setLibraryViewMode("grid")
Mewsic.settings.setHomeViewMode("list")
Mewsic.settings.setPlaylistViewMode("grid")

// Remap keyboard shortcut bindings
Mewsic.settings.setShortcut("togglePlay", "k")
Mewsic.settings.setShortcut("volumeUp", "=", { ctrl: true })
Mewsic.settings.resetShortcuts()

// Snapshot: Plain object copy of all settings
const all = Mewsic.settings.get();

Valid action names for setShortcut: togglePlay, skipForward, skipBackward, playNext, playPrev, volumeUp, volumeDown.

NAMESPACE

Mewsic.config

Declarative schema registration, live reactive settings management, and automated UI form generation for plugins. Settings are automatically rendered under the Config tab in the plugin manager, persistently saved in client local storage (mewsic_plugin_config_<pluginId>), and adapt in real time across the UI without requiring an app reload.

Defining Configuration in manifest.json

Plugin authors can declare configuration options directly inside their manifest.json. When Mewsic loads the plugin, its schema is registered automatically. Both "config" and "settings" keys are supported.

json
{
  "name": "Last.fm Scrobbler",
  "version": "1.0.0",
  "description": "Scrobbles your played tracks to Last.fm in real time.",
  "author": "MusicLover",
  "config": [
    {
      "key": "apiKey",
      "label": "API Key",
      "type": "string",
      "placeholder": "Enter Last.fm API Key",
      "description": "Your registered Last.fm application API key."
    },
    {
      "key": "apiSecret",
      "label": "API Secret",
      "type": "password",
      "placeholder": "Enter Last.fm Secret Token",
      "description": "Your application secret key."
    },
    {
      "key": "scrobbleDelay",
      "label": "Scrobble Threshold (%)",
      "type": "number",
      "default": 50,
      "min": 10,
      "max": 90,
      "step": 5,
      "description": "Percentage of track duration played before submitting scrobble."
    },
    {
      "key": "scrobbleMode",
      "label": "Scrobble Mode",
      "type": "select",
      "default": "all",
      "options": [
        { "label": "All Tracks", "value": "all" },
        { "label": "Local Only", "value": "local" },
        { "label": "Virtual Only", "value": "virtual" }
      ],
      "description": "Filter which types of tracks are scrobbled."
    },
    {
      "key": "autoLove",
      "label": "Auto-Love Favorited Songs",
      "type": "boolean",
      "default": true,
      "description": "Automatically send a Love rating to Last.fm when adding a track to Favorites."
    },
    {
      "key": "badgeColor",
      "label": "Status Badge Color",
      "type": "color",
      "default": "#d51007",
      "description": "Custom color used for Last.fm status overlays."
    }
  ]
}

Supported Field Types (PluginConfigField)

Type UI Component Schema Properties Description
boolean Toggle switch key, label, default, description Simple true/false toggle switch.
string | text Text input key, label, default, placeholder, description Single-line standard text input.
password Masked input key, label, placeholder, description Password field with reveal/hide eye button.
number Numeric input key, label, default, min, max, step, description Numeric input with optional min/max bounds and step.
select Dropdown select key, label, default, options, description Dropdown. options can be string[] or { label, value }[].
color Color picker key, label, default, description Color swatch picker with interactive hex input.

Programmatic API Reference

Plugins can register schemas dynamically, query values, listen to live reactive updates, and set config options programmatically:

javascript
// 1. Register a schema dynamically at runtime
Mewsic.config.register("my-plugin", [
  {
    key: "streamQuality",
    label: "Streaming Quality",
    type: "select",
    default: "high",
    options: [
      { label: "High (320kbps)", value: "high" },
      { label: "Standard (192kbps)", value: "standard" },
      { label: "Low (128kbps)", value: "low" }
    ]
  },
  {
    key: "cacheEnabled",
    label: "Enable Offline Cache",
    type: "boolean",
    default: true
  }
]);

// 2. Get a single value (returns schema default if not modified)
const quality = Mewsic.config.get("my-plugin", "streamQuality");

// 3. Get all values as a dictionary
const config = Mewsic.config.getAll("my-plugin");
console.log(config.streamQuality, config.cacheEnabled);

// 4. Set values (persists to storage and notifies all listeners)
Mewsic.config.set("my-plugin", "streamQuality", "standard"); // single key
Mewsic.config.set("my-plugin", {                             // batch update
  streamQuality: "high",
  cacheEnabled: false
});

// 5. Reset to schema defaults
Mewsic.config.reset("my-plugin", "streamQuality"); // single key
Mewsic.config.reset("my-plugin");                 // all keys

// 6. Get registered schema definition array
const schema = Mewsic.config.getSchema("my-plugin");

// 7. Subscribe to real-time changes (returns unsubscribe fn)
const unsubscribe = Mewsic.config.onChange("my-plugin", (newConfig, changedKey) => {
  console.log(`Setting [${changedKey}] changed to:`, newConfig[changedKey]);
  if (changedKey === "streamQuality") {
    updateAudioBufferQuality(newConfig.streamQuality);
  }
});

// To stop listening later:
// unsubscribe();

UI Helpers & View Integration

Mewsic provides seamless UI helpers to open settings tabs and access configuration directly inside custom views:

javascript
// Open the Mewsic plugin manager directly to your plugin's config tab
Mewsic.ui.openPluginConfig("my-plugin");

// In custom tabs, context includes direct config bindings
Mewsic.ui.registerTab("plugin:my-plugin:dashboard", {
  render: (container, context) => {
    // context.viewId: string
    // context.pluginId: string ("my-plugin")
    // context.config: Record<string, any>
    // context.getConfig(key)
    // context.setConfig(key, value)
    // context.onConfigChange((newConfig, changedKey) => { ... })

    container.innerHTML = `
      <div class="p-6">
        <h1 class="text-xl font-bold">My Plugin Dashboard</h1>
        <p>Current Quality: ${context.config.streamQuality}</p>
        <button id="btn-toggle" class="btn-accent px-4 py-2 mt-4 rounded-xl">
          Toggle Cache (Currently: ${context.config.cacheEnabled})
        </button>
      </div>
    `;

    container.querySelector("#btn-toggle").onclick = () => {
      context.setConfig("cacheEnabled", !context.config.cacheEnabled);
    };

    context.onConfigChange((newConfig) => {
      console.log("Config updated from settings view!", newConfig);
    });
  },
  cleanup: () => {}
});

Dedicated Standalone Config Views: If you navigate to or register a view ID matching plugin-config:<pluginId> or config:<pluginId>, Mewsic automatically renders the complete interactive settings form for that plugin!

Configuration Events

Event Name Source Payload Description
plugin_config_changed Mewsic.events.on { pluginId, key, value, config } Fired when any plugin config value changes.
plugin-config-updated window (CustomEvent) e.detail: { pluginId, key, config } DOM event dispatched on window when settings are saved.
plugin-config-registered window (CustomEvent) e.detail: { pluginId, schema } DOM event dispatched on window when a schema is registered.
NAMESPACE

Mewsic.storage

Namespaced, sandboxed key-value persistent storage. All keys are automatically isolated under mewsic_plugin_<pluginId>_ with JSON serialization.

javascript
Mewsic.storage.set("my-plugin", "token", "ya29.a0...");
const token = Mewsic.storage.get("my-plugin", "token");
Mewsic.storage.remove("my-plugin", "token");

// Inspect what a plugin has stored
const keys = Mewsic.storage.keys("my-plugin");  // string[]

// Wipe everything this plugin has stored
Mewsic.storage.clear("my-plugin");
NAMESPACE

Mewsic.events

Event emitter and listener system for tracking real-time client state changes or broadcasting custom inter-plugin messages.

System Events

javascript
const handler = (track) => console.log("Now playing:", track?.title);
Mewsic.events.on("track_changed", handler);
Mewsic.events.off("track_changed", handler);

// Auto-unsubscribe after the first event fires
Mewsic.events.once("track_changed", (track) => {
  console.log("First track loaded:", track?.title);
});
Event Name Payload Type
track_changed Track | null
playback_state_changed boolean (isPlaying)
time_changed number (seconds)
volume_changed number (0.0 – 1.0)
shuffle_changed boolean
repeat_changed "off" | "one" | "all"
queue_changed Track[]
view_changed string (view id)
playlist_changed string | null (playlist name)
library_changed Track[]
playlists_changed Playlist[]
theme_changed "dark" | "light"
accent_changed string
reverb_changed { enabled: boolean, strength: number }
bass_boost_changed number
volume_boost_changed number
playback_speed_changed number
eq_changed number[] (10 band values)
track_loading { trackId: string }
track_error { trackId: string, error: string }
plugin_config_changed { pluginId: string, key: string, value: any, config: Record<string, any> }

Custom Inter-Plugin Events

Plugins can broadcast and listen for arbitrary events across an isolated custom event bus:

javascript
// Plugin A broadcasts
Mewsic.events.emit("my-plugin:sync-done", { count: 42 });

// Plugin B listens
const handler = (data) => console.log("Synced", data.count, "tracks");
Mewsic.events.onCustom("my-plugin:sync-done", handler);
Mewsic.events.offCustom("my-plugin:sync-done", handler);
SCHEMA

Track Object Reference

The standard TypeScript interface for all track objects within Mewsic:

typescript
interface Track {
  id: string;
  title: string;
  artist: string;
  album: string;
  duration: number;        // seconds
  filePath: string;        // local path or remote URL
  coverArt?: string;
  isVirtual?: boolean;     // true for remote/plugin-provided tracks
  provider?: string;       // e.g. "virtual", "spotify"
  genre?: string;
  year?: number;
  trackNumber?: number;
  fileSize?: number;
  bitrate?: number;
}
EXAMPLE

Complete Plugin Example

A comprehensive walkthrough demonstrating custom sidebar views, persistent storage, real-time events, audio DSP manipulation, and stream resolvers in one complete script:

javascript
(() => {
  const M = window.Mewsic;
  const ID = "demo-plugin";

  // Persist a setting across sessions
  let callCount = parseInt(M.storage.get(ID, "callCount") || "0", 10);

  // React to track changes
  M.events.on("track_changed", (track) => {
    callCount++;
    M.storage.set(ID, "callCount", callCount);

    if (!track) return;

    // Auto-apply a warm EQ whenever a track starts
    M.audio.setEqGains([4, 3, 1, 0, 0, 0, 0, -1, -2, -3]);

    // Show a toast with the track title
    M.ui.addNotification(`Now playing: ${track.title}`, "info", 2000, "Demo Plugin");
  });

  // Add a virtual track to the library
  M.library.addVirtualTrack({
    id: `${ID}:example-001`,
    title: "Example Stream",
    artist: "Demo Artist",
    album: "Plugin Tracks",
    duration: 180,
    filePath: "https://example.com/stream.mp3",
    isVirtual: true,
    provider: ID,
    coverArt: ""
  });

  // Register a resolver — intercept plugin:// URLs
  M.player.registerResolver(async (url) => {
    if (!url.startsWith("plugin://demo/")) return null;
    const id = url.replace("plugin://demo/", "");
    return { url: `https://example.com/audio/${id}.mp3` };
  });

  // Register a search provider
  M.ui.registerSearchProvider(ID, {
    name: "Demo Source",
    search: async (query) => {
      return [{
        id: `${ID}:search-result`,
        title: `Result for "${query}"`,
        artist: "Demo",
        album: "",
        duration: 120,
        coverArt: "",
        url: "plugin://demo/result"
      }];
    }
  });

  // Register sidebar button
  M.ui.registerSidebarComponent(ID, {
    name: "Demo Plugin",
    icon: `
      
    `,
    viewId: `plugin:${ID}`
  });

  // Render custom view
  M.ui.registerTab(`plugin:${ID}`, {
    render: (container) => {
      container.innerHTML = "";
      container.style.cssText = "padding:24px;color:var(--text-primary);font-family:inherit;";

      const state = M.player.getState();
      const settings = M.settings.get();

      container.innerHTML = `
        

Demo Plugin

Showing all plugin API patterns

Now Playing

${state.currentTrack?.title ?? "Nothing"}

${state.currentTrack?.artist ?? "—"}

Stats

Tracks seen: ${callCount}

Theme: ${settings.theme}

`; container.querySelector("#dp-toggle-theme").onclick = () => { M.settings.setTheme(M.settings.theme === "dark" ? "light" : "dark"); }; container.querySelector("#dp-reset-eq").onclick = () => { M.audio.resetEq(); M.ui.addNotification("EQ reset to flat", "info", 2000); }; }, cleanup: () => {} }); // Cross-plugin messaging example M.events.emit(`${ID}:loaded`, { version: "1.0.0" }); M.events.onCustom(`${ID}:loaded`, (data) => { console.log("[Demo Plugin] Received own load event:", data); }); console.log("[Demo Plugin] Loaded. Track count:", callCount); })();
SYSTEM

File Associations

When installed via an official package (.deb, .rpm, .msi, .dmg), Mewsic registers standard desktop OS file handlers:

Extension OS Action
.mewsic Install the plugin package automatically and prompt for instant client reload
.mp3, .flac, .wav, .ogg, .m4a, .aac, .opus, .aiff, .aif, .wma Launch Mewsic and initiate high-fidelity local playback immediately
Built for Mewsic Desktop
Back to top