diff --git a/global/BridgingHeader.h b/global/BridgingHeader.h index 649c111..064426e 100644 --- a/global/BridgingHeader.h +++ b/global/BridgingHeader.h @@ -8,29 +8,5 @@ #import #import #import -#import +#import #import - -typedef NS_ENUM(NSInteger, MPUNowPlayingTitlesViewStyle) { - MPUNowPlayingTitlesViewStyleIdk -}; - -@interface MPUNowPlayingTitlesView : UIView - -- (instancetype)initWithStyle:(MPUNowPlayingTitlesViewStyle)style; - -@property (nonatomic) MPUNowPlayingTitlesViewStyle style; - -@property (nonatomic, copy) NSString *titleText; -@property (nonatomic, copy) NSString *albumText; -@property (nonatomic, copy) NSString *artistText; -@property (nonatomic, copy) NSString *stationNameText; - -@property (nonatomic, retain) NSDictionary *titleTextAttributes; -@property (nonatomic, retain) NSDictionary *detailTextAttributes; - -@property (getter=isExplicit, nonatomic) BOOL explicit; - -@property (getter=isMarqueeEnabled, nonatomic) BOOL marqueeEnabled; - -@end diff --git a/global/MediaControlsViewController.swift b/global/MediaControlsViewController.swift index 11d4034..773ac79 100644 --- a/global/MediaControlsViewController.swift +++ b/global/MediaControlsViewController.swift @@ -58,13 +58,13 @@ class MediaControlsViewController: UIViewController, MPUNowPlayingDelegate { view.autoresizingMask = [ .flexibleWidth ] - // construct the views containerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(containerView) artworkView.translatesAutoresizingMaskIntoConstraints = false artworkView.activated = true + artworkView.addTarget(self, action: #selector(self.artworkTapped), for: .touchUpInside) containerView.addSubview(artworkView) labelsContainerView.translatesAutoresizingMaskIntoConstraints = false @@ -202,6 +202,10 @@ class MediaControlsViewController: UIViewController, MPUNowPlayingDelegate { return } + // for some reason, this starts off being nil and calling it causes it to be populated, which + // we'll need to open the app if the artwork view is tapped + _ = nowPlayingController.nowPlayingAppDisplayID + // set the labels to something useful let attributes = [ NSFontAttributeName: UIFont.preferredFont(forTextStyle: .body), @@ -236,5 +240,17 @@ class MediaControlsViewController: UIViewController, MPUNowPlayingDelegate { func nowPlayingController(_ nowPlayingController: MPUNowPlayingController!, playbackStateDidChange state: Bool) { artworkView.setActivated(state, animated: true) } + + // MARK: - Callbacks + + func artworkTapped() { + guard let bundleID = nowPlayingController.nowPlayingAppDisplayID else { + // nothing playing, probably. nothing to do here + return + } + + // launch the app, hopefully + LSApplicationWorkspace.default().openApplication(withBundleID: bundleID) + } }