Browse Source

修复报错

newdev_shunjiawei
fdp 1 year ago
parent
commit
c14dfb849f
  1. 4
      ios/Podfile.lock
  2. 6
      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)
- spotify_sdk (0.0.1):
- Flutter
- tencentcloud_cos_sdk_plugin (1.2.4):
- tencentcloud_cos_sdk_plugin (1.2.3):
- Flutter
- QCloudCOSXML (= 6.4.7)
- WechatOpenSDK-XCFramework (2.0.4)
@ -203,7 +203,7 @@ SPEC CHECKSUMS:
SDWebImage: f84b0feeb08d2d11e6a9b843cb06d75ebf5b8868
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
spotify_sdk: a48400bb29f70c4fe251ebfdc9135c37097ac5ca
tencentcloud_cos_sdk_plugin: 7bed564dbe72df23e7b5cacb1e51b1a20cb1639c
tencentcloud_cos_sdk_plugin: c3d78b2c3bae42b5a20009dc047f3f1621e6272b
WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f
wifi_iot: f645260a2be8608517b2a9bf4c39b98e97003acc

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

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