Browse Source

修复报错

weicu
fdp 1 year ago
parent
commit
6b9be2ceaa
  1. 4
      ios/Podfile.lock
  2. 14
      local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift

4
ios/Podfile.lock

@ -85,7 +85,7 @@ PODS:
- SDWebImage/Core (~> 5.17) - SDWebImage/Core (~> 5.17)
- spotify_sdk (0.0.1): - spotify_sdk (0.0.1):
- Flutter - Flutter
- tencentcloud_cos_sdk_plugin (1.2.4): - tencentcloud_cos_sdk_plugin (1.2.3):
- Flutter - Flutter
- QCloudCOSXML (= 6.4.7) - QCloudCOSXML (= 6.4.7)
- WechatOpenSDK-XCFramework (2.0.4) - WechatOpenSDK-XCFramework (2.0.4)
@ -203,7 +203,7 @@ SPEC CHECKSUMS:
SDWebImage: f84b0feeb08d2d11e6a9b843cb06d75ebf5b8868 SDWebImage: f84b0feeb08d2d11e6a9b843cb06d75ebf5b8868
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380 SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
spotify_sdk: a48400bb29f70c4fe251ebfdc9135c37097ac5ca spotify_sdk: a48400bb29f70c4fe251ebfdc9135c37097ac5ca
tencentcloud_cos_sdk_plugin: 7bed564dbe72df23e7b5cacb1e51b1a20cb1639c tencentcloud_cos_sdk_plugin: c3d78b2c3bae42b5a20009dc047f3f1621e6272b
WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f
wifi_iot: f645260a2be8608517b2a9bf4c39b98e97003acc wifi_iot: f645260a2be8608517b2a9bf4c39b98e97003acc

14
local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift

@ -212,11 +212,12 @@ public class MusicService: NSObject {
let totalDuration = (duration.isNaN || duration.isInfinite || duration <= 0) ? 0 : Int(duration * 1000) let totalDuration = (duration.isNaN || duration.isInfinite || duration <= 0) ? 0 : Int(duration * 1000)
let progress = (totalDuration > 0 && currentTime >= 0) ? currentTime / duration : 0.0 let progress = (totalDuration > 0 && currentTime >= 0) ? currentTime / duration : 0.0
let result = [ let result: [String: Any] = [ // Add explicit type annotation here
"currentPosition": currentPosition, "currentPosition": currentPosition,
"duration": totalDuration, "duration": totalDuration,
"progress": progress.isNaN || progress.isInfinite ? 0.0 : progress "progress": progress.isNaN || progress.isInfinite ? 0.0 : progress
] ]
// 添加调试日志 // 添加调试日志
if totalDuration == 0 { if totalDuration == 0 {
@ -567,7 +568,7 @@ public class MusicService: NSObject {
// 存储歌曲信息,用于状态变化时更新 // 存储歌曲信息,用于状态变化时更新
objc_setAssociatedObject(playerItem, "songInfo", song, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) objc_setAssociatedObject(playerItem, "songInfo", song, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
} }
}
// MARK: - KVO 观察者 // MARK: - KVO 观察者
override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard let playerItem = object as? AVPlayerItem else { return } guard let playerItem = object as? AVPlayerItem else { return }
@ -623,3 +624,4 @@ override public func observeValue(forKeyPath keyPath: String?, of object: Any?,
break break
} }
} }
}
Loading…
Cancel
Save