9

I'm working with CarPlay(simulator 10.3.1) and implement all methods in MPPlayableContentDataSource but method below isn't called.

- (void)contentItemForIdentifier:(NSString *)identifier completionHandler:(void(^)(MPContentItem *__nullable, NSError * __nullable))completionHandler 

Does anybody know any reasons?

Misha Vyrko
  • 992
  • 6
  • 14

2 Answers2

0

Have you set delegate & dataSource of the MPPlayableContentDataSource. Because without setting this two property, all methods related to dataSource & delegate won't execute.

Dipak Kacha
  • 423
  • 2
  • 13
  • Method in question is optional and it doesn't work for me. All other methods work. it's dataSource. But doesn't matter - content is loaded and displayed on CarPlay. I need this method for other reasons – Misha Vyrko Oct 26 '17 at 08:13
  • Method you have listed is inherited from "MPPlayableContentDataSource" Protocol. So if you are not inheriting that protocol to that class, the method you defining will work like other methods we use. That means it won't execute until you call it. So just cross check whether you have inherited this protocol when class is defined. For reference you can go through this link https://developer.apple.com/documentation/mediaplayer/mpplayablecontentdatasource?language=objc – Dipak Kacha Oct 26 '17 at 10:15
  • All other methods work. My class conform MPPlayableContentDataSource Protocol. – Misha Vyrko Oct 26 '17 at 10:27
0

numberOfChildItemsAtIndexPath: and contentItemAtIndexPath: is the synchronous API that is usually used.

From my understanding, CarPlay only uses contentItemForIdentifier:completionHandler: when you are triggering the asynchronous loading via beginLoadingChildItemsAtIndexPath:completionHandler.

FWIW, the official CarPlay audio programming guide as of March 2017 (I didn't see a newer version, at least not online) does not mention the asynchronous methods.

DrMickeyLauer
  • 4,455
  • 3
  • 31
  • 67