Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Aug 18, 2024
1 parent ebea81c commit 8e9ebdf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
50 changes: 50 additions & 0 deletions docs/mobile/scheme-url.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
id: scheme-url
title: Scheme URL 支持
---

从v1.6.0起支持 Scheme URL,可以使用此功能从浏览器等场景下调用LX Music

调用传参格式与PC端的一致,但目前仅支持以下 URL:

### `data`方式传参

以经过URL编码的JSON数据传参,例:`lxmusic://music/play?data=xxxx`,其中`xxxx`为经过URL编码后的JSON数据,JSON数据内容取决于下表的参数部分

| 描述 | URL | 参数
| --- | --- | ---
| 播放歌单 | `songlist/play` | `source<String>`(源,必须)<br />`id<String/Number>`(歌单ID,可选)<br />`url<String>`(歌单URL,可选)其中`id``url`必需传一个<br />`index<Number>`(播放第几首歌,可选,从0开始)
| 播放歌曲 | `music/play` | `name<String>`(歌曲名,必传)<br />`singer<String>`(艺术家名,必传)<br />`source<String>`(源,必传)<br />`songmid<String/Number>`(歌曲ID,必传)<br />`img<String>`(歌曲图片链接,选传)<br />`albumId<String/Number>`(歌曲专辑ID,选传)<br />`interval<String>`(格式化后的歌曲时长,选传,例:`03:55`)<br />`albumName<String>`(歌曲专辑名称,选传)<br />`types<Object>`(歌曲可用音质数组,必传,<br />数组格式:`[{"type": "<音质>", size: "<格式化后的文件大小,选传>", hash: "<kg源必传>"}]`,<br />例:`[{"type": "128k", size: "3.56M"}, {"type": "320k", size: null}]`)<br /><br />以下为平台特定参数:<br />`hash<String>`(歌曲hash,kg源必传)<br />`strMediaMid<String>`(歌曲strMediaMid,tx源必传)<br />`albumMid<String>`(歌曲albumMid,tx源专用,选传)<br />`copyrightId<String>`(歌曲copyrightId,mg源必传)<br />`lrcUrl<String>`、`trcUrl<String>`、`mrcUrl<String>`(歌曲lrcUrl、trcUrl与mrcUrl,mg源专用,选传)
| 搜索并播放歌曲 | `music/searchPlay` | `name<String>`(歌曲名,必须)<br />`singer<String>`(歌手,可选)<br />`albumName<String>`(专辑名,可选)<br />`interval<String>`(时长,`xx:xx` 的形式,可选)<br />`playLater<Boolean>`(是否稍后播放,可选,默认 `false` 立即播放)

#### 以data传参的例子

以经过URL编码的JSON数据传参,例:`lxmusic://music/play?data=xxxx`,其中xxxx为经过URL编码后的JSON数据

- 打开歌单:`lxmusic://songlist/play?data=%7B%22source%22:%22kw%22,%22id%22:%223373919903%22%7D`
- 搜索歌曲:`lxmusic://music/search?data=%7B%22keywords%22:%22%E7%AA%81%E7%84%B6%E7%9A%84%E8%87%AA%E6%88%91%22%7D`

### `URL`方式传参

由于URL传参只适用于简单传参场景,所以目前只支持以下功能的调用:

| 描述 | URL | 参数
| --- | --- | ---
| 搜索并播放歌曲 | `music/searchPlay/{name-singer}` | `name-singer` (歌曲名,必须),可以只传入歌曲名,也可以传入 **`歌曲名-歌手名`**
| 播放歌曲 | `player/play` |
| 暂停播放 | `player/pause` |
| 切换下一曲 | `player/skipNext` |
| 切换上一曲 | `player/skipPrev` |
| 切换播放或暂停 | `player/togglePlay` |
| 收藏当前播放的歌曲 | `player/collect` |
| 取消收藏当前播放的歌曲 | `player/uncollect` |
| 不喜欢当前播放的歌曲 | `player/dislike` |

#### 以URL传参的例子

`lxmusic://`拼接上表中填充参数后的URL即可,填充参数时最好将参数单独转一下URL编码,否则若参数中存在特殊字符(如`/`)将导致异常的调用

- 搜索并播放歌曲`lxmusic://music/searchPlay/%E7%AA%81%E7%84%B6%E7%9A%84%E8%87%AA%E6%88%91`
- 切换下一曲:`lxmusic://player/skipNext`

相关issue看:[https://github.com/lyswhut/lx-music-desktop/issues/1056](https://github.com/lyswhut/lx-music-desktop/issues/1056)
5 changes: 5 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const sidebars = {
{ type: 'autogenerated', dirName: 'mobile/faq' }
],
},
{
type: 'doc',
id: 'mobile/scheme-url', // document ID
label: 'Scheme URL支持', // sidebar label
},
{
type: 'doc',
id: 'mobile/statusbar-lyric', // document ID
Expand Down

0 comments on commit 8e9ebdf

Please sign in to comment.