When the application does not enter the background, it can update the notification bar for the next episode after automatically playing through the front-end notification bar.
But when the app enters the background and automatically plays the next episode, the notification bar cannot be updated.
When entering the background, there is a timer constantly calling the method of updating the notification bar in the system.
When switching to the next episode, the system method was called and the dictionary passed in was also fine, but it was not updated
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:img]];
dispatch_async(dispatch_get_main_queue(), ^{
_coverImage = [UIImage imageWithData:imageData];
if (_coverImage) {
MPMediaItemArtwork * mArt = [[MPMediaItemArtwork alloc] initWithImage:_coverImage];
[_audioInfoDic setObject:mArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:_audioInfoDic];
}
});
});
This is log:
—luyu————————haveImage
—luyu————————haveImage
—luyu————————NoImage
—luyu————————haveImage
—luyu————————haveImage
MPNowPlayingInfoCenter (log with noImage) updated in the main thread
But the notification bar has not been updated
bass is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.