MediaRemote.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Media remote framework header.
  3. *
  4. * Copyright (c) 2013-2014 Cykey (David Murray)
  5. * All rights reserved.
  6. */
  7. #ifndef MEDIAREMOTE_H_
  8. #define MEDIAREMOTE_H_
  9. #include <CoreFoundation/CoreFoundation.h>
  10. #if __cplusplus
  11. extern "C" {
  12. #endif
  13. #pragma mark - Notifications
  14. /*
  15. * These are used on the local notification center.
  16. */
  17. extern CFStringRef kMRMediaRemoteNowPlayingInfoDidChangeNotification;
  18. extern CFStringRef kMRMediaRemoteNowPlayingPlaybackQueueDidChangeNotification;
  19. extern CFStringRef kMRMediaRemotePickableRoutesDidChangeNotification;
  20. extern CFStringRef kMRMediaRemoteNowPlayingApplicationDidChangeNotification;
  21. extern CFStringRef kMRMediaRemoteNowPlayingApplicationIsPlayingDidChangeNotification;
  22. extern CFStringRef kMRMediaRemoteRouteStatusDidChangeNotification;
  23. #pragma mark - Keys
  24. extern CFStringRef kMRMediaRemoteNowPlayingApplicationPIDUserInfoKey;
  25. extern CFStringRef kMRMediaRemoteNowPlayingApplicationIsPlayingUserInfoKey;
  26. extern CFStringRef kMRMediaRemoteNowPlayingInfoAlbum;
  27. extern CFStringRef kMRMediaRemoteNowPlayingInfoArtist;
  28. extern CFStringRef kMRMediaRemoteNowPlayingInfoArtworkData;
  29. extern CFStringRef kMRMediaRemoteNowPlayingInfoArtworkMIMEType;
  30. extern CFStringRef kMRMediaRemoteNowPlayingInfoChapterNumber;
  31. extern CFStringRef kMRMediaRemoteNowPlayingInfoComposer;
  32. extern CFStringRef kMRMediaRemoteNowPlayingInfoDuration;
  33. extern CFStringRef kMRMediaRemoteNowPlayingInfoElapsedTime;
  34. extern CFStringRef kMRMediaRemoteNowPlayingInfoGenre;
  35. extern CFStringRef kMRMediaRemoteNowPlayingInfoIsAdvertisement;
  36. extern CFStringRef kMRMediaRemoteNowPlayingInfoIsBanned;
  37. extern CFStringRef kMRMediaRemoteNowPlayingInfoIsInWishList;
  38. extern CFStringRef kMRMediaRemoteNowPlayingInfoIsLiked;
  39. extern CFStringRef kMRMediaRemoteNowPlayingInfoIsMusicApp;
  40. extern CFStringRef kMRMediaRemoteNowPlayingInfoPlaybackRate;
  41. extern CFStringRef kMRMediaRemoteNowPlayingInfoProhibitsSkip;
  42. extern CFStringRef kMRMediaRemoteNowPlayingInfoQueueIndex;
  43. extern CFStringRef kMRMediaRemoteNowPlayingInfoRadioStationIdentifier;
  44. extern CFStringRef kMRMediaRemoteNowPlayingInfoRepeatMode;
  45. extern CFStringRef kMRMediaRemoteNowPlayingInfoShuffleMode;
  46. extern CFStringRef kMRMediaRemoteNowPlayingInfoStartTime;
  47. extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsFastForward15Seconds;
  48. extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsIsBanned;
  49. extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsIsLiked;
  50. extern CFStringRef kMRMediaRemoteNowPlayingInfoSupportsRewind15Seconds;
  51. extern CFStringRef kMRMediaRemoteNowPlayingInfoTimestamp;
  52. extern CFStringRef kMRMediaRemoteNowPlayingInfoTitle;
  53. extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalChapterCount;
  54. extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalDiscCount;
  55. extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalQueueCount;
  56. extern CFStringRef kMRMediaRemoteNowPlayingInfoTotalTrackCount;
  57. extern CFStringRef kMRMediaRemoteNowPlayingInfoTrackNumber;
  58. extern CFStringRef kMRMediaRemoteNowPlayingInfoUniqueIdentifier;
  59. extern CFStringRef kMRMediaRemoteNowPlayingInfoRadioStationIdentifier;
  60. extern CFStringRef kMRMediaRemoteNowPlayingInfoRadioStationHash;
  61. extern CFStringRef kMRMediaRemoteOptionMediaType;
  62. extern CFStringRef kMRMediaRemoteOptionSourceID;
  63. extern CFStringRef kMRMediaRemoteOptionTrackID;
  64. extern CFStringRef kMRMediaRemoteOptionStationID;
  65. extern CFStringRef kMRMediaRemoteOptionStationHash;
  66. extern CFStringRef kMRMediaRemoteRouteDescriptionUserInfoKey;
  67. extern CFStringRef kMRMediaRemoteRouteStatusUserInfoKey;
  68. #pragma mark - API
  69. typedef enum {
  70. /*
  71. * Use nil for userInfo.
  72. */
  73. kMRPlay = 0,
  74. kMRPause = 1,
  75. kMRTogglePlayPause = 2,
  76. kMRStop = 3,
  77. kMRNextTrack = 4,
  78. kMRPreviousTrack = 5,
  79. kMRToggleShuffle = 6,
  80. kMRToggleRepeat = 7,
  81. kMRStartForwardSeek = 8,
  82. kMREndForwardSeek = 9,
  83. kMRStartBackwardSeek = 10,
  84. kMREndBackwardSeek = 11,
  85. kMRGoBackFifteenSeconds = 12,
  86. kMRSkipFifteenSeconds = 13,
  87. /*
  88. * Use a NSDictionary for userInfo, which contains three keys:
  89. * kMRMediaRemoteOptionTrackID
  90. * kMRMediaRemoteOptionStationID
  91. * kMRMediaRemoteOptionStationHash
  92. */
  93. kMRLikeTrack = 0x6A,
  94. kMRBanTrack = 0x6B,
  95. kMRAddTrackToWishList = 0x6C,
  96. kMRRemoveTrackFromWishList = 0x6D
  97. } MRCommand;
  98. Boolean MRMediaRemoteSendCommand(MRCommand command, id userInfo);
  99. void MRMediaRemoteSetPlaybackSpeed(int speed);
  100. void MRMediaRemoteSetElapsedTime(double elapsedTime);
  101. void MRMediaRemoteSetNowPlayingApplicationOverrideEnabled(Boolean enabled);
  102. void MRMediaRemoteRegisterForNowPlayingNotifications(dispatch_queue_t queue);
  103. void MRMediaRemoteUnregisterForNowPlayingNotifications();
  104. void MRMediaRemoteBeginRouteDiscovery();
  105. void MRMediaRemoteEndRouteDiscovery();
  106. CFArrayRef MRMediaRemoteCopyPickableRoutes();
  107. typedef void (^MRMediaRemoteGetNowPlayingInfoCompletion)(CFDictionaryRef information);
  108. typedef void (^MRMediaRemoteGetNowPlayingApplicationPIDCompletion)(int PID);
  109. typedef void (^MRMediaRemoteGetNowPlayingApplicationIsPlayingCompletion)(Boolean isPlaying);
  110. void MRMediaRemoteGetNowPlayingApplicationPID(dispatch_queue_t queue, MRMediaRemoteGetNowPlayingApplicationPIDCompletion completion);
  111. void MRMediaRemoteGetNowPlayingInfo(dispatch_queue_t queue, MRMediaRemoteGetNowPlayingInfoCompletion completion);
  112. void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, MRMediaRemoteGetNowPlayingApplicationIsPlayingCompletion completion);
  113. void MRMediaRemoteKeepAlive();
  114. void MRMediaRemoteSetElapsedTime(double time);
  115. void MRMediaRemoteSetShuffleMode(int mode);
  116. void MRMediaRemoteSetRepeatMode(int mode);
  117. /*
  118. * The identifier can be obtained using MRMediaRemoteCopyPickableRoutes.
  119. * Use the 'RouteUID' or the 'RouteName' key.
  120. */
  121. int MRMediaRemoteSelectSourceWithID(CFStringRef identifier);
  122. void MRMediaRemoteSetPickedRouteWithPassword(CFStringRef route, CFStringRef password);
  123. CFArrayRef MRMediaRemoteCopyPickableRoutesForCategory(NSString *category);
  124. Boolean MRMediaRemotePickedRouteHasVolumeControl();
  125. void MRMediaRemoteSetCanBeNowPlayingApplication(Boolean can);
  126. void MRMediaRemoteSetNowPlayingInfo(CFDictionaryRef information);
  127. #if __cplusplus
  128. }
  129. #endif
  130. #endif /* MEDIAREMOTE_H_ */