Created
September 27, 2016 23:34
-
-
Save hanawat/6d04117aab752338c8b9cf7b97cf5f58 to your computer and use it in GitHub Desktop.
iOS10.1でApple MusicのためのAPIが追加されたので試す ref: http://qiita.com/hanawat/items/c900cefcefdadb9b7283
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
player.setQueueWithStoreIDs(storeIds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// collectionView(_:didSelectItemAt:) | |
let descriptor = MPMusicPlayerStoreQueueDescriptor(storeIDs: trackIds) | |
descriptor.startItemID = trackIds[indexPath.row] | |
player.setQueueWith(descriptor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
descriptor.setStartTime(10.0, forItemWithStoreID: storeId) | |
descriptor.setEndTime(30.0, forItemWithStoreID: storeId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
playerViewController.player.prepareToPlay(completionHandler: { error in | |
if error == nil { | |
player.play() | |
} else { | |
print(error?.localizedDescription) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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