Wednesday, October 11, 2023
HomeiOS Developmentios - When utilizing AVPlayerViewController cannot show MPMediaItemPropertyArtwork throughout Airplay

ios – When utilizing AVPlayerViewController cannot show MPMediaItemPropertyArtwork throughout Airplay


A piece of my app shows numerous types of media from an API, photographs, movies and songs (audio + a picture). I am utilizing AVPlayerController and utilizing an UIImageView on prime of its contentOverlayView to show tune album photographs. I’m setting the nowPlayingInfo dictionary, one thing like this when the media begins enjoying:

non-public func setupNowPlaying() {
        
    let elapsedTime = CMTimeGetSeconds(playerController?.participant?.currentTime() ?? CMTime(worth: 0, timescale: CMTimeScale()))
    let length = CMTimeGetSeconds(playerController?.participant?.currentItem?.length ?? CMTime(worth: 0, timescale: CMTimeScale()))
        
    MPNowPlayingInfoCenter.default().nowPlayingInfo = [
        MPMediaItemPropertyAlbumTitle: airPlayAlbum,
        MPNowPlayingInfoPropertyPlaybackRate: 1.0,
        MPMediaItemPropertyTitle: airPlayName,
        MPMediaItemPropertyArtist: airPlayArtist,
        MPNowPlayingInfoPropertyElapsedPlaybackTime: elapsedTime,
        MPMediaItemPropertyPlaybackDuration: duration,
        MPNowPlayingInfoPropertyMediaType: 1
    ]
        
    if let picture = imageView?.picture {
        MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: picture.measurement) { measurement in
            return picture.resizedImage(measurement: measurement)
        }
    }
        
    setupCommands()
    hasSetupNowPlaying = true
}

This accurately shows every part within the iOS command centre for movies and songs. Nevertheless when utilizing the airplay button contained in the AVPlayerViewController to forged to an exterior TV, it solely shows the tune title and a black display screen with playback controls whereas the audio is enjoying, no album paintings. Movies show accurately

Following a suggestion on-line I attempted setting:

playerController?.participant?.allowsExternalPlayback = false

This hides the inbuilt airplay button on the playerController, however when utilizing the command centre to set off airplay, it now accurately shows album paintings, tune title, album title and so on on the exterior television. With this setting on, movies not forged to the exterior television, so thats probably not an answer

Has anybody discovered an answer to leaving allowsExternalPlayback set to true, but in addition displaying the album paintings? There are many complaints on-line about this, however there appears to be no decision



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments