Created
June 14, 2017 21:11
-
-
Save hashaam/7f4786cec05b2b3861824c076342b84e to your computer and use it in GitHub Desktop.
Display now playing information in Command Center
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://hashaam.com/2017/06/15/display-now-playing-information-in-command-center/ | |
import UIKit | |
import MediaPlayer | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupNowPlayingInfo() | |
} | |
func setupNowPlayingInfo() { | |
let image = UIImage(named: "artwork")! | |
let mediaArtwork = MPMediaItemArtwork(boundsSize: image.size) { (size: CGSize) -> UIImage in | |
return image | |
} | |
let nowPlayingInfo: [String: Any] = [ | |
MPMediaItemPropertyArtist: "hashaam.com", | |
MPMediaItemPropertyTitle: "Live Streaming Example", | |
MPMediaItemPropertyArtwork: mediaArtwork, | |
MPNowPlayingInfoPropertyIsLiveStream: true | |
] | |
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment