如何在WatchKit NowPlaying视图中显示播放进度条

时间:2020-11-12 18:44:10

标签: swiftui watchkit apple-watch

我已经获得了一些NowPlaying视图文本元素,可以使用此元素来工作:

func updateInfoState(){
    let artwork = MPMediaItemArtwork.init(boundsSize: self.uiImage.size, requestHandler: { (size) -> UIImage in
        return self.uiImage
    })
    MPNowPlayingInfoCenter.default().nowPlayingInfo = [MPMediaItemPropertyAlbumTitle: title,
                              MPMediaItemPropertyArtist: author,
                              MPMediaItemPropertyTitle: trackName,
                              MPMediaItemPropertyArtwork:artwork,
                              MPNowPlayingInfoPropertyElapsedPlaybackTime: 0.0,
                              MPNowPlayingInfoPropertyPlaybackRate: 1.0,
                              MPNowPlayingInfoPropertyIsLiveStream: false,
    ]
  }

但是我无法获得播放位置的更新。我正在尝试MPNowPlayingInfoPropertyElapsedPlaybackTimeMPNowPlayingInfoPropertyPlaybackRate,但实际上它们什么也没做。任何帮助将不胜感激。

0 个答案:

没有答案