MetingJS Documentation

repository·master·Indexed 23 days ago

https://github.com/metowolf/metingjs

A web component that provides a music player interface using APlayer. MetingJS fetches music metadata and streams from platforms such as NetEase, Tencent, and Xiami via the Meting API. It supports the <meting-js> custom element for rendering players via playlist IDs, automatic link detection, or self-hosted media with direct URLs.

Tokens
1.9K
Snippets
3
Records
8
Agent score
30%

What's inside MetingJS

  1. Configure custom Meting APIs

    master

    MetingJS allows you to use a self-hosted Meting API. You can configure this globally or on a per-element basis. The API selection follows this priority order:

    1. Element api attribute (highest priority)
    2. Global window.meting_api variable
    3. Built-in default API (lowest priority)

    Global Configuration

    Define a meting_api variable in a <script> tag before loading Meting.min.js.

    Per-Element Configuration

    Use the api attribute directly on the <meting-js> tag.

    <!-- Global Configuration -->
    <script>
    var meting_api='http://example.com/api.php?server=:server&type=:type&id=:id&auth=:auth&r=:r';
    </script>
    <script src="dist/Meting.min.js"></script>
    
    <!-- Per-Element Configuration -->
    <meting-js
    	server="netease"
    	type="song"
    	id="28391863"
    	api="https://your-custom-api.com/meting?server=:server&type=:type&id=:id&r=:r">
    </meting-js>
  2. Install MetingJS via CDN

    master

    To use MetingJS, you must first include the APlayer dependencies (CSS and JS) and then include the MetingJS library. You can use the following CDNs:

    • https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js
    • https://unpkg.com/meting@2/dist/Meting.min.js
    <!-- require APlayer -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
    <script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
    <!-- require MetingJS -->
    <script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
  3. Quick Start: Use MetingJS with different media sources

    master

    MetingJS uses the <meting-js> custom element to render music players. You can load music from various platforms, via direct links, or from self-hosted media.

    Netease Playlist

    Use server="netease", type="playlist", and the playlist id.

    Use the auto attribute with a music link (supports netease, tencent, xiami).

    Self-hosted Media

    Provide name, artist, url, and cover manually.

    Fixed Mode with Lyrics

    Set fixed="true" and include lyric text inside a <pre hidden> tag within the <meting-js> element.

    <!-- Netease Playlist -->
    <meting-js
    	server="netease"
    	type="playlist"
    	id="60198">
    </meting-js>
    
    <!-- Automatic Link Detection -->
    <meting-js
    	auto="https://y.qq.com/n/yqq/song/001RGrEX3ija5X.html">
    </meting-js>
    
    <!-- Self-hosted Media -->
    <meting-js
    	name="rainymood"
    	artist="rainymood"
    	url="https://rainymood.com/audio1110/0.m4a"
    	cover="https://rainymood.com/i/badge.jpg">
    </meting-js>
    
    <!-- Fixed Mode with Lyric text -->
    <meting-js
    	name="rainymood"
    	artist="rainymood"
    	url="https://rainymood.com/audio1110/0.m4a"
    	cover="https://rainymood.com/i/badge.jpg"
    	fixed="true">
    	<pre hidden>
    		[00:00.00]This
    		[00:04.01]is
    		[00:08.02]lyric
    	</pre>
    </meting-js>
  4. Automatic link parsing with the 'auto' attribute

    master

    If you provide a URL to the auto attribute, MetingJS will attempt to extract the server, type, and id using predefined regex patterns. This allows you to simply paste a music service URL into the component.

    Supported patterns include:

    • NetEase (music.163.com): song, album, artist, playlist, discover/toplist.
    • Tencent (y.qq.com): song, album, singer, playsquare, playlist.
    • Xiami (xiami.com): song, album, artist, collect.
  5. Use the <meting-js> Web Component

    master
    MetingJS provides a custom HTML element <meting-js> that embeds an APlayer music player. The component automatically parses attributes from the HTML tag to configure the player. It requires APlayer to be available on the window object and fetch support.
  6. Configure <meting-js> via attributes

    master

    The <meting-js> component accepts several attributes to define the music source and player behavior. Attributes are automatically camelCased (e.g., lrc-type becomes lrcType).

    Music Metadata Attributes

    These attributes define the music content:

    • server: The music server (e.g., netease, tencent, xiami).
    • type: The type of content (e.g., song, album, artist, playlist).
    • id: The unique identifier for the music content.
    • api: The API endpoint URL. Defaults to https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r if not provided or if window.meting_api is set.
    • auth: Authentication token for the API.
    • auto: A URL used to automatically detect the server, type, and id via regex patterns.
    • name / title: The name of the audio.
    • artist / author: The artist of the audio.
    • url: Direct URL to the audio file (overrides API-based loading).
    • cover / pic: URL to the cover image.
    • lyric / lrc: The lyrics text.

    APlayer Configuration Attributes

    Any other attributes passed to the element are passed directly to the underlying APPlayer instance as configuration options. Common options include:

    • mutex: Boolean. If true, only one player can play at a time.
    • lrcType: Integer. The type of lyrics rendering (e.g., 3 for standard).
    • storageName: String. The name used for local storage.
    • auto: Boolean. If true, the component will attempt to parse the auto attribute link.
  7. Configure MetingJS element options

    master

    The <meting-js> element accepts several attributes to control player behavior and appearance.

    Required Attributes:

    • id: song id / playlist id / album id / search keyword
    • server: music platform: netease, tencent, kugou, xiami, baidu
    • type: song, playlist, album, search, artist

    Optional Attributes:

    • auto: music link, support: netease, tencent, xiami
    • api: custom api url
    • fixed: boolean, enable fixed mode
    • mini: boolean, enable mini mode
    • autoplay: boolean, audio autoplay
    • theme: main color (e.g., #2980b9)
    • loop: player loop play, values: 'all', 'one', 'none'
    • order: player play order, values: 'list', 'random'
    • preload: values: 'none', 'metadata', 'auto'
    • volume: default volume (0-1, default 0.7)
    • mutex: boolean, prevent playing multiple players at once (default true)
    • lrc-type: lyric type
    • list-folded: boolean, whether list should be folded at first
    • list-max-height: max height of the list (e.g., 340px)
    • storage-name: localStorage key for player settings
  8. Direct audio loading via 'url' attribute

    master

    If the url attribute is provided, MetingJS skips the API fetch and loads the audio directly. When using url, you can also provide metadata via other attributes:

    • name or title: Audio name.
    • artist or author: Artist name.
    • cover or pic: Cover image URL.
    • lyric or lrc: Lyrics content.
    • type: Content type.

    If the element contains text (innerText), that text is used as the lyrics (lrc).