How to set current playback duration and elapsed time on iOS 7 lockscreen?

前端 未结 3 1314
抹茶落季
抹茶落季 2020-12-08 05:25

Starting from iOS 5, every music player can set current playing music information such as title, artist, album title, and artwork on [MPNowPlayingInfoCenter defaultCenter].n

3条回答
  •  难免孤独
    2020-12-08 05:53

    You need to setup playback rate to 1.0f even if documentation says it's 1.0 by default.

    NSDictionary *mediaInfo = @{
        MPMediaItemPropertyTitle: audio.title,
        MPMediaItemPropertyArtist: audio.artist,
        MPMediaItemPropertyPlaybackDuration: audio.duration,
        MPNowPlayingInfoPropertyPlaybackRate: @(1.0)
    };
    
    [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo];
    

提交回复
热议问题