使用WebImage和MusicKitSwiftUI获取未知的专辑封面图像

问题描述

我正在尝试使用WebImage来获取未知的专辑封面(其中带有音符的灰色方块)。目前,我正在播放歌曲时获取专辑封面,但是我想在没有播放时显示灰色音乐图像。我目前有:

if self.isPlaying {
    WebImage(url: URL(string: self.currentSong.artworkURL.replacingOccurrences(of: "{w}",with: "\(Int(geometry.size.width - 24) * 2)").replacingOccurrences(of: "{h}",with: "\(Int(geometry.size.width - 24) * 2)")))
        .resizable()
        .frame(width: geometry.size.width - 24,height: geometry.size.width - 24)
        .cornerRadius(20)
        .shadow(radius: 10)
} else {
    //show gray music icon
    Text("will add image")
}

我不确定应该使用哪个网址来获取该图片(该图片也会显示在未知的专辑封面中,因此该网址是否可用?)。

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...