MPNowPlayingInfoCenter nowPlayingInfo ignored for AVPlayer audio via AirPlay
I have implemented audio playback using AVPlayer, playing a remote mp3 url.
I want to display the information about the currently playing audio using the
When I lock the screen, I do see the image and title I set, so I know that this method is registering the information in some way, but when I switch to AirPlay to an AppleTV, the display looks like a generic video output, with the progress bar at bottom, but elapsed time and duration correctly displayed.
If I set this same
nowPlayingInfo, but then start some audio using an AudioQueue, then it properly displays the image on half the screen (it looks just like playing a podcast with the iPod/Music app).
Is this just a limitation of AirPlay support for audio using AVPlayer, or is there some way to get it to display the image and info properly?
- Customize the Airplay button's appearance
- Airplay from iPad - a separate UIView to display on Apple TV
- What is the code to call the actionsheet AirPlay directly?
- Airplay: Mirror subview on external window
- iOS - How can I display an 'AirPlay' popup menu in Swift?
- How to check if the device is connected via airplay?
2 Solutions Collect From Internet About “MPNowPlayingInfoCenter nowPlayingInfo ignored for AVPlayer audio via AirPlay”
Ok – I dug through the apple dev forums and found a hint.
If you are using AVPlayer for audio only, and want it to work in the background while doing airplay, you need to disable the
Apparently AVPlayer on iOS 5+ assumes that it is playing back video via AirPlay, and so does not allow backgrounding, unless you explicitly disable video AirPlay.
Once you disable this (i.e.
self.player.allowsAirPlayVideo = NO;) then your audio will still play via AirPlay, but now it will now show the audio/ipod like interface correctly.
If you’re on iOS7 you’ve got to disable external playback :
self.player.allowsExternalPlayback = NO;
- UIImageView .scaleAspectFit and autolayout not working programmatically from Swift
- How To Separate Strings For UIScrollView/UITextView based on the size of the frame
- regiondidchange called several times on app load swift
- Swift dictionary get the value without access or knowing the key
- Can my class override protocol property type in Swift?
- Swift : missing argument label 'xxx' in call
- Running iOS App in background for more than 10 minutes
- Checking Firebase current signed-in user via Listener in iOS
- Drawing a dashed line with CGContextSetLineDash
- User Login With AFNetworking
- Full swipe UITableViewCell to delete UITableView iOS 8
- Cocoa Binding Mutable Dictionary with Search Field
- UILabel layer cornerRadius negatively impacting performance
- rightBarButtonItem image not showing up
- Use of unresolved identifier 'FIRDatabase' when using Firebase