I am trying to create a multi-player music player with tracks coming from YouTube and Soundcloud, and I would like to redefine the contents of MPNowPlayingInfoCenter to provide information about artists / releases instead of the name of the YouTube video.
Everything went fine when I used UIWebview, but for performance reasons I had to switch to the new WKWebview, and now the method that I used earlier to set nowPlayingInfos has no effect
Is there a way to disable the automatic mapping of <audio> and <video> tags inside HTML and / or override the information provided by my information?
Here is the code I use that works on iOS 7 and worked on iOS 8 when I used UIWebview:
let newInfos = [ MPMediaItemPropertyTitle: (currentPlaylist[currentPlaylistIndex] as! Track).trackName, MPMediaItemPropertyArtist: (currentPlaylist[currentPlaylistIndex] as! Track).trackArtist, MPMediaItemPropertyPlaybackDuration: NSNumber(integer: self.getDuration()), MPNowPlayingInfoPropertyElapsedPlaybackTime: NSNumber(integer: self.getCurrentTime()), MPNowPlayingInfoPropertyPlaybackRate: NSNumber(double: self.playing ? 1.0 : 0.0), MPMediaItemPropertyArtwork: MPMediaItemArtwork(image: image) ] MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = newInfos
I checked that none of the variables that I use is nil, and I activated my AudioSession in AppDelegate
var audioSession = AVAudioSession.sharedInstance() var error : NSError? audioSession.setCategory(AVAudioSessionCategoryPlayback, error: &error) audioSession.setActive(true, error: &error) UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
Any ideas?
ios swift wkwebview media-player
Marc peysale
source share