Search code examples
swiftmedia-playeravfoundation

Media Info displayed in simulator but doesn't display on real device


I have tried this code to show media info:

import MediaPlayer

let audioInfo = MPNowPlayingInfoCenter.defaultCenter()
audioInfo.nowPlayingInfo = [ MPMediaItemPropertyTitle: "Miley_Cyrus_", MPMediaItemPropertyArtist:"artistName"]

This is working fine on simulator as shown into image:

enter image description here

But this is not working correctly on real Device:

enter image description here

There is no media info displayed in real device as displayed into simulator. Am I missing something?


Solution

  • I have just found the solution for it

    UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
    

    This is working fine.

    Reference from HERE.