We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
使用 Orpheus.addListener(eventName, callback) 进行监听。
Orpheus.addListener(eventName, callback)
onPlaybackStateChanged
{ state: PlaybackState }
onIsPlayingChanged
{ status: boolean }
onTrackFinished
{ trackId, finalPosition, duration }
onPositionUpdate
{ position, duration, buffered }
onPlayerError
{ code, message }
onDownloadUpdated
DownloadTask
onPlaybackSpeedChanged
{ speed: number }
注意: onTrackStarted 事件在 v0.9.0+ 已移除,请使用 Headless Task。
onTrackStarted
为了在 App 后台或被杀掉进程时仍能处理切歌等逻辑(如更新通知栏或以前的 onTrackStarted 逻辑),你需要注册 Headless Task。
import { registerOrpheusHeadlessTask } from "@roitium/expo-orpheus"; registerOrpheusHeadlessTask(async (event) => { // 目前主要处理 TrackStarted 事件 if (event.eventName === "onTrackStarted") { console.log("开始播放:", event.trackId); console.log("原因:", event.reason); // 0: REPEAT, 1: AUTO, 2: SEEK, 3: PLAYLIST_CHANGED } });
必须在 index.js 或应用启动的最早时期注册。
index.js