Questions tagged [mpmusicplayercontroller]

Use an MPMusicPlayerController object, or music player, to play media items from the device iPod library.

Use an object, or music player, to play media items from the device iPod library. There are two types of music player:

  • The application music player plays music locally within your app. It is not aware of the iPod app’s now-playing item, nor does it affect the iPod state.

  • The iPod music player employs the built-in iPod app on your behalf. On instantiation, it takes on the current iPod app state, such as the identification of the now-playing item. If a user switches away from your app while music is playing, that music continues to play. The iPod app then has your music player’s most recently-set repeat mode, shuffle mode, playback state, and now-playing item.

External Resources

374 questions
42
votes
8 answers

iOS 7: MPMusicPlayerController volume deprecated. How to change device volume now?

MPMusicPlayerController setVolume is deprecated since iOS 7 Is there any other way to change system music volume? Preferably without user interaction. Its important feature: to increase volume automatically for any alarm clock from AppStore.
Maxim Kholyavkin
  • 4,463
  • 2
  • 37
  • 82
27
votes
5 answers

How Do I Get Audio Controls on Lock Screen/Control Center from AVAudioPlayer in Swift

New to iOS development, so here goes. I have an app that is playing audio - I'm using AVAudioPlayer to load single files by name in the app's assets. I don't want to query the user's library, only the files provided. Works great, but, I want the…
nbpeth
  • 2,967
  • 4
  • 24
  • 34
25
votes
12 answers

iOS 9: How to change volume programmatically without showing system sound bar popup?

I have to change the volume on iPad and using this code: [[MPMusicPlayerController applicationMusicPlayer] setVolume:0]; But this changing volume and showing system volume bar on iPad. How to change the sound without showing the volume bar? I know,…
mgv
  • 347
  • 1
  • 3
  • 9
22
votes
3 answers

How to enable iPod controls in the background to control non-iPod music in iOS 4?

A good example of what I'm trying to accomplish is implemented in the latest version of the Spotify iPhone application for (Pandora seems to have the same feature) . When Spotify is in the background, double tapping opens the "multi-task dock",…
Max
  • 1,054
  • 1
  • 12
  • 20
14
votes
6 answers

applicationMusicPlayer volume notification

I am using an applicationMusicPlayer and when i try to change the volume appear the visual notification, as shown in the picture. Here the code I am using: [MPMusicPlayerController applicationMusicPlayer] setVolume:newVolune]; Anyone knows how to…
mt81
  • 3,288
  • 1
  • 26
  • 35
14
votes
2 answers

MPRemoteCommandCenter calls handler multiple times in iOS

MPRemoteCommandCenter calls the handler block multiple times and causes unnecessary calls to selector methods. Here is code snippet: MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter]; [commandCenter.nextTrackCommand…
Dhaval H. Nena
  • 3,992
  • 1
  • 37
  • 50
13
votes
5 answers

How to play the iPod Library file in the AVPlayer

How can I get an ipod library music file into AVAudioPlayer?
user237708
12
votes
2 answers

detect MPMusicPlayerController notifications in background

I have a music app written in swift, I am using MPMusicPlayerController.systemMusicPlayer, also tried applicationMusicPlayer. Music plays fine in the background as expected. When my app is in the background I need playback state change…
12
votes
2 answers

iOS AudioSessionSetActive() blocking main thread?

in my iOS app, I'm trying to implement "ducking": while my app plays a short "command-like" sound, any background music should be lowered in volume. Having finished playing the sound, the music volume should go back to its original value. As…
10
votes
1 answer

MPMusicPlayerController: iPod stops sending notifications, when iPod App is terminated in background

I am using a music player property for iPod player controller. // .h @property (nonatomic, retain) MPMusicPlayerController *ipodPlayer; // .m ipodPlayer = [MPMusicPlayerController iPodMusicPlayer]; NSNotificationCenter *notificationCenter =…
petershine
  • 3,190
  • 1
  • 25
  • 49
10
votes
4 answers

iOS - get programmatically queue of items currently playing

I want to get programmatically queue currently played in native Music App. I can use MPMusicPlayerController to get currently playing item but I want to get not only the item but whole playing queue. Is it possible to do it using AVFoundation or any…
Martin Pilch
  • 3,245
  • 3
  • 38
  • 61
9
votes
1 answer

Difference between AVAudioPlayer AVPlayer AVQueuePlayer MPMusicPlayerController MPRemoteCommandCenter MPNowPlayingInfoCenter for an iOS 13+ app

All of the threads on this topic are really old (5+ yo), and I can't seem to form a clear MODERN approach, so hopefully this can be summarized for 2020 (Swift 5, Xcode 11). If you were to build an AUDIO (not just music) player app for the iPhone…
9
votes
4 answers

How to stop MPMusicPlayerController from enabling screen locking

I have an application that requires the iPhone screen to remain active (or not, depending on user choice). I've done this by disabling the application idle timer, which works fine and dandy until I start playing media via the…
tddmonkey
  • 20,798
  • 10
  • 58
  • 67
8
votes
1 answer

Playing (non library) Apple Music content - request fails

I'm trying to play an album, using the following code… let predicate = MPMediaPropertyPredicate(value: "1459938538", forProperty: MPMediaItemPropertyAlbumPersistentID) let iCloudPredicate = MPMediaPropertyPredicate(value: true, forProperty:…
Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
8
votes
3 answers

iPod Volume Level Affects App Volume Level

I am writing an iPad app that uses the "Flite" text-to-speech engine to announce specific events. The Flite engine uses an AVAudioPlayer instance to play the speech audio once it renders. For fun, I decided to add some simple controls to my app to…
Vic320
  • 1,105
  • 2
  • 10
  • 22
1
2 3
24 25