You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
3.7KB

  1. #import <UIKit/UIKit.h>
  2. @interface SBLockScreenManager
  3. +(SBLockScreenManager *)sharedInstance;
  4. -(BOOL)isUILocked;
  5. @end
  6. @interface MPUNowPlayingController
  7. @property bool isPlaying;
  8. @property (nonatomic,readonly) NSString * nowPlayingAppDisplayID;
  9. @property (nonatomic,readonly) UIImage * currentNowPlayingArtwork;
  10. @property (nonatomic,readonly) NSDictionary * currentNowPlayingInfo;
  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 hasSound:(BOOL)hasSound soundID:(int)soundID vibrateMode:(int)vibrate soundPath:(NSString *)soundPath attachmentImage:(UIImage *)attachmentImage overrideBundleImage:(UIImage *)overrideBundleImage;
  16. @end
  17. %hook MPUNowPlayingController
  18. static NSString *cachedTitle;
  19. static NSString *artist;
  20. static NSString *album;
  21. -(void)_updateCurrentNowPlaying{
  22. %orig;
  23. NSString *settingsPath = @"/var/mobile/Library/Preferences/com.gilshahar7.notifymusicprefs.plist";
  24. NSMutableDictionary *prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPath];
  25. BOOL enablewhilelocked = [[prefs objectForKey:@"enablewhilelocked"] boolValue];
  26. BOOL showalbumname = [[prefs objectForKey:@"showalbumname"] boolValue];
  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(![cachedTitle isEqualToString:self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"]]){
  31. cachedTitle = [self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"] copy];
  32. if((enablewhilelocked || (![[%c(SBLockScreenManager) sharedInstance] isUILocked])) && self.isPlaying && ([self.nowPlayingAppDisplayID isEqualToString:@"com.aspiro.TIDAL"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.ondalabs.doppi"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.coppertino.VoxMobile"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.soundcloud.TouchApp"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.Saavn.Saavn"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.apple.Music"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.spotify.client"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.pandora"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.rhapsody.iphone.Rhapsody3"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.google.PlayMusic"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.deezer.Deezer"] || [self.nowPlayingAppDisplayID isEqualToString:@"com.michaelclay.Cesium"])){
  33. artist = [NSString stringWithFormat: @"\n%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoArtist"]];
  34. if([self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"] length] > 1 && showalbumname){
  35. album = self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoAlbum"];
  36. }else{
  37. album = @"Now Playing";
  38. }
  39. if(self.currentNowPlayingArtwork != nil){
  40. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:album message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"], artist] bundleID:self.nowPlayingAppDisplayID hasSound:false soundID:0 vibrateMode:0 soundPath:@"" attachmentImage:self.currentNowPlayingArtwork overrideBundleImage:nil];
  41. }else{
  42. [[objc_getClass("JBBulletinManager") sharedInstance] showBulletinWithTitle:album message:[NSString stringWithFormat: @"%@%@", self.currentNowPlayingInfo[@"kMRMediaRemoteNowPlayingInfoTitle"], artist] bundleID:self.nowPlayingAppDisplayID];
  43. }
  44. }
  45. }
  46. });
  47. }
  48. %end