Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

53 lines
2.4KB

  1. #import <AudioToolbox/AudioToolbox.h>
  2. #import <AudioToolbox/AudioServices.h>
  3. #import <UIKit/UIKit.h>
  4. @interface MPUNowPlayingMetadata
  5. @property (nonatomic,readonly) NSString * title;
  6. @property (nonatomic,readonly) NSString * artist;
  7. @end
  8. @interface MPUNowPlayingController
  9. @property bool isPlaying;
  10. @property (nonatomic,readonly) NSString * nowPlayingAppDisplayID;
  11. @property (nonatomic,readonly) MPUNowPlayingMetadata * currentNowPlayingMetadata;
  12. @end
  13. @interface JBBulletinManager : NSObject
  14. +(id)sharedInstance;
  15. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID;
  16. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID soundPath:(NSString *)soundPath;
  17. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID soundID:(int)inSoundID;
  18. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overrideBundleImage:(UIImage *)overridBundleImage;
  19. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overrideBundleImage:(UIImage *)overridBundleImage soundPath:(NSString *)soundPath;
  20. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overridBundleImage:(UIImage *)overridBundleImage soundID:(int)inSoundID;
  21. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID hasSound:(BOOL)hasSound soundID:(int)soundID vibrateMode:(int)vibrate soundPath:(NSString *)soundPath attachmentImage:(UIImage *)attachmentImage overrideBundleImage:(UIImage *)overrideBundleImage;
  22. @end
  23. %hook MPUNowPlayingController
  24. static NSString *cachedTitle;
  25. -(void)_updateCurrentNowPlaying{
  26. %orig;
  27. double delayInSeconds = 0.5;
  28. dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
  29. dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
  30. if(self.isPlaying && ([self.nowPlayingAppDisplayID isEqualToString:@"com.apple.Music"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.spotify.client"]) && ![cachedTitle isEqualToString:self.currentNowPlayingMetadata.title]){
  31. cachedTitle = [self.currentNowPlayingMetadata.title copy];
  32. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:self.currentNowPlayingMetadata.title message:self.currentNowPlayingMetadata.artist bundleID:self.nowPlayingAppDisplayID];
  33. }
  34. });
  35. }
  36. %end