|
|
|
@ -30,9 +30,9 @@ class MusicSystemFunctionHandler { |
|
|
|
) |
|
|
|
|
|
|
|
// 注册媒体控制函数 |
|
|
|
registerMediaPlayFunction(client: client) |
|
|
|
registerMediaResumeFunction(client: client) |
|
|
|
registerMediaPauseFunction(client: client) |
|
|
|
registerMediaCloseFunction(client: client) |
|
|
|
// registerMediaCloseFunction(client: client) |
|
|
|
registerMediaPreviousFunction(client: client) |
|
|
|
registerMediaNextFunction(client: client) |
|
|
|
} |
|
|
|
@ -99,7 +99,7 @@ private class MusicSearchHandler: FunctionHandler { |
|
|
|
} |
|
|
|
|
|
|
|
/// 注册媒体播放函数 |
|
|
|
private func registerMediaPlayFunction(client: MCPClient) { |
|
|
|
private func registerMediaResumeFunction(client: MCPClient) { |
|
|
|
let parameters: [String: Any] = [ |
|
|
|
"type": "object", |
|
|
|
"properties": [:], |
|
|
|
@ -195,14 +195,14 @@ private class MediaPlayHandler: FunctionHandler { |
|
|
|
/// 媒体暂停处理器 |
|
|
|
private class MediaPauseHandler: FunctionHandler { |
|
|
|
func handle(arguments: [String: Any]) async throws -> String { |
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("MediaStop"), object: nil) |
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("MediaPause"), object: nil) |
|
|
|
return "{\"broadcast\": false,\"result\": \"已停止音乐播放\"}" |
|
|
|
} |
|
|
|
} |
|
|
|
/// 媒体暂停处理器 |
|
|
|
private class MediaCloseHandler: FunctionHandler { |
|
|
|
func handle(arguments: [String: Any]) async throws -> String { |
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("MediaPause"), object: nil) |
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("MediaStop"), object: nil) |
|
|
|
return "{\"broadcast\": false,\"result\": \"已暂停音乐播放\"}" |
|
|
|
} |
|
|
|
} |
|
|
|
|