Accessing the Music Library

Accessing the Music Library

Fb69c72d5af289d6674d2659246a5291?s=128

Tomohiro Nishimura

March 30, 2016
Tweet

Transcript

  1. "DDFTTJOH UIF.VTJD-JCSBSZ ؔ੢ϞόΠϧΞϓϦݚڀձ JE4JYFJHIU

  2. ·͓͖͑ w JE4JYFJHIU !UPNPIJ@SP  w ג ͸ͯͳ w J1IPOF͚ͩͨ͘

    w
  3. None
  4. None
  5. None
  6. ㊗"QQMF.VTJDղې

  7. ௥Ճ͞Εͨ"1*ʢൈਮ w 4,$MPVE4FSWJDF$POUSPMMFS w .1.FEJB-JCSBSZ w BEE*UFN8JUI1SPEVDU*%DPNQMFUJPO)BOEMFS w .1.VTJD1MBZFS$POUSPMMFS w

    TFU2VFVF8JUI4UPSF*%T
  8. 4,$MPVE4FSWJDF$POUSPMMFS w BVUIPSJ[BUJPO4UBUVT  w SFRVFTU"VUIPSJ[BUJPO @  w SFRVFTU$BQBCJMJUJFT8JUI$PNQMFUJPO)BOEMFS

    @  w SFRVFTU4UPSFGSPOU*EFOUJpFS8JUI$PNQMFUJPO)B OEMFS @
  9. 4,$MPVE4FSWJDF$POUSPMMFS w BVUIPSJ[BUJPO4UBUVT  w SFRVFTU"VUIPSJ[BUJPO @  w SFRVFTU$BQBCJMJUJFT8JUI$PNQMFUJPO)BOEMFS

    @  w SFRVFTU4UPSFGSPOU*EFOUJpFS8JUI$PNQMFUJPO)B OEMFS @
  10. switch SKCloudServiceController.authorizationStatus() { case .Authorized: // ڐՄ͞Ε͍ͯΔ case .Denied: //

    ڐՄ͞Ε͍ͯͳ͍ case .NotDetermined: // ͲͪΒ͔ܾ·͍ͬͯͳ͍ (ڐՄΛٻΊΔඞཁ͕͋Δ) case .Restricted: // Ұ෦ͷػೳ͕ڐՄ͞Ε͍ͯΔ }
  11. 4,$MPVE4FSWJDF$POUSPMMFS w BVUIPSJ[BUJPO4UBUVT  w SFRVFTU"VUIPSJ[BUJPO @  w SFRVFTU$BQBCJMJUJFT8JUI$PNQMFUJPO)BOEMFS

    @  w SFRVFTU4UPSFGSPOU*EFOUJpFS8JUI$PNQMFUJPO)B OEMFS @
  12. SKCloudServiceController.requestAuthorization { status in guard status == .Authorized || status

    == .Restricted else { return } // ڐՄ͞Εͨʂ }
  13. ݖݶ w ֬ೝͷμΠΞϩά͕ग़ΔͷͰ ϢʔβʔʹڐՄͯ͠΋Β͏ඞ ཁ͕͋Δ

  14. ݖݶ w .&%*"@-*#3"3:ͱ͍͏ͷ ͕૿͑ͯΔ w ͜Ε͕༗ޮͰͳ͍ͱԿ΋ग़དྷ ͳ͍ w ϓϥΠόγʔͷઃఆʹ΋௥Ճ ͞Ε͍ͯΔ

  15. 4,$MPVE4FSWJDF$POUSPMMFS w BVUIPSJ[BUJPO4UBUVT  w SFRVFTU"VUIPSJ[BUJPO @  w SFRVFTU$BQBCJMJUJFT8JUI$PNQMFUJPO)BOEMF

    S @  w SFRVFTU4UPSFGSPOU*EFOUJpFS8JUI$PNQMFUJPO)B OEMFS @
  16. let controller = SKCloudServiceController() controller.requestCapabilitiesWithCompletionHandler { (capabilities, error) in if

    let error = error { print(error) fatalError() } if capabilities.contains(.MusicCatalogPlayback) { // ࠶ੜՄೳ } if capabilities.contains(.AddToCloudMusicLibrary) { // ϥΠϒϥϦ΁ͷ௥ՃՄೳ } }
  17. 4,$MPVE4FSWJDF$POUSPMMFS w BVUIPSJ[BUJPO4UBUVT  w SFRVFTU"VUIPSJ[BUJPO @  w SFRVFTU$BQBCJMJUJFT8JUI$PNQMFUJPO)BOEMFS

    @  w SFRVFTU4UPSFGSPOU*EFOUJpFS8JUI$PNQMFUJP O)BOEMFS @
  18. 4UPSFGSPOU*% w ֤ࠃͷJ5VOFT4UPSFΛද͢*% w "1*Ͱ͸Ϣʔβʔ͕"QQMF.VTJDͷܖ໿Λ͍ͯ͠ Δࠃͷ*%ΛऔಘͰ͖Δ w ࠃ͝ͱʹ1SPEVDU*%͕มΘΔͷͰॏཁ w ͨͩ͠ʮ

    ʯͷ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Γ͍ͨ͠ w J5VOFT4FBSDI"1*Ͱݕࡧͯ͠4UPSF*%Λήοτ ͢Δඞཁ͕͋Δ ݱ࣮

  26. 4UPSF*%͕෼͔ͬͯ ͍Δલఏͷ"1*

  27. let player = MPMusicPlayerController.systemMusicPlayer() player.setQueueWithStoreIDs(["154657357", "1033055855"]) player.play()

  28. let player = MPMusicPlayerController.systemMusicPlayer() player.setQueueWithStoreIDs(["154657357", "1033055855"]) player.play() ஫ɿ೔ຊͷJ5.4Ͱ͔͠༗ޮ͡Όͳ͍

  29. DPMMFDUJPO7JFX6SMIUUQTJUVOFTBQQMFDPNKQBMCVNBIBSEEBZTOJHIUJE USBDL7JFX6SMIUUQTJUVOFTBQQMFDPNKQBMCVNBIBSEEBZTOJHIUJE QSFWJFX6SMIUUQBQIPCPTBQQMFDPNVTS.VTJDWG BSUXPSL6SMIUUQJTN[TUBUJDDPNJNBHFUIVNC.VTJDWGBEDGBE BSUXPSL6SMIUUQJTN[TUBUJDDPNJNBHFUIVNC.VTJDWGBEDGBE BSUXPSL6SMIUUQJTN[TUBUJDDPNJNBHFUIVNC.VTJDWGBEDGB DPMMFDUJPO1SJDF  USBDL1SJDF 

    SFMFBTF%BUF5;  DPMMFDUJPO&YQMJDJUOFTTOPU&YQMJDJU  USBDL&YQMJDJUOFTTOPU&YQMJDJU  EJTD$PVOU  EJTD/VNCFS  USBDL$PVOU  USBDL/VNCFS  USBDL5JNF.JMMJT  DPVOUSZ+1/  DVSSFODZ+1:  QSJNBSZ(FOSF/BNFϩοΫ  JT4USFBNBCMFUSVF ^
  30. ϥΠϒϥϦʹ௥Ճ͢Δ w .1.FEJB-JCSBSZ w BEE*UFN8JUI1SPEVDU*%DPNQMFUJPO)BOEMFS

  31. ͜Ε͕ग़དྷΔ

  32. let mediaLibrary = MPMediaLibrary.defaultMediaLibrary() mediaLibrary.addItemWithProductID("1078914477") { (entities, error) in if

    let error = error { print(error) fatalError() } // ௥Ճ׬ྃ }
  33. ࡶଟͳ࿩ w ͢Ͱʹ௥ՃࡁͷۂΛ௥Ճͯ͠΋େৎ෉ w "1*Ͱ௥Ճͯ͠΋ΞʔτϫʔΫ͸औಘ͞Εͳ͍ w .VTJDΞϓϦͰ։͍ͨΓ͢Δ͔͠ͳ͍ʁ w ফ͢͜ͱ͸ग़དྷͳ͍ͷͰςετͰڵຯͳ͍ۂΛ௥Ճ͠· ͘ΔͱͭΒ͍

    w ࠶ੜ΋͚ͩΕͲΞϧόϜͷ4UPSF*%Λࢦఆ͢ΔͱɺΞ ϧόϜ಺ͷશۂ͕ର৅ʹͳΔ
  34. ໝ૝

  35. w 1MBZMJTUͷڞ༗ w ଞਓ͕࡞ͬͨ1MBZMJTUΛฉ͍ͨΓ ϥΠϒϥϦʹ௥Ճग़དྷΔ w ϥδΦ w ΈΜͳͷϦΫΤετʹΑͬͯ 1MBZMJTUΛ࡞ͬͯΞϓϦ͔Βಉ࣌

    ʹௌ͘ w ʜ w ͳΜ͔΋͏ͪΐͬͱ"1*͕ཉ͍͠ʂ
  36. ؔϞό Ұ೥ʂ  ͓ΊͰͱ͏͍͟͝·͢