|
|
|
@ -15,8 +15,8 @@ class SpotifService { |
|
|
|
/// 初始化OpenAI服务 |
|
|
|
Future<bool> initialize() async { |
|
|
|
if (!isInitialized) { |
|
|
|
getAccessToken(); |
|
|
|
connectToSpotifyRemote(); |
|
|
|
await getAccessToken(); |
|
|
|
await connectToSpotifyRemote(); |
|
|
|
isInitialized = true; |
|
|
|
printInfo(info: "SpotifService----------- initialize"); |
|
|
|
} |
|
|
|
@ -68,6 +68,28 @@ class SpotifService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取当前播放状态 |
|
|
|
Future<bool> isPaused() async { |
|
|
|
try { |
|
|
|
var state = await SpotifySdk.getPlayerState(); |
|
|
|
if (state != null) { |
|
|
|
printInfo(info: "SpotifService----------- isPaused $state"); |
|
|
|
return state.isPaused; |
|
|
|
} else { |
|
|
|
printError(info: "SpotifService----------- isPaused null"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} on PlatformException catch (e) { |
|
|
|
printError( |
|
|
|
info: |
|
|
|
"SpotifService------------getPlayerState ${e.code}: ${e.message}"); |
|
|
|
} on MissingPluginException { |
|
|
|
printError( |
|
|
|
info: "SpotifService------------getPlayerState not implemented"); |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
//播放 音乐 |
|
|
|
Future<void> play(String url) async { |
|
|
|
try { |
|
|
|
|