Skip to content

Instantly share code, notes, and snippets.

@hanawat
Created September 27, 2016 23:34
Show Gist options
  • Save hanawat/6d04117aab752338c8b9cf7b97cf5f58 to your computer and use it in GitHub Desktop.
Save hanawat/6d04117aab752338c8b9cf7b97cf5f58 to your computer and use it in GitHub Desktop.
iOS10.1でApple MusicのためのAPIが追加されたので試す ref: http://qiita.com/hanawat/items/c900cefcefdadb9b7283
player.setQueueWithStoreIDs(storeIds)
// collectionView(_:didSelectItemAt:)
let selectedStoreIds = trackIds.enumerated().filter { $0.offset >= indexPath.row }.map { $0.element }
+ trackIds.enumerated().filter { $0.offset < indexPath.row }.map { $0.element }
player.repeatMode = .all
player.setQueueWithStoreIDs(selectedStoreIds)
// collectionView(_:didSelectItemAt:)
let descriptor = MPMusicPlayerStoreQueueDescriptor(storeIDs: trackIds)
descriptor.startItemID = trackIds[indexPath.row]
player.setQueueWith(descriptor)
descriptor.setStartTime(10.0, forItemWithStoreID: storeId)
descriptor.setEndTime(30.0, forItemWithStoreID: storeId)
playerViewController.player.prepareToPlay(completionHandler: { error in
if error == nil {
player.play()
} else {
print(error?.localizedDescription)
}
})
struct MPError {
init(_nsError _nsError: NSError)
static var _nsErrorDomain: String { get }
enum Code : Int {
typealias _ErrorType = MPError
case unknown
case permissionDenied
case cloudServiceCapabilityMissing
case networkConnectionFailed
case notFound
case notSupported
}
static var unknown: MPError.Code { get }
static var permissionDenied: MPError.Code { get }
static var cloudServiceCapabilityMissing: MPError.Code { get }
static var networkConnectionFailed: MPError.Code { get }
static var notFound: MPError.Code { get }
static var notSupported: MPError.Code { get }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment