mpmediaitem

MPMusicPlayerController breaks lock screen controls

随声附和 提交于 2020-01-01 06:55:05
问题 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

'NSInvalidArgumentException', reason: '-[AVPlayerItem duration]: unrecognized selector sent

纵饮孤独 提交于 2019-12-25 02:26:02
问题 I am trying to play a MediaItem using AVPlayer and later trying to get the duration of the current item like this (duration is an object of type CMTime): duration = [[player currentItem] duration]; I get no issues in iPad but in iPod Touch, I get the following error. I haven't tried this in iPhone yet. Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVPlayerItem duration]: unrecognized selector sent to instance 0x186100' Any pointers to the fix will be

cannot subscript a value of type [MPMediaItem]

送分小仙女□ 提交于 2019-12-24 15:20:05
问题 I am trying to execute this code in order to get all the music playlists that the users can have on their phones. var queryPlaylists = MPMediaQuery.playlistsQuery() print(queryPlaylists.collections[0]) However, when I try to access any of the elements of queryPlaylists.collections I get a compilation error: Cannot subscript a value of type [MPMediaItem]. This does not make any sense to me since the above in an array. In addition this used to work before xcode 7.0. 回答1: I figured out in order

Converting MPMediaItem to NSData

假如想象 提交于 2019-12-23 04:51:16
问题 I'm trying to convert an MPMediaItem to NSData object so I can play it with AVAudioPlayer. The following answer was posted a while back on a similar question, with steps on how to to that: MPMediaItems raw song data Of course you can access the data of a MPMediaItem. It's not crystal clear at once but it works. Here's how: Get the media item's URL from it's MPMediaItemPropertyAssetURL property Initialize an AVURLAsset with this URL Initialize an AVAssetReader with this asset Fetch the

Problems with MPMediaQuery and iTunes Match

ε祈祈猫儿з 提交于 2019-12-23 00:30:48
问题 I need to display a list of all of the playlists currently on the device. The problem is, on a device with iTunes Match turned on, any number of playlists could have zero items saved on the phone. Since (as far as I can tell) there's no reliable way to trigger an MPMediaItem download when you're using AVAudioPlayer , I'd like to filter out any playlists that don't have any local entries. Right now I can have it cycle through an individual playlist and strip songs that don't have an assetURL ,

Problems with MPMediaQuery and iTunes Match

社会主义新天地 提交于 2019-12-23 00:29:02
问题 I need to display a list of all of the playlists currently on the device. The problem is, on a device with iTunes Match turned on, any number of playlists could have zero items saved on the phone. Since (as far as I can tell) there's no reliable way to trigger an MPMediaItem download when you're using AVAudioPlayer , I'd like to filter out any playlists that don't have any local entries. Right now I can have it cycle through an individual playlist and strip songs that don't have an assetURL ,

How to get the MPMediaItem (audiobook) individual chapters

烂漫一生 提交于 2019-12-22 18:27:11
问题 I know I can get all the audiobooks from the iPod library with: MPMediaPropertyPredicate *abPredicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInt:MPMediaTypeAudioBook] forProperty:MPMediaItemPropertyMediaType]; MPMediaQuery *abQuery = [[MPMediaQuery alloc] init]; [abQuery addFilterPredicate:abPredicate]; [abQuery setGroupingType:MPMediaGroupingAlbum]; NSArray *books = [abQuery collections]; And I can get the parts/files for each book by using this: [book items];

How to get the MPMediaItem (audiobook) individual chapters

…衆ロ難τιáo~ 提交于 2019-12-22 18:27:06
问题 I know I can get all the audiobooks from the iPod library with: MPMediaPropertyPredicate *abPredicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInt:MPMediaTypeAudioBook] forProperty:MPMediaItemPropertyMediaType]; MPMediaQuery *abQuery = [[MPMediaQuery alloc] init]; [abQuery addFilterPredicate:abPredicate]; [abQuery setGroupingType:MPMediaGroupingAlbum]; NSArray *books = [abQuery collections]; And I can get the parts/files for each book by using this: [book items];

Get audio file size without export

早过忘川 提交于 2019-12-21 17:22:39
问题 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. 回答1: I have not

MPMediaItemArtwork returning wrong sized artwork

无人久伴 提交于 2019-12-21 10:57:26
问题 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