Skip to content

🔌 Plugin Development Overview

The EchoMusic plugin system provides a highly flexible local extension mechanism, similar in concept to the plugin architectures of VS Code or Obsidian. Plugins can customize the UI, extend functionality, process audio data, and deeply integrate with the player.

Plugin System Architecture

Overall Architecture

┌────────────────────────────────────────┐
│           EchoMusic Application         │
│  ┌──────────┐  ┌──────────┐            │
│  │Main Window│  │Mini Player│            │
│  │(Electron) │  │(Separate) │            │
│  ├──────────┤  ├──────────┤            │
│  │Plugin A   │  │Plugin A   │ ← if      │
│  │Plugin B   │  │           │  miniPlayer│
│  │Plugin C   │  │           │  enabled   │
│  └──────────┘  └──────────┘            │
│  ┌──────────┐                          │
│  │Desktop    │                         │
│  │Lyrics     │                          │
│  │(Separate) │                          │
│  ├──────────┤                          │
│  │Plugin A   │ ← if desktopLyric       │
│  │           │   enabled               │
│  └──────────┘                          │
│       ▲                                │
│       │ ctx injection                  │
│       │                                │
│  ┌────┴─────┐                          │
│  │Plugin     │ Load / Unload /         │
│  │Manager    │ Lifecycle               │
│  └──────────┘                          │
└────────────────────────────────────────┘

Multi-Window Model

EchoMusic has three independent renderer windows, each with separate JS memory:

WindowDescriptionPlugin Participation
Main WindowFull player UI, settings, plugin management, etc.All enabled plugins loaded by default
Mini PlayerCompact mini player windowRequires runtime.miniPlayer: true in manifest
Desktop LyricFloating desktop lyrics windowRequires runtime.desktopLyric: true in manifest

If your plugin only operates on the main window (e.g., adding settings panels or registering pages), you don't need to enable miniPlayer or desktopLyric.

Plugin Lifecycle

  [User Enables Plugin]


  ┌─────────────┐     ┌──────────────────┐
  │ Load manifest│ ──▶ │ Validate version / │
  │              │     │ capabilities      │
  └─────────────┘     └──────┬───────────┘

                    ┌────────▼──────────┐
                    │ Version mismatch?  │
                    │ → Show "Incompatible│
                    │   version"          │
                    │ Block activation    │
                    └────────┬──────────┘
                             │ Pass
                    ┌────────▼──────────┐
                    │ Load entry JS (ESM)│
                    │ Inject ctx object  │
                    └────────┬──────────┘

                    ┌────────▼──────────┐
                    │ activate(ctx)      │
                    │ Plugin registers   │
                    │ resources          │
                    └────────┬──────────┘

              ┌──────────────┼──────────────┐
              │              │              │
              ▼              ▼              ▼
       Normal operation  Disable/Uninstall  Crash/Error
              │              │              │
              │       ┌──────▼──────┐       │
              │       │deactivate() │       │
              │       │Auto cleanup │       │
              │       │ctx.dispose()│       │
              │       └──────┴──────┘       │
              │                             │
              └──────────────┬──────────────┘

                    ┌────────▼──────────┐
                    │ Plugin stopped      │
                    │ Directory removed   │
                    │ on uninstall        │
                    │ KV data & error logs│
                    │ cleared             │
                    └───────────────────┘

Security Model

Trust Boundary

  • Plugins are user-enabled local code running in the Electron renderer process
  • EchoMusic does not sandbox plugins — they can access all renderer process APIs
  • Therefore, only enable plugins from trusted sources

Capabilities

Plugin access to sensitive APIs uses an explicit declaration mechanism. After declaring the required capability in the manifest, the corresponding ctx APIs become available:

CapabilityAPI Access Granted
audioSourcectx.player.audioSource.register() — Take over audio source resolution
audioSpectrumctx.audio.spectrum — Read/subscribe to audio spectrum
kugouApictx.kugou — Call Kugou Music API
localFilesctx.fs — Scan/read local files
lyricEffectsctx.lyricEffects.register() — Register lyric visual effects
lyricsctx.lyrics.registerResolver() — Provide custom lyrics
processctx.process.launch() — Launch native programs

Follow the principle of least privilege: only declare capabilities your plugin actually needs.

Development Environment Requirements

  • Node.js: 18+ recommended
  • Runtime: Browser ESM (Node.js built-in modules like fs, path are unavailable)
  • Vue dependency: Use ctx.vue, do not use bare imports (e.g. import { ref } from 'vue')
  • Build tools (optional): Use Vite / esbuild to bundle TypeScript or Vue SFC into a single ESM file

Documentation Navigation

DocumentAudienceContent
Getting Started →BeginnersBuild your first plugin from scratch
Manifest Reference →EveryoneComplete manifest.json field reference
Context API Reference →EveryoneComplete ctx API listing
UI Extension Guide →Frontend DevsPages, settings panels, context menus, component injection
Player & Audio →Audio DevsPlayback control, audio spectrum, lyrics system
Filesystem & Storage →Advanced DevsLocal files, KV storage, event listeners, appearance
Publishing & Distribution →Plugin AuthorsPlugin registry, versioning, packaging & release