mpmediaitem

Apple Music Offline Files Have no URL?

霸气de小男生 提交于 2019-12-12 07:49:15
问题 It seems that the property MPMediaItemPropertyAssetURL on a MPMediaItem returns null when the file is one that was from Apple Music and has been made "available offline". On the other hand, items from my original library which I uploaded to iTunes match/apple music and then make available offline don't seem to have this problem. Is this a bug? Have I done something wrong? Anyone having similar issues? 回答1: It seems that Apple Music files are DRM-protected and subscription based, so probably

All tableView Cells Show Same Artwork Image for Playlists

送分小仙女□ 提交于 2019-12-12 06:59:00
问题 I have a tableView which shows a list of playlists from the user's music library. The code I used to get this list is: @implementation playlistsViewController { NSArray *playlists; MPMediaQuery *playlistsQuery; } - (void)viewDidLoad { self.title = @"Playlists"; playlistsQuery = [MPMediaQuery playlistsQuery]; playlists = [playlistsQuery collections]; } #pragma mark - Table view data source - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return

iPod Library path to NSData

喜欢而已 提交于 2019-12-12 02:53:20
问题 How to convert the iPod library to NSData. The url is: ipod-library://item/item.mp3?id=1258203422631791096 Getting error but, I can play the song by using AVPlayer. NSURL *url = [curItem valueForProperty: MPMediaItemPropertyAssetURL]; NSError *error = nil; NSData *data = [NSData dataWithContentsOfFile:[url absoluteString] options:NSDataReadingMappedAlways error:&error]; NSLog(@"Error : %@",error); The curItem is a MPMediaItem Error Domain=NSCocoaErrorDomain Code=260 "The file “item.mp3?id

Set MPNowPlayingInfoCenter duration from AVPlayer?

萝らか妹 提交于 2019-12-11 11:57:47
问题 I am trying to set MPNowPlayingInfoCenter, most of the key-value pairs work fine, but there is some kind of issue with playback time let mpic = MPNowPlayingInfoCenter.defaultCenter() mpic.nowPlayingInfo = [ MPMediaItemPropertyArtwork:albumArtWork, MPMediaItemPropertyTitle:titleString, MPMediaItemPropertyArtist:artistName, MPMediaItemPropertyPlaybackDuration:99, MPNowPlayingInfoPropertyElapsedPlaybackTime:String(stringInterpolationSegment:self.myPlayer.currentItem?.currentTime()),

Getting podcast metadata from from iPodLibrary

…衆ロ難τιáo~ 提交于 2019-12-11 07:54:26
问题 Bellow is code for fetching items in the iPod library of the iOS device, the problem I am having is to do with getting the right MPMediaItemProperty . The way I understand it if I want to get data like artwork, comments title - I gotta take one media item of the MPMediaItemCollection class in my - (MPMediaItem *)mediaItemForRow: (NSInteger)row method. The problem with this is that I do not get the same info as Apple have - cause I´v checked in their podcast app. They must use some other way

how to resolve when MPMediaItem assetURL is nil?

拈花ヽ惹草 提交于 2019-12-10 13:45:17
问题 I'm working on code that looks at the user's videos and passes them along to AVPlayer by way of an AVPlayerItem which takes a URL. To get all the videos on an iOS device, you can do: let videoNumber = MPMediaType.anyVideo.rawValue let predicate = MPMediaPropertyPredicate.init(value: videoNumber, forProperty: MPMediaItemPropertyMediaType) let query = MPMediaQuery.init() query.addFilterPredicate(predicate) if let items = query.items { mediaCollection = MPMediaItemCollection(items: items) // -1

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

泄露秘密 提交于 2019-12-06 02:58:41
问题 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

Objective C: Getting MPMediaItem 'Favorite' property

♀尐吖头ヾ 提交于 2019-12-05 05:47:35
问题 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

Getting NSData out of music file in iPhone

夙愿已清 提交于 2019-12-05 05:16:36
问题 I have retrieved all musics and videos from my iPhone device. I am now stuck in saving those in to my application, i am unable to get the raw data out of the file. Can any one help me to find a solution for this. this is the code i used to get the music files. MPMediaQuery *deviceiPod = [[MPMediaQuery alloc] init]; NSArray *itemsFromGenericQuery = [deviceiPod items]; for (MPMediaItem *media in itemsFromGenericQuery){ //i get the media item here. } How to convert it to NSData ?? This is what i

Obtaining iTunes ID to an iPod player item

爷,独闯天下 提交于 2019-12-04 09:00:39
问题 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