1importAVFoundation2importMediaPlayer3importUIKit45classViewController:UIViewController{67overridefuncviewDidLoad(){8super.viewDidLoad()9// Do any additional setup after loading the view, typically from a nib.1011let albumsQuery =MPMediaQuery.albums()12guardlet albums:[MPMediaItemCollection]= albumsQuery.collections else{13print("error")14return15}1617for album in albums {1819let title = album.representativeItem?.albumTitle ??""20let artist = album.representativeItem?.albumArtist ??""21let releaseDate = album.representativeItem?.releaseDate
22let propertyReleaseDate = album.representativeItem?.value(forProperty:MPMediaItemPropertyReleaseDate)23let year = album.representativeItem?.value(forProperty:"year")2425print("title: (title)")26print("artist: (artist)")27print("releaseDate: (releaseDate)")28print("propertyReleaseDate: (propertyReleaseDate)")29print("year: (year)\n")3031for single in(album.items){3233let singleTitle = single.value(forProperty:MPMediaItemPropertyTitle)??""34let singleArtist = single.value(forProperty:MPMediaItemPropertyArtist)??""35let singleReleaseDate = single.releaseDate
36let singlePropertyReleaseDate = single.value(forProperty:MPMediaItemPropertyReleaseDate)37let singleYear = single.value(forProperty:"year")3839print("singleTitle: (singleTitle)")40print("singleArtist: (singleArtist)")41print("singleReleaseDate: (singleReleaseDate)")42print("singlePropertyReleaseDate: (singlePropertyReleaseDate)")43print("singleYear: (singleYear)\n")44}45}4647}4849overridefuncdidReceiveMemoryWarning(){50super.didReceiveMemoryWarning()51// Dispose of any resources that can be recreated.52}535455}5657
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/02 13:05