Documentation Archive Developer
Search

MediaPlayer Changes for Swift

MediaPlayer

Modified MPContentItem
Declaration
From
class MPContentItem : NSObject {
    var identifier: String { get }
    var title: String?
    var subtitle: String?
    var artwork: MPMediaItemArtwork?
    var container: Bool
    var playable: Bool
    var playbackProgress: Float
    init(identifier identifier: String)
}
To
class MPContentItem : NSObject {
    init(identifier identifier: String)
    var identifier: String { get }
    var title: String?
    var subtitle: String?
    var artwork: MPMediaItemArtwork?
    var container: Bool
    var playable: Bool
    var playbackProgress: Float
}

Declaration
From
class MPMediaLibrary : NSObject, NSSecureCoding {
    class func defaultMediaLibrary() -> MPMediaLibrary
    var lastModifiedDate: NSDate { get }
    func beginGeneratingLibraryChangeNotifications()
    func endGeneratingLibraryChangeNotifications()
}
To
class MPMediaLibrary : NSObject, NSSecureCoding {
    class func defaultMediaLibrary() -> MPMediaLibrary
    var lastModifiedDate: NSDate { get }
    func beginGeneratingLibraryChangeNotifications()
    func endGeneratingLibraryChangeNotifications()
    class func authorizationStatus() -> MPMediaLibraryAuthorizationStatus
    class func requestAuthorization(_ handler: (MPMediaLibraryAuthorizationStatus) -> Void)
    func addItemWithProductID(_ productID: String, completionHandler completionHandler: (([MPMediaEntity], NSError?) -> Void)?)
    func getPlaylistWithUUID(_ uuid: NSUUID, creationMetadata creationMetadata: MPMediaPlaylistCreationMetadata?, completionHandler completionHandler: (MPMediaPlaylist?, NSError?) -> Void)
}

Declaration
From
class MPMediaPlaylist : MPMediaItemCollection {
    var persistentID: MPMediaEntityPersistentID { get }
    var name: String? { get }
    var playlistAttributes: MPMediaPlaylistAttribute { get }
    var seedItems: [MPMediaItem]? { get }
}
To
class MPMediaPlaylist : MPMediaItemCollection {
    var persistentID: MPMediaEntityPersistentID { get }
    var name: String? { get }
    var playlistAttributes: MPMediaPlaylistAttribute { get }
    var seedItems: [MPMediaItem]? { get }
    var descriptionText: String? { get }
    var authorDisplayName: String? { get }
    func addItemWithProductID(_ productID: String, completionHandler completionHandler: ((NSError?) -> Void)?)
    func addMediaItems(_ mediaItems: [MPMediaItem], completionHandler completionHandler: ((NSError?) -> Void)?)
}

Declaration
From
class MPMusicPlayerController : NSObject, MPMediaPlayback {
    class func applicationMusicPlayer() -> MPMusicPlayerController
    class func systemMusicPlayer() -> MPMusicPlayerController
    class func iPodMusicPlayer() -> MPMusicPlayerController
}
extension MPMusicPlayerController {
    var playbackState: MPMusicPlaybackState { get }
    var repeatMode: MPMusicRepeatMode
    var shuffleMode: MPMusicShuffleMode
    var volume: Float
    @NSCopying var nowPlayingItem: MPMediaItem?
    var indexOfNowPlayingItem: Int { get }
    func setQueueWithQuery(_ query: MPMediaQuery)
    func setQueueWithItemCollection(_ itemCollection: MPMediaItemCollection)
    func skipToNextItem()
    func skipToBeginning()
    func skipToPreviousItem()
    func beginGeneratingPlaybackNotifications()
    func endGeneratingPlaybackNotifications()
}
To
class MPMusicPlayerController : NSObject, MPMediaPlayback {
    class func applicationMusicPlayer() -> MPMusicPlayerController
    class func systemMusicPlayer() -> MPMusicPlayerController
    class func iPodMusicPlayer() -> MPMusicPlayerController
}
extension MPMusicPlayerController {
    var playbackState: MPMusicPlaybackState { get }
    var repeatMode: MPMusicRepeatMode
    var shuffleMode: MPMusicShuffleMode
    var volume: Float
    @NSCopying var nowPlayingItem: MPMediaItem?
    var indexOfNowPlayingItem: Int { get }
    func setQueueWithQuery(_ query: MPMediaQuery)
    func setQueueWithItemCollection(_ itemCollection: MPMediaItemCollection)
    func setQueueWithStoreIDs(_ storeIDs: [String])
    func skipToNextItem()
    func skipToBeginning()
    func skipToPreviousItem()
    func beginGeneratingPlaybackNotifications()
    func endGeneratingPlaybackNotifications()
}