mpmediaitem

How to get lyrics for Now Playing song in iOS10 (Swift 3)

て烟熏妆下的殇ゞ 提交于 2019-12-04 06:59:59
I want to display lyrics from song that is currently playing by iOS system player. Here is my custom player: import UIKit import MediaPlayer import AVFoundation class NowPlayingController: NSObject { var musicPlayer: MPMusicPlayerController { if musicPlayer_Lazy == nil { musicPlayer_Lazy = MPMusicPlayerController.systemMusicPlayer() let center = NotificationCenter.default center.addObserver(self, selector: #selector(self.playingItemDidChange), name: NSNotification.Name.MPMusicPlayerControllerNowPlayingItemDidChange, object: musicPlayer_Lazy) musicPlayer_Lazy!

Get audio file size without export

醉酒当歌 提交于 2019-12-04 06:59:23
i'm developing an app that export audio file stored in the iPod library, but i should verify the file size before export and upload (server has a fixed max upload size): i know that after exporting file, the size will not be the same: is there any method to estimate the new size ? main question : can i know the original file size before export (using MPMediaItem or something else), so i can tell user that this file can't be uploaded (the export can take a while). thanks. I have not tested but AVAssetExportSession can help you with this. MPMediaItem *curItem = musicPlayer.nowPlayingItem; NSURL

MPMediaItemArtwork returning wrong sized artwork

别来无恙 提交于 2019-12-04 05:27:30
I'm seeing a consistent issue with MPMediaItemArtwork in that it's returning artwork in a size different to that which I request. The code I'm using is as follows MPMediaItem *representativeItem = [self.representativeItems objectAtIndex:index]; MPMediaItemArtwork *artwork = [representativeItem valueForProperty:MPMediaItemPropertyArtwork]; UIImage *albumCover = [artwork imageWithSize:CGSizeMake(128.0f, 128.0f)]; This works as expected, except that the size of the returned image is always {320.0f, 320.0f} even though I specifically asked for {128.0f, 128.0f} and it's causing some memory issues

MPMusicPlayerController breaks lock screen controls

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 20:56:51
I'm attempting to use MPMusicPlayerController to play apple music songs, but I can't get the lock screen controls to work. It seems as though MPMusicPlayerController overridess the remoteControlReceivedWithEvent listener. Here is how I set up my controller: self.player = [MPMusicPlayerController applicationMusicPlayer]; self.player.repeatMode = MPMusicRepeatModeNone; self.player.shuffleMode = MPMusicShuffleModeOff; [self.player beginGeneratingPlaybackNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePlaybackStateChanged:) name

Objective C: Getting MPMediaItem 'Favorite' property

£可爱£侵袭症+ 提交于 2019-12-03 20:56:05
I was looking at Apple's documentation, and I cannot seem to find a way to get whether or not an MPMediaItem is a 'favorite' track or not. See screenshot below, with the pink heart. How can one get this property? I know since it's a new feature, it's availability would be limited to iOS 8.4 or later. Here's some code I'm using to get other properties from MPMediaItems, via the music picker: - (void) processMediaItems:(MPMediaItemCollection *)mediaItemCollection { //iterate through selected songs if (mediaItemCollection) { NSArray *allSelectedSongs = [mediaItemCollection items]; for(MPMediaItem

Iphone - Writing a media player with lyrics

为君一笑 提交于 2019-12-03 17:29:52
I want to write a simple media player which displays lyrics that are retrieved from the web. I know once LyricWiki was such a source, but now no longer exists. Does a new API or source for lyrics exist that I can use ? When I do get the lyrics, how do I sync them with song ? I know the MPMediaItem class has the MPMediaItemPropertyLyrics but this is cleary not enough for me cause this is only for songs from Itunes and not all of them have lyrics available. I would appreciate any help or links that can I use to sort this issue. A little Googling and I found a few options that might solve your

Obtaining iTunes ID to an iPod player item

六月ゝ 毕业季﹏ 提交于 2019-12-03 01:39:45
I have an app that interacts with both the iPod player, and the iTunes Store Web Service Search API. Is there a way to obtain the iTunes ID for a song that I retrieve from my user's iPod library (e.g. via MPMusicPlayerController, or MPMediaItem)? The documentation says that the MPMediaItemPropertyPersistentID is a unique identifier that persists across app launch. This however, seems like it might be a unique local id. The only solution I can think of is to retrieve the song title and artist from MPMediaItem, then query iTunes to obtain the iTunes ID. Is the iTunes ID stored anywhere locally

URL to MPMediaItem

筅森魡賤 提交于 2019-12-03 00:36:47
I have a simple question but i can't found a right answer. I have a song url saved to my database. An path Like this. aSound.path = [[item valueForProperty: MPMediaItemPropertyAssetURL] absoluteString]; How to convert back to a MPMediaItem object wich has songname artist and artwork? Is it possible? Thanks the answers. amleszk Saving: NSNumber* persistentID = [mediaItem valueForProperty:MPMediaItemPropertyPersistentID]; Loading: MPMediaPropertyPredicate * predicate = [MPMediaPropertyPredicate predicateWithValue:persistentID forProperty:MPMediaItemPropertyPersistentID]; Another example:

how to convert nsdata to MPMediaitem song iOS Sdk

痴心易碎 提交于 2019-12-02 11:48:23
问题 i converted MPMediaItem to NSData and stored that in database, now i have to convert that NSData to MPMediaItem to play that song in mediaplayer. Used below code to convert MPMediaItem to NSData: NSURL *url = [song valueForProperty: MPMediaItemPropertyAssetURL]; AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil]; AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetPassthrough]; exporter.outputFileType = @

how to convert nsdata to MPMediaitem song iOS Sdk

馋奶兔 提交于 2019-12-02 03:15:29
i converted MPMediaItem to NSData and stored that in database, now i have to convert that NSData to MPMediaItem to play that song in mediaplayer. Used below code to convert MPMediaItem to NSData: NSURL *url = [song valueForProperty: MPMediaItemPropertyAssetURL]; AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil]; AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetPassthrough]; exporter.outputFileType = @"public.mpeg-4"; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,