Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CarPlayの対応方法と日本での現状

 CarPlayの対応方法と日本での現状

Yuji Hato

August 20, 2016
Tweet

More Decks by Yuji Hato

Other Decks in Technology

Transcript

  1. What is CarPlay • 2014೥3݄3೔ʹCarPlay͕ਖ਼ࣜൃද • iPhone୺຤ΛΧʔφϏ౳ͷंࡌػثʹ࿈ಈͤ͞Δ γεςϜ • MapsɺMusicɺPhoneɺMessagesɺPodcastsͳͲͷ

    iOSΞϓϦ΍SiriΛंࡌσΟεϓϨΠͰ௚઀ૢ࡞Ͱ͖Δ • αʔυύʔςΟͷAudioΞϓϦ΋ରԠՄೳ • ຊମΞϓϦͷҰ෦ͱͯ͠ಈ࡞͢Δ
  2. ରԠ ΞϓϦ • Tuneln Radio • MLB.com At Bat •

    NHK WORLD TV ? • Audible • VOX • Audio Books • Spotify • AWA ೔ຊ ւ֎ etc…
  3. ରԠ φϏ ७ਖ਼φϏ ରԠφϏ ରԠंछ τϤλ   εζΩ ଟػೳϝϞϦʔφϏήʔγϣϯ

    ΠάχεɺιϦΦɺεϖʔγΞɺϋεϥʔ ೔࢈ ϓϨϛΞϜφϏ બ୒φϏ࣍ୈ ϗϯμ ελϯμʔυφϏҎ্ બ୒φϏ࣍ୈɺ"DDPSEɺ-FHFOE౳͸º Ϛπμ   ࡾඛ  Ԥभ޲͚ύδΣϩɻ೔ຊ͸·ͩະରԠ εόϧ ࣍ظΠϯϓϨοα ϕϯπ " # $-" $-4 (-" (-&ɺࠓޙॱ࣍ #.8  "VEJ  " 2ɻࠓޙॱ࣍ 78 $PNQPTJUJPONFEJB /FX1PMP 5JHVBOͳͲɻࠓޙॱ࣍ (. ೥Ҏ߱ൃചͷશϞσϧରԠ 'PSE ೥ൃചͷશϞσϧରԠ 7PMWP 9$4 7 αʔυύʔςΟ ରԠφϏ ύΠΦχΞ 41)%" ΞϧύΠϯ J-9 ೔ຊͰ͸ະൃച ϝʔΧʔϗʔϜϖʔδͳͲ͔Βͷಠࣗௐ΂ 2016/08/14ݱࡏ
  4. ࣮૷ MPPlayableContentManager class CarPlayDemo: NSObject, MPPlayableContentDataSource, MPPlayableContentDelegate { static let

    shared = CarPlayDemo() func setup() { MPPlayableContentManager.sharedContentManager().delegate = self MPPlayableContentManager.sharedContentManager().dataSource = self } … } func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { … CarPlayDemo.shared.setup() … }
  5. ࣮૷ MPPlayableContentDataSource func numberOfChildItemsAtIndexPath(indexPath: NSIndexPath) -> Int { // indexPathʹԠͨ͡Ϧετͷ݅਺Λฦ͢

    return 4 } func contentItemAtIndexPath(indexPath: NSIndexPath) -> MPContentItem? { // JOEFY1BUIʹԠͨ͡.1$POUFOU*UFNΛฦ͢ let contentItem = MPContentItem(identifier: "container1") contentItem.title = “container1" contentItem.artwork = CarPlayArtwork.Home.artwork contentItem.container = true contentItem.playable = false return contentItem }
  6. ࣮૷ ิ଍ NSIndexPath let indexPath = NSIndexPath(indexes: [1,4,3,2], length: 4)

    print(indexPath.length) // 4 print(indexPath.indexAtPosition(0)) // 1 print(indexPath.indexAtPosition(1)) // 4 print(indexPath.indexAtPosition(2)) // 3 print(indexPath.indexAtPosition(3)) // 2 // Get with pointer var indexesPtr = UnsafeMutablePointer<Int>.alloc(indexPath.length) indexPath.getIndexes(indexesPtr) let indexes = [Int](UnsafeBufferPointer(start: indexesPtr, count: indexPath.length)) indexes.forEach { value in print(value) // 1 4 3 2 }
  7. ࣮૷ MPNowPlayingInfoCenter var trackInfo: [String: AnyObject] = [:] trackInfo[MPMediaItemPropertyTitle] =

    "trackName" trackInfo[MPMediaItemPropertyArtist] = "artistName" trackInfo[MPMediaItemPropertyAlbumTitle] = "albumName" trackInfo[MPMediaItemPropertyPlaybackDuration] = 60 trackInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = 10 trackInfo[MPNowPlayingInfoPropertyPlaybackRate] = isPlaying ? 1 : 0 trackInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(image: UIImage(asset: .ArtworkDemo)) MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = trackInfo
  8. ࣮૷ MPRemoteCommandCenter let remoteCommandCenter = MPRemoteCommandCenter.sharedCommandCenter() remoteCommandCenter.nextTrackCommand.addTarget(self, action: #selector(RemoteCommand.next)) remoteCommandCenter.previousTrackCommand.addTarget(self,

    action: #selector(RemoteCommand.previous)) remoteCommandCenter.playCommand.addTarget(self, action: #selector(RemoteCommand.play)) remoteCommandCenter.pauseCommand.addTarget(self, action: #selector(RemoteCommand.pause)) remoteCommandCenter.togglePlayPauseCommand.addTarget(self, action: #selector(RemoteCommand.playOrPause)) …
  9. ࣮૷ Τϥʔදࣔ // MPPlayableContentDataSource func beginLoadingChildItemsAtIndexPath(indexPath: NSIndexPath, completionHandler: (NSError?) ->

    Void) { // Error completionHandler(CarPlayErrorType.NoData.error()) } // MPPlayableContentDelegate func playableContentManager(contentManager: MPPlayableContentManager, initiatePlaybackOfContentItemAtIndexPath indexPath: NSIndexPath, completionHandler: (NSError?) -> Void) { // Error completionHandler(CarPlayErrorType.PlaybackError.error()) }