From 6b9be2ceaa6da71b1aa28d0c879eb7cae60133b7 Mon Sep 17 00:00:00 2001 From: fdp <1286779656@qq.com> Date: Thu, 17 Jul 2025 10:26:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 4 ++-- .../Sources/music_service/MusicService.swift | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index c9050a312..d0bbc4669 100644 --- a/ios/Podfile.lock +++ b/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 diff --git a/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift b/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift index e9879a14b..ce5ca2ab5 100644 --- a/local_plugins/music_service/ios/music_service/Sources/music_service/MusicService.swift +++ b/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 progress = (totalDuration > 0 && currentTime >= 0) ? currentTime / duration : 0.0 - let result = [ - "currentPosition": currentPosition, - "duration": totalDuration, - "progress": progress.isNaN || progress.isInfinite ? 0.0 : progress - ] + let result: [String: Any] = [ // Add explicit type annotation here + "currentPosition": currentPosition, + "duration": totalDuration, + "progress": progress.isNaN || progress.isInfinite ? 0.0 : progress + ] + // 添加调试日志 if totalDuration == 0 { @@ -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 } } +} \ No newline at end of file