mpmusicplayercontroller

iOS 9.3.2 Breaks MPMusicPlayerController

十年热恋 提交于 2019-12-20 10:53:58
问题 I'm trying to integrate Apple Music to my app, I managed to get it working flawlessly until this morning. After updating to iOS 9.3.2 nothing is the same: The permission system works the same (SKCloudServiceController) to retrieve the AuthorizationStatus and Capability of the user. However, the MPMusicPlayerController do not behave the same using the new iOS version, let me explain : On iOS 9.3.1, if I call the playerController.play() method after setting my tracks in playerController

Independent Volume control of AVAudioPlayer and MPMusicPlayerController in iOS App.

独自空忆成欢 提交于 2019-12-19 10:33:10
问题 Within my application, I am playing downloaded audio using an AVAudioPlayer, while simultaneously playing audio from the user's iPod music library with an MPMusicPlayerController. I need to be able to adjust the Volume of the AVAudioPlayer instance so that it's louder than the audio coming from the MPMusicPlayerController. The problem is, when I adjust the Volume property of the AVAudioPlayer, it also adjusts the volume of the MPMusicPlayerController. Is there any solution which would allow

How can I fade-out the sound played by MPMusicPlayerController?

人盡茶涼 提交于 2019-12-19 10:28:18
问题 I'd like to fade-out the sound played by MPMusicPlayerController over a particular time period? How can I do this? 回答1: There is no fade functionality so you have to implement it yourself. Loop until volume is 0, and add a delay for each step. If you want all this to happen 2 seconds into the future, put the code on a block: MPMusicPlayerController *iPod = [MPMusicPlayerController iPodMusicPlayer]; int64_t delay = 2LL * NSEC_PER_SEC; dispatch_after(dispatch_time(DISPATCH_TIME_NOW,delay),

How do I make my app work with the media control buttons on lock screen?

别说谁变了你拦得住时间么 提交于 2019-12-18 13:23:26
问题 In recent iOS versions apps have some kind of access to the media control buttons on the lock screen, like the Play/Pause button: It looks like the buttons are supposed to work with the MPMusicPlayerController class, is that right? Is there a way to get the “raw” events from the buttons? Because the music player only seems to offer an API to supply a bunch of MPMediaItem s. What if my app is for example a radio that needs to handle the buttons differently? 回答1: After a bit more searching I

iOS: Displaying currently played track info in LockScreen?

若如初见. 提交于 2019-12-18 04:19:10
问题 As of iOS 5 we have access to MPNowPlayingInfoCenter to display info in the lockscreen and in the multimedia controls on the multitasking bar. I have an app that plays local audio files. I want to display info like the artist's name, the album and the artwork on the lockscreen with MPNowPlayingInfoCenter , but the only way to do this (As far as I know) is to use MPMusicPlayerController and get nowPlayingItem ... The problem is that MPMusicPlayerController is used to play iPod Music only, and

iOS: Displaying currently played track info in LockScreen?

你说的曾经没有我的故事 提交于 2019-12-18 04:19:09
问题 As of iOS 5 we have access to MPNowPlayingInfoCenter to display info in the lockscreen and in the multimedia controls on the multitasking bar. I have an app that plays local audio files. I want to display info like the artist's name, the album and the artwork on the lockscreen with MPNowPlayingInfoCenter , but the only way to do this (As far as I know) is to use MPMusicPlayerController and get nowPlayingItem ... The problem is that MPMusicPlayerController is used to play iPod Music only, and

How do I get the lyrics of the currently playing song in Swift 4?

馋奶兔 提交于 2019-12-13 03:25:36
问题 I am getting the Current Song playing as an MPMediaItem and I can successfully retrieve the title, artist and song length. However when I try to get the lyrics nothing shows up in the text field that I am updating. let currentSong: MPMediaItem = mediaItemCollection.items[0] if let artwork: MPMediaItemArtwork = currentSong.value(forProperty: MPMediaItemPropertyArtwork) as? MPMediaItemArtwork { albumArtwork.image = artwork.image(at: CGSize(width: 120, height: 120)) songTitle.text = currentSong

I need to know how to get information about which player is currently streaming (player, spotify, napster…)

Deadly 提交于 2019-12-13 02:34:29
问题 I can get information (artist, album, title) of the song that is currently playing with: let t = MPMusicPlayerController().nowPlayingItem?.title It works fine when the music is streaming from the iOS Music Player. However, when the streaming is from other source (Spotify, Napster, Youtube, Tuneinradio, etc.) I can not get information. How can I get this information for any app? 回答1: Use the nowPlayingInfo dictionary on MPNowPlayingInfoCenter.defaultCenter() : let t = MPNowPlayingInfoCenter

How to set music playback slider in music player

雨燕双飞 提交于 2019-12-12 12:18:16
问题 i created a music player with previous and next functionality in my app.i want to impliment song playback slider. how to do this? 回答1: Use a UISlider setting the maxValue to the current playing song duration (in seconds) and the minValue to 0. Assuming that you're using an MPMusicPlayerController use the currentPlaybackTime to get the current time of the playing track and use that value to update the slider each second slider.value = musicPlayerController.currentPlaybackTime; slider

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