Setting and accessing iOS seek bar on lock screen

♀尐吖头ヾ 提交于 2019-12-09 13:09:03

问题


I am playing a audio file in iOS app using AVQueuePlayer/AVFoundation. i have set the MPNowPlayingInfoCenter's now playing information like album title, artist, Artwork, like this

NSMutableDictionary *albumInfo = [[NSMutableDictionary alloc] init];
MPMediaItemArtwork *artworkP;
UIImage *artWork = [UIImage imageNamed:album.imageUrl];
[albumInfo setObject:album.title forKey:MPMediaItemPropertyTitle];
[albumInfo setObject:album.auther forKey:MPMediaItemPropertyArtist];
[albumInfo setObject:album.title forKey:MPMediaItemPropertyAlbumTitle];
[albumInfo setObject:artworkP forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:albumInfo]

and also accessing remote event in application delegate for play,pause, next, previous event from lock screen. But the seek bar is not accessible, even i didn't find any option to set seek property.

i want to set seek property and want to access the seek slider change event in my app.


回答1:


I believe the only way to support forward and backward seeking is by the previous/advance buttons (they send a begin/end seeking notification when held down).

UIEventSubtypeRemoteControlBeginSeekingBackward, UIEventSubtypeRemoteControlBeginSeekingForward, 
UIEventSubtypeRemoteControlEndSeekingBackward, UIEventSubtypeRemoteControlEndSeekingForward

Based on some of the other questions and documentation the seek bar is only accessible via Apple's own apps (https://stackoverflow.com/a/20142141/535632, https://stackoverflow.com/a/20909875/535632). According to that last answer, it appears some apps (notably Spotify) route their music through the music player to utilize the seek bar.




回答2:


You can use MPRemoteCommandCenter after iOS 7



来源:https://stackoverflow.com/questions/21549846/setting-and-accessing-ios-seek-bar-on-lock-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!