mpmediaitemcollection

Persist a MPMediaItemCollection Object Using NSUserDefaults

自闭症网瘾萝莉.ら 提交于 2019-12-18 13:37:12
问题 How do you persist a MPMediaItemCollection object using NSUserDefaults? The MPMediaItemCollection object is a single song selected from the iPod. I have been struggling with this for hours! Anyone have any ideas or alternatives to NSUserDefaults or a conversion from MPMediaItemCollection, or anything?! Thanks... 回答1: First convert/encode the MPMediaItemCollection to an NSData Object and store it using NSUserDefaults using: NSData *data = [NSKeyedArchiver archivedDataWithRootObject

Brief stop/start of Now Playing item when updating a media collection queue MPMediaItemCollection

╄→гoц情女王★ 提交于 2019-12-10 20:04:45
问题 Im playing about with apples addMusic sample app in xcode, as im looking to be able to add similar functionality (playing a queue of music selected by the user in the background of the app). It does this annoying thing where the music player briefly stops before playing again when the user hits the 'Done' button after picking their song selections in the built in MediaPicker. - I'm assuming this is because of the method apple used, which applies a new array as the queue, and resets the now

Play Song at specific index of MPMediaItemCollection in Swift

我的未来我决定 提交于 2019-12-10 15:49:11
问题 I try to make my own Musicplayer with Swift. I need to jump to a specific song/index of my MPMediaItemCollection and start to play it but i can only find methods like skipToNextItem() and skipToPreviousItem(). Is there any other way to do that than with a loop? let player = MPMusicPlayerController.systemMusicPlayer() player.setQueueWithItemCollection(mediaCollection) player.play() 回答1: According to the documentation, we use the nowPlayingItem property. To specify that playback should begin at

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 pull the artist value from MPMediaItemCollection

喜欢而已 提交于 2019-12-08 12:38:57
问题 Why does the following result in a tableview full of "Artist" instead of a tableview full of actual artist names? Where did I go wrong? How do I pull the artist value from a collection? All help is appreciated... var tableData = MPMediaQuery.artistsQuery() override func viewDidLoad() { super.viewDidLoad() self.artistTableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") tableData.groupingType = MPMediaGrouping.Artist } func numberOfSectionsInTableView(tableView:

Place mediaItemCollection data in UITableView

梦想的初衷 提交于 2019-12-07 22:36:45
问题 I need some help placing the mediaItemCollection data in a UITableView . Code: // Responds to the user tapping Done after choosing music. - (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection { [self dismissModalViewControllerAnimated: YES]; [musicPlayer stop]; [[MPMusicPlayerController iPodMusicPlayer] stop]; [[MPMusicPlayerController iPodMusicPlayer] setQueueWithItemCollection:mediaItemCollection]; [

Place mediaItemCollection data in UITableView

天大地大妈咪最大 提交于 2019-12-06 16:05:19
I need some help placing the mediaItemCollection data in a UITableView . Code: // Responds to the user tapping Done after choosing music. - (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection { [self dismissModalViewControllerAnimated: YES]; [musicPlayer stop]; [[MPMusicPlayerController iPodMusicPlayer] stop]; [[MPMusicPlayerController iPodMusicPlayer] setQueueWithItemCollection:mediaItemCollection]; [[MPMusicPlayerController iPodMusicPlayer] play]; } The mediaItemCollection is what I need to place into my UITableView . I

Way to persist MPMediaItemCollection objects? (selected from iPod)

◇◆丶佛笑我妖孽 提交于 2019-12-04 12:06:26
问题 I am making an app in which the user can select a song in a settings tab and have this played in a different view on demand. I want it so that this item can be stored if the user is to shut the app and reopen it another time. I have managed to allow the user to select and store a song in with: -(IBAction)showMediaPicker:(id)sender{ MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny]; mediaPicker.delegate = self; mediaPicker

Way to persist MPMediaItemCollection objects? (selected from iPod)

走远了吗. 提交于 2019-12-03 07:44:39
I am making an app in which the user can select a song in a settings tab and have this played in a different view on demand. I want it so that this item can be stored if the user is to shut the app and reopen it another time. I have managed to allow the user to select and store a song in with: -(IBAction)showMediaPicker:(id)sender{ MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny]; mediaPicker.delegate = self; mediaPicker.allowsPickingMultipleItems = NO; mediaPicker.prompt = @"Select Alarm Sound"; [self presentModalViewController

How Do You Obtain the “Purchase Date” or “Date Added” from MPMediaItems in iPod Library

戏子无情 提交于 2019-11-29 15:18:36
As users download new songs into their iPod Music library from the iTunes Store, I would like to programmatically list those songs in a table view. Is it possible to obtain the "Date Added" or "Purchase Date" from the MPMediaItemCollection? I see there are property keys such as play count and last played date. I know the data exists because it can be viewed in iTunes, but I am not finding it. Any suggestions on where to find this or how to derive it? As you can see in Apple Documentation for MPMediaItem http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMediaItem