Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

50 Zeilen
3.0KB

  1. #import <UIKit/UIKit.h>
  2. @interface MPUNowPlayingMetadata
  3. @property (nonatomic,readonly) NSString * title;
  4. @property (nonatomic,readonly) NSString * artist;
  5. @end
  6. @interface MPUNowPlayingController
  7. @property bool isPlaying;
  8. @property (nonatomic,readonly) NSString * nowPlayingAppDisplayID;
  9. @property (nonatomic,readonly) MPUNowPlayingMetadata * currentNowPlayingMetadata;
  10. @property (nonatomic,readonly) UIImage * currentNowPlayingArtwork;
  11. @end
  12. @interface JBBulletinManager : NSObject
  13. +(id)sharedInstance;
  14. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID;
  15. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID soundPath:(NSString *)soundPath;
  16. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message bundleID:(NSString *)bundleID soundID:(int)inSoundID;
  17. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overrideBundleImage:(UIImage *)overridBundleImage;
  18. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overrideBundleImage:(UIImage *)overridBundleImage soundPath:(NSString *)soundPath;
  19. -(id)showBulletinWithTitle:(NSString *)title message:(NSString *)message overridBundleImage:(UIImage *)overridBundleImage soundID:(int)inSoundID;
  20. -(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;
  21. @end
  22. %hook MPUNowPlayingController
  23. static NSString *cachedTitle;
  24. static NSString *artist;
  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. if([self.currentNowPlayingMetadata.artist length] > 1){
  33. artist = [NSString stringWithFormat: @"\nBy: %@", self.currentNowPlayingMetadata.artist];
  34. }else{
  35. artist = @"";
  36. }
  37. if(self.currentNowPlayingArtwork != nil){
  38. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:@"Now Playing" message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingMetadata.title, artist] bundleID:self.nowPlayingAppDisplayID hasSound:false soundID:0 vibrateMode:0 soundPath:@"" attachmentImage:self.currentNowPlayingArtwork overrideBundleImage:nil];
  39. }else{
  40. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:@"Now Playing" message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingMetadata.title, artist] bundleID:self.nowPlayingAppDisplayID];
  41. }
  42. }
  43. });
  44. }
  45. %end