Media Player

RSS for tag

Find and play songs, audio podcasts, audio books, and more from within your app using Media Player.

Media Player Documentation

Posts under Media Player tag

68 Posts
Sort by:
Post not yet marked as solved
0 Replies
281 Views
I am able to play AES encrypted content in online mode and download it . But the downloaded content does not play in offline mode. Steps: Get encrypted content url call backend api to get token to decrypt the url play the content . works download content. works off the internet and try to play . Fails to play.
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.9k Views
I'm getting a variety of errors when I call prepareToPlay on the MPMusicPlayerController. Sometimes they happen, sometimes they don't. I'm trying to play songs from the Apple Music service. When I don't get the errors, it plays just fine. I have iOS v13.5.1 on my iPhone Xs and I'm using Xcode 11.5. This is my code: let applicationMusicPlayer = MPMusicPlayerController.applicationMusicPlayer applicationMusicPlayer.setQueue(with: [trackID]) applicationMusicPlayer.prepareToPlay(completionHandler:{ error in if let error = error { print(error.localizedDescription) return } DispatchQueue.main.async{ applicationMusicPlayer.play() } } These are the various errors I'm getting: [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=2 "Queue was interrupted by another queue" UserInfo={NSDebugDescription=Queue was interrupted by another queue} [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=9 "Preparing queue timed out" UserInfo={NSDebugDescription=Preparing queue timed out} [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=6 "Failed to prepare to play" UserInfo={NSDebugDescription=Failed to prepare to play} [SDKPlayback] applicationQueuePlayer _establishConnectionIfNeeded timeout [ping did not pong]
Posted
by AppWriter.
Last updated
.
Post not yet marked as solved
1 Replies
495 Views
I'm using AVPlayerView to display a video whose title I want to override in the system-wide NowPlaying view (e.g. on Big Sur in the Notification Center). On iOS / tvOS / Catalyst, this can (supposedly) be done by setting the AVPlayerItem's externalMetadata as desired, but this property is unsupported on macOS. What's the supported way of doing this for a "normal" AppKit app? My simple attempt of manually setting the information via MPNowPlayingInfoCenter didn't work; I assume that's getting overwritten by the "automatic" support from AVPlayer(View) with the faulty (empty) title from the actual video. Any pointers?
Posted
by maven.
Last updated
.
Post not yet marked as solved
0 Replies
197 Views
When the player's rate is being set to a different value than 1.0 I am experiencing after a few seconds issues with handling different remote commands. In my case when I change the rate e.g. to 3.0 after a little time only remoteCenter.playCommand's handle is triggered. Even when the player still plays. The handlers return .success after the block content is successfully executed. All relevant commands are enabled (command.isEnabled). The properties of MPRemoteCommandCenter are pretty simple so there is a little space to adjust it. I have tried to toggle the isEnabled value on different commands. Explicitly called unregisterForRemoteNotifications, registerForRemoteNotifications on UIApplication Tested the case only with the playCommand, and pauseCommand. Used the older API with selectors Nothing of this has helped. let remoteCenter = MPRemoteCommandCenter.shared() remoteCenter.playCommand.addTarget { [weak self] _ in ...
Posted Last updated
.
Post not yet marked as solved
1 Replies
434 Views
The function enumerateValues on MPMediaEntity is crashing internally when a data item is missing. It appears to be accessing a 0 address inside swift_getObjectType. Anybody else seen this?
Posted Last updated
.
Post not yet marked as solved
7 Replies
1.3k Views
I have an application that as part of it's functionality, reproduce music from the music library using the AVPlayerItem. it's working fine on iOS but on the Macbook with M1 processor the audio is not loading. Plist already contains the items: NSAppleMusicUsageDescription & NSAppTransportSecurity
Posted Last updated
.
Post not yet marked as solved
0 Replies
147 Views
When I try to play music through my built in speakers it automatically goes through my TV, I don't want it to so I tried going through Sounds and changing the settings but I can't stop it doing it, any ideas please?
Posted
by RichC.
Last updated
.
Post not yet marked as solved
0 Replies
297 Views
Hello everyone I'm seeing weird crash on bugsnag. Its about player on tvOS and it happens when I'm exiting player. And its 2 system classes. Can someone help me understand what's going on here Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x2831d5480 "AVFocusProxyView:0x1224b3370.left"> and <NSLayoutXAxisAnchor:0x28356cf40 "AVPlayerLayerView:0x1224bf9b0.left"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.
Posted
by azhukov.
Last updated
.
Post not yet marked as solved
6 Replies
1.4k Views
I’m converting a MusicKit app from iOS to macOS with Catalyst but can’t get the player to work. The app works flawlessly on iOS but I get the following error in my console on macOS whenever the MPMusicPlayer tries to manipulate the queue by adding a song with a store id [SDKPlayback] Failed to obtain remoteObject: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.Music.MPMusicPlayerApplicationControllerInternal was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.Music.MPMusicPlayerApplicationControllerInternal was invalidated.} Both the player, setQueue and play methods are according to the documentation supported on Mac Catalyst 13+: https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller/1624253-setqueue https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller/2582424-preparetoplay https://developer.apple.com/documentation/mediaplayer/mpmediaplayback/1616255-play
Posted
by zltn.
Last updated
.
Post not yet marked as solved
1 Replies
336 Views
Is there a way to get the current queue items from an MPMusicPlayerController? I need to know when the items I've set to the queue finish playing completely but cannot find any way to do this. I am not using MusicKit but setting the queue via play parameters. From what I can tell so far, after the queue finishes playing, it pauses and resets to the first item in the queue. So even after playback is done, there is no way to know that it finished on its own.
Posted Last updated
.
Post not yet marked as solved
0 Replies
225 Views
Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001b7fb8204 __ulock_wait + 8 1 libdispatch.dylib 0x00000001811df344 _dlock_wait + 56 (lock.c:326) 2 libdispatch.dylib 0x00000001811df0e8 _dispatch_thread_event_wait_slow + 56 (lock.c:366) 3 libdispatch.dylib 0x00000001811edd58 DISPATCH_WAIT_FOR_QUEUE + 364 (lock.h:330) 4 libdispatch.dylib 0x00000001811ed900 _dispatch_sync_f_slow + 144 (queue.c:1762) 5 MediaToolbox 0x000000018b59f414 playerasync_CopyProperty + 516 (FigPlayer_Async.c:3014) 6 AVFCore 0x000000018a8e5488 -[AVPlayer _timeControlStatusAndWaitingReason:] + 244 (CMBaseObject.h:396) 7 AVFCore 0x000000018a8b1f9c __avplayer_fpNotificationCallback_block_invoke + 888 (AVPlayer.m:7940) 8 libdispatch.dylib 0x00000001811dcc04 _dispatch_call_block_and_release + 32 (init.c:1516) 9 libdispatch.dylib 0x00000001811de950 _dispatch_client_callout + 20 (object.m:560) 10 libdispatch.dylib 0x00000001811ecd30 _dispatch_main_queue_callback_4CF + 940 (inline_internal.h:2597) 11 CoreFoundation 0x0000000181524ce4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CFRunLoop.c:1795) 12 CoreFoundation 0x00000001814deebc __CFRunLoopRun + 2540 (CFRunLoop.c:3144) 13 CoreFoundation 0x00000001814f23c8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268) 14 GraphicsServices 0x000000019cd0338c GSEventRunModal + 164 (GSEvent.c:2200) 15 UIKitCore 0x0000000183e98060 -[UIApplication _run] + 1100 (UIApplication.m:3457) 16 UIKitCore 0x0000000183c15b8c UIApplicationMain + 2124 (UIApplication.m:5013) 17 BanBanLive 0x0000000100be3e38 main + 88 (main.m:13) 18 dyld 0x0000000103589a24 start + 520 (dyldMain.cpp:876)
Posted
by RiverJ.
Last updated
.
Post not yet marked as solved
1 Replies
400 Views
As the title asks, is it possible to support SharePlay using the applicationQueuePlayer in the Media Player framework? It seems not to be possible since there is no AVPlaybackCoordinator available like there is for AVPlayer. Is that correct? It would be nice to be able to support this in my application if possible. Thanks!
Posted Last updated
.
Post not yet marked as solved
5 Replies
486 Views
I don't know why but when I go into MusicKit part on developer part on my app on Apple's website there is no spot to configure it. I saw online a lot of articles saying that you have to configure it to use MusicKit with an app. Is this a bug or something or do I need to do something to enable it? I just don't understand I added it into my app but I can't seem to get this to work for some reason I'm not sure why.
Posted
by ellj69.
Last updated
.
Post marked as solved
1 Replies
647 Views
My app uses the Media Player framework to play music and has the Audio background mode. When a user pauses the music and backgrounds the app (or if the app is already in the background when they pause), the system does not kill the app as long as it has the active AVAudioSession. This means that as long as a user doesn't start playback from another audio app, mine is available in Control Center for a quick resume. I recently implemented the UIBackgroundTask API (specifically UIApplication.shared.beginBackgroundTask/endBackgroundTask) to run a 5-20 second server communication task when the app is paused while in the background. Now, iOS kills my app at the conclusion of that task, despite it still having the active audio session. It is no longer in Control Center, and needs to be launched fresh. Is there anything I can do to prevent the system from killing my app at the conclusion of the background task? I'm starting to get complaints from users that they're having to relaunch the app after every time they pause for more than a few seconds. Thanks!
Posted Last updated
.
Post not yet marked as solved
1 Replies
557 Views
I'm parsing some data from my API and I would like to show artist and title in title section of MPMediaItemPropertyTitle and the album art. Right now I can print a string, as you can spot in the code below, but I would like to print the API data, as I'm doing it in the labels. Thank you in advance for your help. Here is my code: import UIKit import AVKit import MediaPlayer class ViewController: UIViewController, AVAudioPlayerDelegate { var player : AVPlayer! var dict = NSDictionary() @IBOutlet weak var artist: UILabel! @IBOutlet weak var songtitle: UILabel! @IBOutlet weak var artUrl: UIImageView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. overrideUserInterfaceStyle = .light setupRemoteTransportControls() requestNowPlaying() setupNowPlaying() addInterruptionsObserver() } [...] //There is parsing section [...] DispatchQueue.main.async { self.songtitle.text = radio.nowPlaying.song.title self.artist.text = radio.nowPlaying.song.artist self.playlist.text = radio.nowPlaying.playlist //albumcover art section if let artUrl = URL(string: radio.nowPlaying.song.art), artUrl != self.songArtUrl { //Loading image from `artUrl` let imageDatatask = session.dataTask(with: artUrl) { imageData, imageResponse, imageError in if let imageError = imageError { print(imageError) return } guard let imageData = imageData else { print("image_data is nil") return } DispatchQueue.main.async { self.songArtUrl = artUrl let albumArt = UIImage(data: imageData) self.artUrl.image = albumArt } } imageDatatask.resume() } [...] //here is some code with adding remote controls [...] func setupNowPlaying() { // Define Now Playing Info var nowPlayingInfo = [String : Any]() nowPlayingInfo[MPMediaItemPropertyTitle] = "Here I would like to print artist + title" nowPlayingInfo[MPMediaItemPropertyArtist] = "My name as string - nothing to change" if let image = UIImage(named: "Deault_albumart") { //Here I would like to add image from API nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { size in return image } } nowPlayingInfo[MPNowPlayingInfoPropertyIsLiveStream] = true MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo }
Posted
by pawelzet.
Last updated
.
Post not yet marked as solved
1 Replies
946 Views
I have been developing an app that uses Youtube Content which I am fetching from Youtube Data API which is publicly provided by Youtube itself. Basically, my app shows a list of Youtube Videos and playlist fetched from Youtube API in the user interface and the user can play video The app I am developing is not enabling users to "save, convert, or download" any videos directly or indirectly App Store Review Guidelines mentions two points 1 > 5.2.2 points states that "Authorization must be provided upon request" 2> 5.2.3 states that "Documentation must be provided upon request" so my question is that is there any chance of my app may face app store rejection? if yes then what can I do in order to pass the app store review process? if my app receives app store rejection then how can I get "Authorization" or "Documentation" from Youtube because as far as I read on Youtube API Documentation Youtube is not providing neither "Authorization" nor "Documentation". Youtube only lets you register your app on their console and gives you API key using which you can get data
Posted
by Dhrumil_7.
Last updated
.
Post not yet marked as solved
1 Replies
696 Views
Hello, I've implemented two functions in View controller (setupRemoteTransportControls() and setupNowPlaying()) and added one function to AppDelegate, but I'm still unable to see background audio controls of my app on the lock screen and also audio interruption function isn't working. This is the live stream from url, as you can spot on in the code. In the general settings I have added background playing: What I would like to do is to print on the Remote Command Center artist, title and albumArt, but but i was stuck just displaying the command center. I attach link my code on github, because it is too many characters to paste it: https://github.com/pawelzet/promil_new/blob/main/ViewController.swift Here is AppDelegate func that I've added:     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {         application.beginReceivingRemoteControlEvents()      //    Override point for customization after application launch.        return true     }
Posted
by pawelzet.
Last updated
.