29 changed files with 1495 additions and 959 deletions
@ -0,0 +1,282 @@ |
|||
import Foundation |
|||
import qq_music |
|||
|
|||
class QQMusicSystemFunctionHandler { |
|||
|
|||
// 添加 registerAllFunctions 方法 |
|||
func registerAllFunctions(client: MCPClient) { |
|||
// 注册QQ音乐搜索和播放功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_searchandplay_songs", |
|||
description: "搜索并播放QQ音乐歌曲", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [ |
|||
"keyword": [ |
|||
"type": "string", |
|||
"description": "搜索关键词" |
|||
] |
|||
], |
|||
"required": ["keyword"] |
|||
], |
|||
handler: QQMusicSearchHandler() |
|||
) |
|||
|
|||
// 注册暂停功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_pause", |
|||
description: "暂停QQ音乐播放", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicPauseHandler() |
|||
) |
|||
|
|||
// 注册恢复播放功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_resume", |
|||
description: "恢复QQ音乐播放", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicResumeHandler() |
|||
) |
|||
|
|||
// 注册停止功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_stop", |
|||
description: "停止QQ音乐播放", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicStopHandler() |
|||
) |
|||
|
|||
// 注册下一首功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_next", |
|||
description: "播放下一首歌曲", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicNextHandler() |
|||
) |
|||
|
|||
// 注册上一首功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_previous", |
|||
description: "播放上一首歌曲", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicPreviousHandler() |
|||
) |
|||
|
|||
// 注册获取播放状态功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_get_playback_state", |
|||
description: "获取QQ音乐播放状态", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicGetPlaybackStateHandler() |
|||
) |
|||
|
|||
// 注册获取当前歌曲功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_get_current_song", |
|||
description: "获取当前播放的歌曲信息", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicGetCurrentSongHandler() |
|||
) |
|||
|
|||
// 注册获取播放时间功能 |
|||
client.registerLocalFunction( |
|||
name: "qqmusic_get_play_time", |
|||
description: "获取播放时间信息", |
|||
parameters: [ |
|||
"type": "object", |
|||
"properties": [:] as [String: Any], |
|||
"required": [] as [String] |
|||
], |
|||
handler: QQMusicGetPlayTimeHandler() |
|||
) |
|||
} |
|||
} |
|||
|
|||
// MARK: - Private Handler Classes |
|||
|
|||
private class QQMusicSearchHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
guard let keyword = arguments["keyword"] as? String else { |
|||
let result: [String: Any] = ["success": false, "error": "Missing keyword parameter"] |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
|
|||
return await withCheckedContinuation { continuation in |
|||
// 直接调用QPlayAutoManager的搜索接口 |
|||
QPlayAutoManager.shared.search(keyword: keyword, searchType: .song) { items in |
|||
var result: [String: Any] |
|||
|
|||
if let items = items, !items.isEmpty { |
|||
let songs = items.map { item -> [String: Any] in |
|||
return [ |
|||
"mid": item.mid ?? "", |
|||
"name": item.name ?? "", |
|||
"artist": item.singer?.name ?? "", |
|||
"album": item.album ?? "", |
|||
"duration": item.duration, |
|||
"pic": item.coverUri ?? "" |
|||
] |
|||
} |
|||
result = [ |
|||
"success": true, |
|||
"message": "Found \(items.count) songs and started playing", |
|||
"data": songs |
|||
] |
|||
} else { |
|||
result = ["success": false, "error": "No songs found"] |
|||
} |
|||
|
|||
do { |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
let jsonString = String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
continuation.resume(returning: jsonString) |
|||
} catch { |
|||
continuation.resume(returning: "{\"success\": false, \"error\": \"JSON serialization failed\"}") |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
private class QQMusicPauseHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
QPlayAutoManager.shared.pause() |
|||
let result: [String: Any] = ["success": true, "message": "Music paused"] |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicResumeHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
QPlayAutoManager.shared.play() |
|||
let result: [String: Any] = ["success": true, "message": "Music resumed"] |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicStopHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
QPlayAutoManager.shared.stop() |
|||
let result: [String: Any] = ["success": true, "message": "Music stopped"] |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicNextHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
QPlayAutoManager.shared.next() |
|||
let result: [String: Any] = ["success": true, "message": "Skipped to next song"] |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicPreviousHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
QPlayAutoManager.shared.previous() |
|||
let result: [String: Any] = ["success": true, "message": "Skipped to previous song"] |
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicGetPlaybackStateHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
let playState = QPlayAutoManager.shared.currentPlayState |
|||
let isConnected = QPlayAutoManager.shared.isConnected |
|||
|
|||
var state = "unknown" |
|||
switch playState { |
|||
case .playing: |
|||
state = "playing" |
|||
case .pause: |
|||
state = "paused" |
|||
case .stop: |
|||
state = "stopped" |
|||
default: |
|||
state = "unknown" |
|||
} |
|||
|
|||
let result: [String: Any] = [ |
|||
"success": true, |
|||
"state": state, |
|||
"connected": isConnected |
|||
] |
|||
|
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicGetCurrentSongHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
var result: [String: Any] |
|||
|
|||
if let currentSong = QPlayAutoManager.shared.currentSong { |
|||
result = [ |
|||
"success": true, |
|||
"song": [ |
|||
"id": currentSong.id ?? "", |
|||
"name": currentSong.name ?? "", |
|||
"artist": currentSong.singer?.name ?? "", |
|||
"album": currentSong.album ?? "", |
|||
"duration": currentSong.duration |
|||
] |
|||
] |
|||
} else { |
|||
result = ["success": false, "error": "No current song"] |
|||
} |
|||
|
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
|
|||
private class QQMusicGetPlayTimeHandler: FunctionHandler { |
|||
func handle(arguments: [String: Any]) async throws -> String { |
|||
let currentProgress = QPlayAutoManager.shared.currentProgress |
|||
let currentSong = QPlayAutoManager.shared.currentSong |
|||
let totalDuration = currentSong?.duration ?? 0 |
|||
|
|||
let result: [String: Any] = [ |
|||
"success": true, |
|||
"current_time": currentProgress, |
|||
"total_time": totalDuration |
|||
] |
|||
|
|||
let jsonData = try JSONSerialization.data(withJSONObject: result) |
|||
return String(data: jsonData, encoding: .utf8) ?? "{}" |
|||
} |
|||
} |
|||
@ -1,7 +1,188 @@ |
|||
//
|
|||
// QPlayAutoSDK.h
|
|||
// QPlayAutoSDK Umbrella Header
|
|||
// QPlayAutoSDK
|
|||
//
|
|||
// Created by travisli(李鞠佑) on 2018/11/5.
|
|||
// Copyright © 2018年 腾讯音乐. All rights reserved.
|
|||
//
|
|||
|
|||
#import <Foundation/Foundation.h> |
|||
#import "QPlayAutoDefine.h" |
|||
|
|||
#define APP_DEVICE_TYPE (3) |
|||
|
|||
NS_ASSUME_NONNULL_BEGIN |
|||
|
|||
typedef void (^QPlayAutoResultItemsBlock)(NSInteger errorCode,NSArray<QPlayAutoListItem *> *_Nullable items); |
|||
typedef void (^QPlayAutoResultParentItemBlock)(NSInteger errorCode,QPlayAutoListItem *parentItem); |
|||
|
|||
extern NSString const * QPlayAutoSDKVersion; |
|||
|
|||
@protocol QPlayAutoSDKDelegate <NSObject> |
|||
|
|||
//连接状态变化回调
|
|||
- (void)onQPlayAutoConnectStateChanged:(QPlayAutoConnectState)newState; |
|||
//播放状态状态变化回调
|
|||
- (void)onQPlayAutoPlayStateChanged:(QPlayAutoPlayState)playState song:(QPlayAutoListItem *)song position:(NSInteger)position; |
|||
//歌曲播放进度
|
|||
- (void)onQPlayAutoPlayProgressChanged:(QPlayAutoListItem *)song progress:(NSTimeInterval)progress duration:(NSTimeInterval)duration; |
|||
//歌曲收藏状态变化
|
|||
- (void)onSongFavoriteStateChange:(NSString*)songID isFavorite:(BOOL)isFavorite; |
|||
//播放状态事件变化
|
|||
- (void)onPlayModeChange:(QPlayAutoPlayMode)playMode; |
|||
//定时关闭事件
|
|||
- (void)onPlayPausedByTimeoff; |
|||
//登陆状态
|
|||
- (void)onLoginStateDidChanged:(BOOL)isLoginOK; |
|||
@end |
|||
|
|||
|
|||
|
|||
@interface QPlayAutoSDK : NSObject |
|||
|
|||
/// 注册App
|
|||
/// @param name 名称
|
|||
/// @param brand 品牌
|
|||
/// @param deviceId ?
|
|||
/// @param scheme 授权成功后Q音跳转合作方的scheme
|
|||
/// @param appId Q音分配的Id
|
|||
/// @param secretKey 合作方私钥
|
|||
/// @param bundleId 合作方包名
|
|||
+ (void)registerAppWithName:(NSString *)name brand:(NSString *)brand deviceId:(NSString *)deviceId scheme:(NSString *)scheme appId:(NSString *)appId secretKey:(NSString *)secretKey bundleId:(NSString *)bundleId; |
|||
|
|||
/// 播放状态
|
|||
+ (QPlayAutoPlayMode)currentPlayMode; |
|||
/// 当前歌曲
|
|||
+ (QPlayAutoListItem *_Nullable)currentSong; |
|||
/// 当前播放状态
|
|||
+ (QPlayAutoPlayState)currentPlayState; |
|||
/// 当前播放进度
|
|||
+ (NSTimeInterval)currentProgress; |
|||
/// QQ音乐是否登录
|
|||
+ (BOOL)isLoginOK; |
|||
/// 检查QQ音乐是否已安装
|
|||
+ (BOOL)isQQMusicInstalled; |
|||
/// 是否已连接
|
|||
+ (BOOL)isConnected; |
|||
/// 连接中
|
|||
+ (BOOL)isConnecting; |
|||
///QQ音乐设备信息
|
|||
+ (NSDictionary *)deviceInfo; |
|||
|
|||
+(NSString *)openId; |
|||
+(NSString *)openToken; |
|||
|
|||
|
|||
///是否可以处理回调url
|
|||
+ (BOOL)canHandleOpenURL:(NSURL *)url; |
|||
///处理回调url
|
|||
+ (BOOL)handleOpenURL:(NSURL *)url; |
|||
|
|||
/// 回调代理
|
|||
+ (void)setDelegate:(id<QPlayAutoSDKDelegate>) delegate; |
|||
|
|||
|
|||
/// 拉端连接QPlay
|
|||
/// - Parameter forceLogin: 是否强制登录
|
|||
+ (void)connectAndForceLogin:(BOOL)forceLogin; |
|||
/// 停止
|
|||
+ (void)stop; |
|||
|
|||
|
|||
/// 二次热启动连接(需要联系Q音打开此功能才能使用)
|
|||
/// - Parameters:
|
|||
/// - timeout: 超时时间
|
|||
/// - completion: 回调
|
|||
+ (void)reconnectWithTimeout:(NSTimeInterval)timeout completion:(QPlayAutoRequestFinishBlock)completion; |
|||
|
|||
/// 跳转QQ音乐登录
|
|||
/// @param bundleId 合作方bundleId
|
|||
/// @param callbackUrl 跳转合作方url
|
|||
+ (BOOL)loginQQMusicWithBundleId:(NSString *)bundleId callbackUrl:(NSString *)callbackUrl; |
|||
|
|||
|
|||
/// 获取数据
|
|||
/// @param parent 父
|
|||
/// @param pageIndex 页码
|
|||
/// @param pageSize 页大小
|
|||
/// @param completion 回调
|
|||
+ (void)getDataItemsFromParent:(QPlayAutoListItem *)parent pageIndex:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize completion:(QPlayAutoResultParentItemBlock)completion; |
|||
|
|||
|
|||
/// 设置播放模式
|
|||
/// @param playMode 播放模式
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setPlayMode:(QPlayAutoPlayMode)playMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
|
|||
/// 设置播放整首还是高潮
|
|||
/// @param assencceMode 高潮还是整首
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setAssenceMode:(QPlayAutoAssenceMode)assencceMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
/// 收藏/取消收藏(歌曲id)
|
|||
/// @param song 歌曲
|
|||
/// @param isFavorite 收藏/取消收藏
|
|||
/// @param completion 回调
|
|||
+ (void)setFavoriteStateWithSong:(QPlayAutoListItem *)song isFavorite:(BOOL)isFavorite completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
/// 播放歌曲
|
|||
/// @param songList 歌曲列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playAtIndex:(NSArray<QPlayAutoListItem*> *)songList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
/// 通过歌曲Mid列表播放歌曲
|
|||
/// @param songMidList 歌曲Mid列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playSongMidAtIndex:(NSArray<NSString*> *)songMidList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
///播放下一首
|
|||
+ (void)playerPlayNextWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放上一首
|
|||
+ (void)playerPlayPrevWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放暂停
|
|||
+ (void)playerPlayPause; |
|||
|
|||
///播放恢复
|
|||
+ (void)playerPlayResumeWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///Seek到指定位置
|
|||
+ (void)playerSeek:(NSInteger)position; |
|||
|
|||
|
|||
/// 搜索歌曲
|
|||
/// @param keyword 关键词
|
|||
/// @param type 搜索类型
|
|||
/// @param firstPage 是否第一页
|
|||
/// @param completion 回调
|
|||
+ (NSInteger)search:(NSString *)keyword |
|||
type:(QPlayAutoSearchType)type |
|||
firstPage:(BOOL)firstPage |
|||
completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
/// 相似歌曲
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestSimilarWithSong:(QPlayAutoListItem *)song completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
|
|||
/// 查询歌词
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestLyricWithSong:(QPlayAutoListItem *)song completion:(void (^)(NSInteger errorCode,QPlayAutoLyric *_Nullable lyric))completion; |
|||
|
|||
|
|||
/// 获取特定歌曲列表
|
|||
/// @param type 列表类型
|
|||
/// @param completion 回调
|
|||
+ (void)requestSonglistWithType:(QPlayAutoSongListType)type completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
@end |
|||
|
|||
#import "include/QPlayAutoSDK.h" |
|||
#import "include/QPlayAutoDefine.h" |
|||
NS_ASSUME_NONNULL_END |
|||
|
|||
@ -1,188 +0,0 @@ |
|||
//
|
|||
// QPlayAutoSDK.h
|
|||
// QPlayAutoSDK
|
|||
//
|
|||
// Created by travisli(李鞠佑) on 2018/11/5.
|
|||
// Copyright © 2018年 腾讯音乐. All rights reserved.
|
|||
//
|
|||
|
|||
#import <Foundation/Foundation.h> |
|||
#import "QPlayAutoDefine.h" |
|||
|
|||
#define APP_DEVICE_TYPE (3) |
|||
|
|||
NS_ASSUME_NONNULL_BEGIN |
|||
|
|||
typedef void (^QPlayAutoResultItemsBlock)(NSInteger errorCode,NSArray<QPlayAutoListItem *> *_Nullable items); |
|||
typedef void (^QPlayAutoResultParentItemBlock)(NSInteger errorCode,QPlayAutoListItem *parentItem); |
|||
|
|||
extern NSString const * QPlayAutoSDKVersion; |
|||
|
|||
@protocol QPlayAutoSDKDelegate <NSObject> |
|||
|
|||
//连接状态变化回调
|
|||
- (void)onQPlayAutoConnectStateChanged:(QPlayAutoConnectState)newState; |
|||
//播放状态状态变化回调
|
|||
- (void)onQPlayAutoPlayStateChanged:(QPlayAutoPlayState)playState song:(QPlayAutoListItem *)song position:(NSInteger)position; |
|||
//歌曲播放进度
|
|||
- (void)onQPlayAutoPlayProgressChanged:(QPlayAutoListItem *)song progress:(NSTimeInterval)progress duration:(NSTimeInterval)duration; |
|||
//歌曲收藏状态变化
|
|||
- (void)onSongFavoriteStateChange:(NSString*)songID isFavorite:(BOOL)isFavorite; |
|||
//播放状态事件变化
|
|||
- (void)onPlayModeChange:(QPlayAutoPlayMode)playMode; |
|||
//定时关闭事件
|
|||
- (void)onPlayPausedByTimeoff; |
|||
//登陆状态
|
|||
- (void)onLoginStateDidChanged:(BOOL)isLoginOK; |
|||
@end |
|||
|
|||
|
|||
|
|||
@interface QPlayAutoSDK : NSObject |
|||
|
|||
/// 注册App
|
|||
/// @param name 名称
|
|||
/// @param brand 品牌
|
|||
/// @param deviceId ?
|
|||
/// @param scheme 授权成功后Q音跳转合作方的scheme
|
|||
/// @param appId Q音分配的Id
|
|||
/// @param secretKey 合作方私钥
|
|||
/// @param bundleId 合作方包名
|
|||
+ (void)registerAppWithName:(NSString *)name brand:(NSString *)brand deviceId:(NSString *)deviceId scheme:(NSString *)scheme appId:(NSString *)appId secretKey:(NSString *)secretKey bundleId:(NSString *)bundleId; |
|||
|
|||
/// 播放状态
|
|||
+ (QPlayAutoPlayMode)currentPlayMode; |
|||
/// 当前歌曲
|
|||
+ (QPlayAutoListItem *_Nullable)currentSong; |
|||
/// 当前播放状态
|
|||
+ (QPlayAutoPlayState)currentPlayState; |
|||
/// 当前播放进度
|
|||
+ (NSTimeInterval)currentProgress; |
|||
/// QQ音乐是否登录
|
|||
+ (BOOL)isLoginOK; |
|||
/// 检查QQ音乐是否已安装
|
|||
+ (BOOL)isQQMusicInstalled; |
|||
/// 是否已连接
|
|||
+ (BOOL)isConnected; |
|||
/// 连接中
|
|||
+ (BOOL)isConnecting; |
|||
///QQ音乐设备信息
|
|||
+ (NSDictionary *)deviceInfo; |
|||
|
|||
+(NSString *)openId; |
|||
+(NSString *)openToken; |
|||
|
|||
|
|||
///是否可以处理回调url
|
|||
+ (BOOL)canHandleOpenURL:(NSURL *)url; |
|||
///处理回调url
|
|||
+ (BOOL)handleOpenURL:(NSURL *)url; |
|||
|
|||
/// 回调代理
|
|||
+ (void)setDelegate:(id<QPlayAutoSDKDelegate>) delegate; |
|||
|
|||
|
|||
/// 拉端连接QPlay
|
|||
/// - Parameter forceLogin: 是否强制登录
|
|||
+ (void)connectAndForceLogin:(BOOL)forceLogin; |
|||
/// 停止
|
|||
+ (void)stop; |
|||
|
|||
|
|||
/// 二次热启动连接(需要联系Q音打开此功能才能使用)
|
|||
/// - Parameters:
|
|||
/// - timeout: 超时时间
|
|||
/// - completion: 回调
|
|||
+ (void)reconnectWithTimeout:(NSTimeInterval)timeout completion:(QPlayAutoRequestFinishBlock)completion; |
|||
|
|||
/// 跳转QQ音乐登录
|
|||
/// @param bundleId 合作方bundleId
|
|||
/// @param callbackUrl 跳转合作方url
|
|||
+ (BOOL)loginQQMusicWithBundleId:(NSString *)bundleId callbackUrl:(NSString *)callbackUrl; |
|||
|
|||
|
|||
/// 获取数据
|
|||
/// @param parent 父
|
|||
/// @param pageIndex 页码
|
|||
/// @param pageSize 页大小
|
|||
/// @param completion 回调
|
|||
+ (void)getDataItemsFromParent:(QPlayAutoListItem *)parent pageIndex:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize completion:(QPlayAutoResultParentItemBlock)completion; |
|||
|
|||
|
|||
/// 设置播放模式
|
|||
/// @param playMode 播放模式
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setPlayMode:(QPlayAutoPlayMode)playMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
|
|||
/// 设置播放整首还是高潮
|
|||
/// @param assencceMode 高潮还是整首
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setAssenceMode:(QPlayAutoAssenceMode)assencceMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
/// 收藏/取消收藏(歌曲id)
|
|||
/// @param song 歌曲
|
|||
/// @param isFavorite 收藏/取消收藏
|
|||
/// @param completion 回调
|
|||
+ (void)setFavoriteStateWithSong:(QPlayAutoListItem *)song isFavorite:(BOOL)isFavorite completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
/// 播放歌曲
|
|||
/// @param songList 歌曲列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playAtIndex:(NSArray<QPlayAutoListItem*> *)songList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
/// 通过歌曲Mid列表播放歌曲
|
|||
/// @param songMidList 歌曲Mid列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playSongMidAtIndex:(NSArray<NSString*> *)songMidList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
///播放下一首
|
|||
+ (void)playerPlayNextWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放上一首
|
|||
+ (void)playerPlayPrevWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放暂停
|
|||
+ (void)playerPlayPause; |
|||
|
|||
///播放恢复
|
|||
+ (void)playerPlayResumeWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///Seek到指定位置
|
|||
+ (void)playerSeek:(NSInteger)position; |
|||
|
|||
|
|||
/// 搜索歌曲
|
|||
/// @param keyword 关键词
|
|||
/// @param type 搜索类型
|
|||
/// @param firstPage 是否第一页
|
|||
/// @param completion 回调
|
|||
+ (NSInteger)search:(NSString *)keyword |
|||
type:(QPlayAutoSearchType)type |
|||
firstPage:(BOOL)firstPage |
|||
completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
/// 相似歌曲
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestSimilarWithSong:(QPlayAutoListItem *)song completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
|
|||
/// 查询歌词
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestLyricWithSong:(QPlayAutoListItem *)song completion:(void (^)(NSInteger errorCode,QPlayAutoLyric *_Nullable lyric))completion; |
|||
|
|||
|
|||
/// 获取特定歌曲列表
|
|||
/// @param type 列表类型
|
|||
/// @param completion 回调
|
|||
+ (void)requestSonglistWithType:(QPlayAutoSongListType)type completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
@end |
|||
|
|||
NS_ASSUME_NONNULL_END |
|||
@ -1,5 +1,8 @@ |
|||
framework module QPlayAutoSDK { |
|||
umbrella header "QPlayAutoSDK.h" |
|||
module QPlayAutoSDK { |
|||
header "QPlayAutoSDK.h" |
|||
header "QPlayAutoDefine.h" |
|||
|
|||
export * |
|||
module * { export * } |
|||
|
|||
link "QPlayAutoSDK" |
|||
} |
|||
|
|||
@ -1,7 +1,188 @@ |
|||
//
|
|||
// QPlayAutoSDK.h
|
|||
// QPlayAutoSDK Umbrella Header
|
|||
// QPlayAutoSDK
|
|||
//
|
|||
// Created by travisli(李鞠佑) on 2018/11/5.
|
|||
// Copyright © 2018年 腾讯音乐. All rights reserved.
|
|||
//
|
|||
|
|||
#import <Foundation/Foundation.h> |
|||
#import "QPlayAutoDefine.h" |
|||
|
|||
#define APP_DEVICE_TYPE (3) |
|||
|
|||
NS_ASSUME_NONNULL_BEGIN |
|||
|
|||
typedef void (^QPlayAutoResultItemsBlock)(NSInteger errorCode,NSArray<QPlayAutoListItem *> *_Nullable items); |
|||
typedef void (^QPlayAutoResultParentItemBlock)(NSInteger errorCode,QPlayAutoListItem *parentItem); |
|||
|
|||
extern NSString const * QPlayAutoSDKVersion; |
|||
|
|||
@protocol QPlayAutoSDKDelegate <NSObject> |
|||
|
|||
//连接状态变化回调
|
|||
- (void)onQPlayAutoConnectStateChanged:(QPlayAutoConnectState)newState; |
|||
//播放状态状态变化回调
|
|||
- (void)onQPlayAutoPlayStateChanged:(QPlayAutoPlayState)playState song:(QPlayAutoListItem *)song position:(NSInteger)position; |
|||
//歌曲播放进度
|
|||
- (void)onQPlayAutoPlayProgressChanged:(QPlayAutoListItem *)song progress:(NSTimeInterval)progress duration:(NSTimeInterval)duration; |
|||
//歌曲收藏状态变化
|
|||
- (void)onSongFavoriteStateChange:(NSString*)songID isFavorite:(BOOL)isFavorite; |
|||
//播放状态事件变化
|
|||
- (void)onPlayModeChange:(QPlayAutoPlayMode)playMode; |
|||
//定时关闭事件
|
|||
- (void)onPlayPausedByTimeoff; |
|||
//登陆状态
|
|||
- (void)onLoginStateDidChanged:(BOOL)isLoginOK; |
|||
@end |
|||
|
|||
|
|||
|
|||
@interface QPlayAutoSDK : NSObject |
|||
|
|||
/// 注册App
|
|||
/// @param name 名称
|
|||
/// @param brand 品牌
|
|||
/// @param deviceId ?
|
|||
/// @param scheme 授权成功后Q音跳转合作方的scheme
|
|||
/// @param appId Q音分配的Id
|
|||
/// @param secretKey 合作方私钥
|
|||
/// @param bundleId 合作方包名
|
|||
+ (void)registerAppWithName:(NSString *)name brand:(NSString *)brand deviceId:(NSString *)deviceId scheme:(NSString *)scheme appId:(NSString *)appId secretKey:(NSString *)secretKey bundleId:(NSString *)bundleId; |
|||
|
|||
/// 播放状态
|
|||
+ (QPlayAutoPlayMode)currentPlayMode; |
|||
/// 当前歌曲
|
|||
+ (QPlayAutoListItem *_Nullable)currentSong; |
|||
/// 当前播放状态
|
|||
+ (QPlayAutoPlayState)currentPlayState; |
|||
/// 当前播放进度
|
|||
+ (NSTimeInterval)currentProgress; |
|||
/// QQ音乐是否登录
|
|||
+ (BOOL)isLoginOK; |
|||
/// 检查QQ音乐是否已安装
|
|||
+ (BOOL)isQQMusicInstalled; |
|||
/// 是否已连接
|
|||
+ (BOOL)isConnected; |
|||
/// 连接中
|
|||
+ (BOOL)isConnecting; |
|||
///QQ音乐设备信息
|
|||
+ (NSDictionary *)deviceInfo; |
|||
|
|||
+(NSString *)openId; |
|||
+(NSString *)openToken; |
|||
|
|||
|
|||
///是否可以处理回调url
|
|||
+ (BOOL)canHandleOpenURL:(NSURL *)url; |
|||
///处理回调url
|
|||
+ (BOOL)handleOpenURL:(NSURL *)url; |
|||
|
|||
/// 回调代理
|
|||
+ (void)setDelegate:(id<QPlayAutoSDKDelegate>) delegate; |
|||
|
|||
|
|||
/// 拉端连接QPlay
|
|||
/// - Parameter forceLogin: 是否强制登录
|
|||
+ (void)connectAndForceLogin:(BOOL)forceLogin; |
|||
/// 停止
|
|||
+ (void)stop; |
|||
|
|||
|
|||
/// 二次热启动连接(需要联系Q音打开此功能才能使用)
|
|||
/// - Parameters:
|
|||
/// - timeout: 超时时间
|
|||
/// - completion: 回调
|
|||
+ (void)reconnectWithTimeout:(NSTimeInterval)timeout completion:(QPlayAutoRequestFinishBlock)completion; |
|||
|
|||
/// 跳转QQ音乐登录
|
|||
/// @param bundleId 合作方bundleId
|
|||
/// @param callbackUrl 跳转合作方url
|
|||
+ (BOOL)loginQQMusicWithBundleId:(NSString *)bundleId callbackUrl:(NSString *)callbackUrl; |
|||
|
|||
|
|||
/// 获取数据
|
|||
/// @param parent 父
|
|||
/// @param pageIndex 页码
|
|||
/// @param pageSize 页大小
|
|||
/// @param completion 回调
|
|||
+ (void)getDataItemsFromParent:(QPlayAutoListItem *)parent pageIndex:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize completion:(QPlayAutoResultParentItemBlock)completion; |
|||
|
|||
|
|||
/// 设置播放模式
|
|||
/// @param playMode 播放模式
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setPlayMode:(QPlayAutoPlayMode)playMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
|
|||
/// 设置播放整首还是高潮
|
|||
/// @param assencceMode 高潮还是整首
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setAssenceMode:(QPlayAutoAssenceMode)assencceMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
/// 收藏/取消收藏(歌曲id)
|
|||
/// @param song 歌曲
|
|||
/// @param isFavorite 收藏/取消收藏
|
|||
/// @param completion 回调
|
|||
+ (void)setFavoriteStateWithSong:(QPlayAutoListItem *)song isFavorite:(BOOL)isFavorite completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
/// 播放歌曲
|
|||
/// @param songList 歌曲列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playAtIndex:(NSArray<QPlayAutoListItem*> *)songList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
/// 通过歌曲Mid列表播放歌曲
|
|||
/// @param songMidList 歌曲Mid列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playSongMidAtIndex:(NSArray<NSString*> *)songMidList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
///播放下一首
|
|||
+ (void)playerPlayNextWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放上一首
|
|||
+ (void)playerPlayPrevWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放暂停
|
|||
+ (void)playerPlayPause; |
|||
|
|||
///播放恢复
|
|||
+ (void)playerPlayResumeWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///Seek到指定位置
|
|||
+ (void)playerSeek:(NSInteger)position; |
|||
|
|||
|
|||
/// 搜索歌曲
|
|||
/// @param keyword 关键词
|
|||
/// @param type 搜索类型
|
|||
/// @param firstPage 是否第一页
|
|||
/// @param completion 回调
|
|||
+ (NSInteger)search:(NSString *)keyword |
|||
type:(QPlayAutoSearchType)type |
|||
firstPage:(BOOL)firstPage |
|||
completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
/// 相似歌曲
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestSimilarWithSong:(QPlayAutoListItem *)song completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
|
|||
/// 查询歌词
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestLyricWithSong:(QPlayAutoListItem *)song completion:(void (^)(NSInteger errorCode,QPlayAutoLyric *_Nullable lyric))completion; |
|||
|
|||
|
|||
/// 获取特定歌曲列表
|
|||
/// @param type 列表类型
|
|||
/// @param completion 回调
|
|||
+ (void)requestSonglistWithType:(QPlayAutoSongListType)type completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
@end |
|||
|
|||
#import "include/QPlayAutoSDK.h" |
|||
#import "include/QPlayAutoDefine.h" |
|||
NS_ASSUME_NONNULL_END |
|||
|
|||
@ -1,188 +0,0 @@ |
|||
//
|
|||
// QPlayAutoSDK.h
|
|||
// QPlayAutoSDK
|
|||
//
|
|||
// Created by travisli(李鞠佑) on 2018/11/5.
|
|||
// Copyright © 2018年 腾讯音乐. All rights reserved.
|
|||
//
|
|||
|
|||
#import <Foundation/Foundation.h> |
|||
#import "QPlayAutoDefine.h" |
|||
|
|||
#define APP_DEVICE_TYPE (3) |
|||
|
|||
NS_ASSUME_NONNULL_BEGIN |
|||
|
|||
typedef void (^QPlayAutoResultItemsBlock)(NSInteger errorCode,NSArray<QPlayAutoListItem *> *_Nullable items); |
|||
typedef void (^QPlayAutoResultParentItemBlock)(NSInteger errorCode,QPlayAutoListItem *parentItem); |
|||
|
|||
extern NSString const * QPlayAutoSDKVersion; |
|||
|
|||
@protocol QPlayAutoSDKDelegate <NSObject> |
|||
|
|||
//连接状态变化回调
|
|||
- (void)onQPlayAutoConnectStateChanged:(QPlayAutoConnectState)newState; |
|||
//播放状态状态变化回调
|
|||
- (void)onQPlayAutoPlayStateChanged:(QPlayAutoPlayState)playState song:(QPlayAutoListItem *)song position:(NSInteger)position; |
|||
//歌曲播放进度
|
|||
- (void)onQPlayAutoPlayProgressChanged:(QPlayAutoListItem *)song progress:(NSTimeInterval)progress duration:(NSTimeInterval)duration; |
|||
//歌曲收藏状态变化
|
|||
- (void)onSongFavoriteStateChange:(NSString*)songID isFavorite:(BOOL)isFavorite; |
|||
//播放状态事件变化
|
|||
- (void)onPlayModeChange:(QPlayAutoPlayMode)playMode; |
|||
//定时关闭事件
|
|||
- (void)onPlayPausedByTimeoff; |
|||
//登陆状态
|
|||
- (void)onLoginStateDidChanged:(BOOL)isLoginOK; |
|||
@end |
|||
|
|||
|
|||
|
|||
@interface QPlayAutoSDK : NSObject |
|||
|
|||
/// 注册App
|
|||
/// @param name 名称
|
|||
/// @param brand 品牌
|
|||
/// @param deviceId ?
|
|||
/// @param scheme 授权成功后Q音跳转合作方的scheme
|
|||
/// @param appId Q音分配的Id
|
|||
/// @param secretKey 合作方私钥
|
|||
/// @param bundleId 合作方包名
|
|||
+ (void)registerAppWithName:(NSString *)name brand:(NSString *)brand deviceId:(NSString *)deviceId scheme:(NSString *)scheme appId:(NSString *)appId secretKey:(NSString *)secretKey bundleId:(NSString *)bundleId; |
|||
|
|||
/// 播放状态
|
|||
+ (QPlayAutoPlayMode)currentPlayMode; |
|||
/// 当前歌曲
|
|||
+ (QPlayAutoListItem *_Nullable)currentSong; |
|||
/// 当前播放状态
|
|||
+ (QPlayAutoPlayState)currentPlayState; |
|||
/// 当前播放进度
|
|||
+ (NSTimeInterval)currentProgress; |
|||
/// QQ音乐是否登录
|
|||
+ (BOOL)isLoginOK; |
|||
/// 检查QQ音乐是否已安装
|
|||
+ (BOOL)isQQMusicInstalled; |
|||
/// 是否已连接
|
|||
+ (BOOL)isConnected; |
|||
/// 连接中
|
|||
+ (BOOL)isConnecting; |
|||
///QQ音乐设备信息
|
|||
+ (NSDictionary *)deviceInfo; |
|||
|
|||
+(NSString *)openId; |
|||
+(NSString *)openToken; |
|||
|
|||
|
|||
///是否可以处理回调url
|
|||
+ (BOOL)canHandleOpenURL:(NSURL *)url; |
|||
///处理回调url
|
|||
+ (BOOL)handleOpenURL:(NSURL *)url; |
|||
|
|||
/// 回调代理
|
|||
+ (void)setDelegate:(id<QPlayAutoSDKDelegate>) delegate; |
|||
|
|||
|
|||
/// 拉端连接QPlay
|
|||
/// - Parameter forceLogin: 是否强制登录
|
|||
+ (void)connectAndForceLogin:(BOOL)forceLogin; |
|||
/// 停止
|
|||
+ (void)stop; |
|||
|
|||
|
|||
/// 二次热启动连接(需要联系Q音打开此功能才能使用)
|
|||
/// - Parameters:
|
|||
/// - timeout: 超时时间
|
|||
/// - completion: 回调
|
|||
+ (void)reconnectWithTimeout:(NSTimeInterval)timeout completion:(QPlayAutoRequestFinishBlock)completion; |
|||
|
|||
/// 跳转QQ音乐登录
|
|||
/// @param bundleId 合作方bundleId
|
|||
/// @param callbackUrl 跳转合作方url
|
|||
+ (BOOL)loginQQMusicWithBundleId:(NSString *)bundleId callbackUrl:(NSString *)callbackUrl; |
|||
|
|||
|
|||
/// 获取数据
|
|||
/// @param parent 父
|
|||
/// @param pageIndex 页码
|
|||
/// @param pageSize 页大小
|
|||
/// @param completion 回调
|
|||
+ (void)getDataItemsFromParent:(QPlayAutoListItem *)parent pageIndex:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize completion:(QPlayAutoResultParentItemBlock)completion; |
|||
|
|||
|
|||
/// 设置播放模式
|
|||
/// @param playMode 播放模式
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setPlayMode:(QPlayAutoPlayMode)playMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
|
|||
/// 设置播放整首还是高潮
|
|||
/// @param assencceMode 高潮还是整首
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setAssenceMode:(QPlayAutoAssenceMode)assencceMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
/// 收藏/取消收藏(歌曲id)
|
|||
/// @param song 歌曲
|
|||
/// @param isFavorite 收藏/取消收藏
|
|||
/// @param completion 回调
|
|||
+ (void)setFavoriteStateWithSong:(QPlayAutoListItem *)song isFavorite:(BOOL)isFavorite completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
/// 播放歌曲
|
|||
/// @param songList 歌曲列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playAtIndex:(NSArray<QPlayAutoListItem*> *)songList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
/// 通过歌曲Mid列表播放歌曲
|
|||
/// @param songMidList 歌曲Mid列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playSongMidAtIndex:(NSArray<NSString*> *)songMidList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
///播放下一首
|
|||
+ (void)playerPlayNextWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放上一首
|
|||
+ (void)playerPlayPrevWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放暂停
|
|||
+ (void)playerPlayPause; |
|||
|
|||
///播放恢复
|
|||
+ (void)playerPlayResumeWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///Seek到指定位置
|
|||
+ (void)playerSeek:(NSInteger)position; |
|||
|
|||
|
|||
/// 搜索歌曲
|
|||
/// @param keyword 关键词
|
|||
/// @param type 搜索类型
|
|||
/// @param firstPage 是否第一页
|
|||
/// @param completion 回调
|
|||
+ (NSInteger)search:(NSString *)keyword |
|||
type:(QPlayAutoSearchType)type |
|||
firstPage:(BOOL)firstPage |
|||
completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
/// 相似歌曲
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestSimilarWithSong:(QPlayAutoListItem *)song completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
|
|||
/// 查询歌词
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestLyricWithSong:(QPlayAutoListItem *)song completion:(void (^)(NSInteger errorCode,QPlayAutoLyric *_Nullable lyric))completion; |
|||
|
|||
|
|||
/// 获取特定歌曲列表
|
|||
/// @param type 列表类型
|
|||
/// @param completion 回调
|
|||
+ (void)requestSonglistWithType:(QPlayAutoSongListType)type completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
@end |
|||
|
|||
NS_ASSUME_NONNULL_END |
|||
@ -1,5 +1,8 @@ |
|||
framework module QPlayAutoSDK { |
|||
umbrella header "QPlayAutoSDK.h" |
|||
module QPlayAutoSDK { |
|||
header "QPlayAutoSDK.h" |
|||
header "QPlayAutoDefine.h" |
|||
|
|||
export * |
|||
module * { export * } |
|||
|
|||
link "QPlayAutoSDK" |
|||
} |
|||
|
|||
@ -1,238 +0,0 @@ |
|||
//
|
|||
// QPlayAutoDefine.h
|
|||
// QPlayAutoSDK
|
|||
//
|
|||
// Created by travisli(李鞠佑) on 2018/11/17.
|
|||
// Copyright © 2018年 腾讯音乐. All rights reserved.
|
|||
//
|
|||
|
|||
#ifndef QPlayAutoDefine_h |
|||
#define QPlayAutoDefine_h |
|||
|
|||
extern NSString *const kQPlayAutoItemRootID; |
|||
extern NSString *const kQPlayAutoArgument_Count; |
|||
extern NSString *const kQPlayAutoArgument_PageIndex; |
|||
extern NSString *const kQPlayAutoArgument_ParentID; |
|||
extern NSString *const kQPlayAutoArgument_Lists; |
|||
extern NSString *const kQPlayAutoArgument_PlayMode; |
|||
extern NSString *const kQPlayAutoArgument_IsFav; |
|||
extern NSString *const kQPlayAutoArgument_Position; |
|||
extern NSString *const kQPlayAutoArgument_Song; |
|||
extern NSString *const kQPlayAutoArgument_SongID; |
|||
extern NSString *const kQPlayAutoArgument_State; |
|||
extern NSString *const kQPlayAutoArgument_Error; |
|||
|
|||
/*
|
|||
QPlayAuto错误 |
|||
*/ |
|||
typedef NS_ENUM(NSUInteger, QPlayAutoError) |
|||
{ |
|||
QPlayAuto_OK=0, //成功
|
|||
QPlayAuto_QueryAutoFailed=100, //查询车机信息失败
|
|||
QPlayAuto_QueryMobileFailed=101, //查询移动设备失败
|
|||
QPlayAuto_QuerySongsFailed_WithoutID=102, //查询歌单数据失败,父 ID 不存在
|
|||
QPlayAuto_QuerySongsFailed_NoNetwork=103, //查询歌单数据失败,移动设备网络不通,无法下载数据
|
|||
QPlayAuto_QuerySongsFailed_Unknow=104, //查询歌单数据失败,原因未知
|
|||
QPlayAuto_SongIDError=105, //歌曲 ID 不存在
|
|||
QPlayAuto_ReadError=106, //读取数据错误
|
|||
QPlayAuto_ParamError=107, //参数错误
|
|||
QPlayAuto_SystemError=108, //系统调用错误
|
|||
QPlayAuto_CopyRightError=109, //无法播放,没有版权
|
|||
QPlayAuto_LoginError=110, //无法读取,没有登录
|
|||
QPlayAuto_PcmRepeat=111, //PCM 请求重复
|
|||
QPlayAuto_NoPermission=112, //没有权限
|
|||
QPlayAuto_NeedBuy = 113, //无法播放(数字专辑)
|
|||
QPlayAuto_NotSupportFormat=114, //无法播放(不支持格式)
|
|||
QPlayAuto_NeedAuth=115, //需要授权
|
|||
QPlayAuto_NeedVIP = 116, //无法播放(需要购买VIP)
|
|||
QPlayAuto_TryListen = 117, //试听歌曲,购买听完整版
|
|||
QPlayAuto_TrafficAlert = 118, //无法播放(流量弹窗阻断)
|
|||
QPlayAuto_OnlyWifi = 119, //无法播放(仅Wifi弹窗阻断)
|
|||
QPlayAuto_AlreadyConnected=120, //已经连接车机
|
|||
QPlayAuto_SeekError = 121, //拖拽进度错误
|
|||
QPlayAuto_NoListenRight = 122, //无法播放(无版权)
|
|||
QPlayAuto_SongNotMatch=123, //歌曲不匹配
|
|||
QPlayAuto_Disconnect=124, //连接已断开
|
|||
}; |
|||
|
|||
/**
|
|||
QPlayAuto连接状态 |
|||
*/ |
|||
typedef NS_ENUM(NSUInteger, QPlayAutoConnectState) |
|||
{ |
|||
QPlayAutoConnectState_Connected = 0, //连接成功
|
|||
QPlayAutoConnectState_Disconnect = 1, //断开连接
|
|||
QPlayAutoConnectState_Failed = -1, //连接失败
|
|||
QPlayAutoConnectState_Cancel = -2, //连接取消
|
|||
}; |
|||
|
|||
/*
|
|||
QPlayAutoListItem类型 |
|||
*/ |
|||
typedef NS_ENUM(NSUInteger, QPlayAutoListItemType) |
|||
{ |
|||
QPlayAutoListItemType_Song = 1, //歌曲
|
|||
QPlayAutoListItemType_Normal = 2, //普通目录
|
|||
QPlayAutoListItemType_Radio = 3, //电台
|
|||
QPlayAutoListItemType_Folder = 4, //歌单
|
|||
QPlayAutoListItemType_Album = 5, //专辑
|
|||
}; |
|||
|
|||
typedef NS_ENUM(NSUInteger, QPlayAutoSongListType) |
|||
{ |
|||
QPlayAutoSongListType_Daily = 108, //每日30首
|
|||
}; |
|||
|
|||
|
|||
/**
|
|||
QPlayAuto播放状态 |
|||
*/ |
|||
typedef NS_ENUM(NSUInteger, QPlayAutoPlayState) |
|||
{ |
|||
QPlayAutoPlayState_Stop=0, //停止
|
|||
QPlayAutoPlayState_Playing=1, //播放
|
|||
QPlayAutoPlayState_Pause=2 //暂停
|
|||
}; |
|||
|
|||
typedef NS_ENUM(NSInteger, QPlayAutoAssenceMode) |
|||
{ |
|||
QPlayAutoAssenceMode_Full = 0, // 默认整首播放
|
|||
QPlayAutoAssenceMode_Part = 1, // 仅播放精华片段
|
|||
}; |
|||
|
|||
/**
|
|||
QPlayAuto播放模式 |
|||
*/ |
|||
typedef NS_ENUM(NSUInteger, QPlayAutoPlayMode) |
|||
{ |
|||
QPlayAutoPlayMode_SequenceCircle=0, //列表循环
|
|||
QPlayAutoPlayMode_SingleCircle=1, //单曲循环
|
|||
QPlayAutoPlayMode_RandomCircle=2 //随机播放
|
|||
}; |
|||
|
|||
/**
|
|||
QPlayAuto搜索类型 |
|||
*/ |
|||
typedef NS_ENUM(NSInteger, QPlayAutoSearchType) |
|||
{ |
|||
QPlayAutoSearchType_Song = 0, //歌曲
|
|||
QPlayAutoSearchType_Album = 2, //专辑
|
|||
QPlayAutoSearchType_Folder = 3, //歌单
|
|||
QPlayAutoSearchType_Composite = 100, //综合
|
|||
}; |
|||
|
|||
typedef NS_ENUM(NSInteger, QPlayAutoVipState) |
|||
{ |
|||
QPlayAutoVipState_Normal = 0, |
|||
QPlayAutoVipState_VIP = 1, |
|||
QPlayAutoVipState_SVIP = 2, |
|||
}; |
|||
|
|||
/**
|
|||
第三方App信息 |
|||
*/ |
|||
@interface QPlayAutoAppInfo : NSObject<NSCoding> |
|||
|
|||
@property (nonatomic,strong) NSString *deviceId; //AppId
|
|||
@property (nonatomic,assign) NSInteger deviceType; |
|||
@property (nonatomic,strong) NSString *scheme; //跳转scheme
|
|||
@property (nonatomic,strong) NSString *brand; //品牌
|
|||
@property (nonatomic,strong) NSString *name; //名称
|
|||
@property (nonatomic,strong) NSString *appId; //名称
|
|||
@property (nonatomic,strong) NSString *secretKey; //私钥
|
|||
@property (nonatomic,strong) NSString *bundleId; //bundleId
|
|||
@property (nonatomic,assign) NSInteger qmCommandPort; //Q音接收命令端口
|
|||
@property (nonatomic,strong) NSString *qmHost; //Q音接收命令IP
|
|||
@property (nonatomic,strong) NSDate *lastConnectDate;//上次连接的日期
|
|||
@end |
|||
|
|||
@interface QPlayAutoSinger : NSObject |
|||
@property (nonatomic,strong) NSString *ID; //ID
|
|||
@property (nonatomic,strong) NSString *Mid; //Mid
|
|||
@property (nonatomic,strong) NSString *name; //名称
|
|||
@end |
|||
|
|||
|
|||
/*
|
|||
QPlayAuto列表项(歌单、电台、排行榜、歌曲、etc) |
|||
*/ |
|||
@interface QPlayAutoListItem: NSObject |
|||
|
|||
@property (nonatomic,strong) NSString *ID; //ID
|
|||
@property (nonatomic,strong) NSString *Name; //名称
|
|||
@property (nonatomic,strong) NSString *SubName; //副标题
|
|||
@property (nonatomic,strong) QPlayAutoSinger *singer; //歌手
|
|||
@property (nonatomic,strong) NSString *Album; //专辑
|
|||
@property (nonatomic,strong) NSString *Mid; |
|||
@property (nonatomic,assign) QPlayAutoVipState vipState; |
|||
@property (nonatomic,assign) QPlayAutoListItemType Type; |
|||
@property (nonatomic,assign) NSInteger Duration; //时长
|
|||
@property (nonatomic,strong) NSString *CoverUri; //封面Uri
|
|||
@property (nonatomic,assign) NSInteger totalCount; //总数
|
|||
@property (nonatomic,assign) BOOL isFav; //是否收藏
|
|||
@property (nonatomic,assign) BOOL isOrigin; //是否原唱
|
|||
@property (nonatomic,assign) BOOL isNoAudioSource; //无音源
|
|||
@property (nonatomic,strong) NSMutableArray<QPlayAutoListItem*> *items; //子列表
|
|||
@property (nonatomic,weak) QPlayAutoListItem *parentItem; //父节点
|
|||
|
|||
@property (nonatomic,assign) BOOL isTryListen; //是否试听歌曲
|
|||
@property (nonatomic,readonly) BOOL isSong; //歌曲
|
|||
@property (nonatomic,readonly) BOOL isFolder;//歌单
|
|||
@property (nonatomic,readonly) BOOL isAlbum; //专辑
|
|||
@property (nonatomic,readonly) BOOL isRadio; //电台
|
|||
@property (nonatomic,readonly) BOOL isDirectory; //普通目录
|
|||
|
|||
@property (nonatomic,readonly) BOOL isVIP; //VIP歌曲
|
|||
@property (nonatomic,readonly) BOOL isSVIP; //SVIP歌曲
|
|||
|
|||
- (instancetype)initWithDictionary:(NSDictionary*)dict; |
|||
- (instancetype)initSongWithId:(NSString *)identifier isFav:(BOOL)isFav; |
|||
- (instancetype)initWithId:(NSString *)identifier type:(QPlayAutoListItemType)type; |
|||
|
|||
//是否是根节点
|
|||
- (BOOL)isRoot; |
|||
|
|||
//是否有更多
|
|||
- (BOOL)hasMore; |
|||
|
|||
- (QPlayAutoListItem*)findItemWithID:(NSString*)ID; |
|||
|
|||
@end |
|||
|
|||
/**
|
|||
QPlayAuto请求回调 |
|||
|
|||
@param success 是否成功 |
|||
@param dict 结果Dictionary |
|||
*/ |
|||
typedef void (^QPlayAutoRequestFinishBlock)(BOOL success, NSDictionary *dict); |
|||
|
|||
|
|||
@interface QPlayAutoRequestBase : NSObject |
|||
|
|||
/** 请求类型 */ |
|||
@property (nonatomic, assign) int type; |
|||
|
|||
@end |
|||
|
|||
@interface QPlayAutoSentence : NSObject <NSCoding> |
|||
@property (nonatomic, assign) NSInteger startTime; |
|||
@property (nonatomic, assign) NSInteger duration; |
|||
@property (nonatomic, strong) NSString *text; |
|||
@property (nonatomic, readonly) NSString *startTimeText; |
|||
@property (nonatomic, readonly) NSString *endTimeText; |
|||
@end |
|||
|
|||
@interface QPlayAutoLyric : NSObject <NSCoding> |
|||
@property(nonatomic,assign) BOOL isTxtType;//歌词是不是纯文本的歌词,没有时间标记
|
|||
@property(nonatomic,strong) NSString *songId; |
|||
@property(nonatomic,strong) NSString *songName; |
|||
@property(nonatomic,strong) NSString *singerName; |
|||
@property(nonatomic,strong) NSString *albumName; |
|||
@property(nonatomic,readonly) NSString *text;//所有歌词文本
|
|||
@property(nonatomic,strong) NSArray<QPlayAutoSentence *> *sentences; |
|||
- (NSString *)sentenceAtTime:(NSTimeInterval)time; |
|||
@end |
|||
|
|||
|
|||
#endif /* QPlayAutoDefine_h */ |
|||
@ -1,188 +0,0 @@ |
|||
//
|
|||
// QPlayAutoSDK.h
|
|||
// QPlayAutoSDK
|
|||
//
|
|||
// Created by travisli(李鞠佑) on 2018/11/5.
|
|||
// Copyright © 2018年 腾讯音乐. All rights reserved.
|
|||
//
|
|||
|
|||
#import <Foundation/Foundation.h> |
|||
#import "QPlayAutoDefine.h" |
|||
|
|||
#define APP_DEVICE_TYPE (3) |
|||
|
|||
NS_ASSUME_NONNULL_BEGIN |
|||
|
|||
typedef void (^QPlayAutoResultItemsBlock)(NSInteger errorCode,NSArray<QPlayAutoListItem *> *_Nullable items); |
|||
typedef void (^QPlayAutoResultParentItemBlock)(NSInteger errorCode,QPlayAutoListItem *parentItem); |
|||
|
|||
extern NSString const * QPlayAutoSDKVersion; |
|||
|
|||
@protocol QPlayAutoSDKDelegate <NSObject> |
|||
|
|||
//连接状态变化回调
|
|||
- (void)onQPlayAutoConnectStateChanged:(QPlayAutoConnectState)newState; |
|||
//播放状态状态变化回调
|
|||
- (void)onQPlayAutoPlayStateChanged:(QPlayAutoPlayState)playState song:(QPlayAutoListItem *)song position:(NSInteger)position; |
|||
//歌曲播放进度
|
|||
- (void)onQPlayAutoPlayProgressChanged:(QPlayAutoListItem *)song progress:(NSTimeInterval)progress duration:(NSTimeInterval)duration; |
|||
//歌曲收藏状态变化
|
|||
- (void)onSongFavoriteStateChange:(NSString*)songID isFavorite:(BOOL)isFavorite; |
|||
//播放状态事件变化
|
|||
- (void)onPlayModeChange:(QPlayAutoPlayMode)playMode; |
|||
//定时关闭事件
|
|||
- (void)onPlayPausedByTimeoff; |
|||
//登陆状态
|
|||
- (void)onLoginStateDidChanged:(BOOL)isLoginOK; |
|||
@end |
|||
|
|||
|
|||
|
|||
@interface QPlayAutoSDK : NSObject |
|||
|
|||
/// 注册App
|
|||
/// @param name 名称
|
|||
/// @param brand 品牌
|
|||
/// @param deviceId ?
|
|||
/// @param scheme 授权成功后Q音跳转合作方的scheme
|
|||
/// @param appId Q音分配的Id
|
|||
/// @param secretKey 合作方私钥
|
|||
/// @param bundleId 合作方包名
|
|||
+ (void)registerAppWithName:(NSString *)name brand:(NSString *)brand deviceId:(NSString *)deviceId scheme:(NSString *)scheme appId:(NSString *)appId secretKey:(NSString *)secretKey bundleId:(NSString *)bundleId; |
|||
|
|||
/// 播放状态
|
|||
+ (QPlayAutoPlayMode)currentPlayMode; |
|||
/// 当前歌曲
|
|||
+ (QPlayAutoListItem *_Nullable)currentSong; |
|||
/// 当前播放状态
|
|||
+ (QPlayAutoPlayState)currentPlayState; |
|||
/// 当前播放进度
|
|||
+ (NSTimeInterval)currentProgress; |
|||
/// QQ音乐是否登录
|
|||
+ (BOOL)isLoginOK; |
|||
/// 检查QQ音乐是否已安装
|
|||
+ (BOOL)isQQMusicInstalled; |
|||
/// 是否已连接
|
|||
+ (BOOL)isConnected; |
|||
/// 连接中
|
|||
+ (BOOL)isConnecting; |
|||
///QQ音乐设备信息
|
|||
+ (NSDictionary *)deviceInfo; |
|||
|
|||
+(NSString *)openId; |
|||
+(NSString *)openToken; |
|||
|
|||
|
|||
///是否可以处理回调url
|
|||
+ (BOOL)canHandleOpenURL:(NSURL *)url; |
|||
///处理回调url
|
|||
+ (BOOL)handleOpenURL:(NSURL *)url; |
|||
|
|||
/// 回调代理
|
|||
+ (void)setDelegate:(id<QPlayAutoSDKDelegate>) delegate; |
|||
|
|||
|
|||
/// 拉端连接QPlay
|
|||
/// - Parameter forceLogin: 是否强制登录
|
|||
+ (void)connectAndForceLogin:(BOOL)forceLogin; |
|||
/// 停止
|
|||
+ (void)stop; |
|||
|
|||
|
|||
/// 二次热启动连接(需要联系Q音打开此功能才能使用)
|
|||
/// - Parameters:
|
|||
/// - timeout: 超时时间
|
|||
/// - completion: 回调
|
|||
+ (void)reconnectWithTimeout:(NSTimeInterval)timeout completion:(QPlayAutoRequestFinishBlock)completion; |
|||
|
|||
/// 跳转QQ音乐登录
|
|||
/// @param bundleId 合作方bundleId
|
|||
/// @param callbackUrl 跳转合作方url
|
|||
+ (BOOL)loginQQMusicWithBundleId:(NSString *)bundleId callbackUrl:(NSString *)callbackUrl; |
|||
|
|||
|
|||
/// 获取数据
|
|||
/// @param parent 父
|
|||
/// @param pageIndex 页码
|
|||
/// @param pageSize 页大小
|
|||
/// @param completion 回调
|
|||
+ (void)getDataItemsFromParent:(QPlayAutoListItem *)parent pageIndex:(NSUInteger)pageIndex pageSize:(NSUInteger)pageSize completion:(QPlayAutoResultParentItemBlock)completion; |
|||
|
|||
|
|||
/// 设置播放模式
|
|||
/// @param playMode 播放模式
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setPlayMode:(QPlayAutoPlayMode)playMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
|
|||
/// 设置播放整首还是高潮
|
|||
/// @param assencceMode 高潮还是整首
|
|||
/// @param block 回调
|
|||
+ (NSInteger)setAssenceMode:(QPlayAutoAssenceMode)assencceMode callback:(QPlayAutoRequestFinishBlock _Nullable )block; |
|||
|
|||
/// 收藏/取消收藏(歌曲id)
|
|||
/// @param song 歌曲
|
|||
/// @param isFavorite 收藏/取消收藏
|
|||
/// @param completion 回调
|
|||
+ (void)setFavoriteStateWithSong:(QPlayAutoListItem *)song isFavorite:(BOOL)isFavorite completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
/// 播放歌曲
|
|||
/// @param songList 歌曲列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playAtIndex:(NSArray<QPlayAutoListItem*> *)songList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
/// 通过歌曲Mid列表播放歌曲
|
|||
/// @param songMidList 歌曲Mid列表
|
|||
/// @param playIndex 播放索引
|
|||
/// @param completion 回调
|
|||
+ (void)playSongMidAtIndex:(NSArray<NSString*> *)songMidList playIndex:(NSInteger)playIndex completion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
|
|||
///播放下一首
|
|||
+ (void)playerPlayNextWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放上一首
|
|||
+ (void)playerPlayPrevWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///播放暂停
|
|||
+ (void)playerPlayPause; |
|||
|
|||
///播放恢复
|
|||
+ (void)playerPlayResumeWithCompletion:(void (^)(NSInteger errorCode))completion; |
|||
|
|||
///Seek到指定位置
|
|||
+ (void)playerSeek:(NSInteger)position; |
|||
|
|||
|
|||
/// 搜索歌曲
|
|||
/// @param keyword 关键词
|
|||
/// @param type 搜索类型
|
|||
/// @param firstPage 是否第一页
|
|||
/// @param completion 回调
|
|||
+ (NSInteger)search:(NSString *)keyword |
|||
type:(QPlayAutoSearchType)type |
|||
firstPage:(BOOL)firstPage |
|||
completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
/// 相似歌曲
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestSimilarWithSong:(QPlayAutoListItem *)song completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
|
|||
/// 查询歌词
|
|||
/// @param song 歌曲
|
|||
/// @param completion 回调
|
|||
+ (void)requestLyricWithSong:(QPlayAutoListItem *)song completion:(void (^)(NSInteger errorCode,QPlayAutoLyric *_Nullable lyric))completion; |
|||
|
|||
|
|||
/// 获取特定歌曲列表
|
|||
/// @param type 列表类型
|
|||
/// @param completion 回调
|
|||
+ (void)requestSonglistWithType:(QPlayAutoSongListType)type completion:(QPlayAutoResultItemsBlock)completion; |
|||
|
|||
@end |
|||
|
|||
NS_ASSUME_NONNULL_END |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,8 +0,0 @@ |
|||
module QPlayAutoSDK { |
|||
header "Headers/include/QPlayAutoSDK.h" |
|||
header "Headers/include/QPlayAutoDefine.h" |
|||
|
|||
export * |
|||
|
|||
link "QPlayAutoSDK" |
|||
} |
|||
Loading…
Reference in new issue