Post not yet marked as solved
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]
Post not yet marked as solved
Is there a way to disable the default video controls (play/pause/scrubber/etc) on the new SwiftUI VideoPlayer in iOS14, so I could create a custom one?
Post not yet marked as solved
Hi!
In Becoming a Now Playable App - https://developer.apple.com/documentation/mediaplayer/becoming_a_now_playable_app project for iOS target after changing playback rate to 2.0 (or any other value greater than 1.0) some bluetooth headphones fail to pause playback (for example Motorola Pulse Escape).
The same issue manifests in other apps where playback speed change is allowed, but works well for Apple's Podcasts app.
I tried to create custom UIWindow subclass to log all events received by OS, but iOS 13 doesn't receive pause command from headset at all (when playback is active and rate > 1.0), however skip backward/previous track make app work until you change rate back to 2.
Does anyone have an idea how to make pause work in this case?
Thanks!
Post not yet marked as solved
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?
Post not yet marked as solved
AVPlayer gets the list of URLs from the m3u8 file. I need to add some query string at the end of each URL.
Is there any option in the AVPlayer to do this?
Example:
HLS URL : http://example.com/hls.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.417000,ts
#EXTINF:10.417000,ts
#EXTINF:9.470000,ts
#EXTINF:10.417000,ts
#EXTINF:9.470000,ts
#EXTINF:10.417000,ts
#EXTINF:9.470000,ts
#EXTINF:3.840611,ts
#EXT-X-ENDLIST
AVPlayer is trying to download http://example.com/1.ts
But I want the AVPlayer to add
"?st=2020-09-01T13%3A59%3A03Z&se=2020-09-02T13%3A59%3A03Z&sp=rl&sv=2018-03-28&sr=b&sig=Pua9sv8mgvPF6gNwuBSghdEq%2BefMFmwBuyUdjCetmw4%3D"
So AVPlayer will try
http://example.com/1.ts?st=2020-09-01T13%3A59%3A03Z&se=2020-09-02T13%3A59%3A03Z&sp=rl&sv=2018-03-28&sr=b&sig=Pua9sv8mgvPF6gNwuBSghdEq%2BefMFmwBuyUdjCetmw4%3D instead of http://example.com/1.ts
Post not yet marked as solved
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
Post not yet marked as solved
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?
Post not yet marked as solved
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
Post not yet marked as solved
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
Given an MPMediaItem the user selected from MPMediaPickerController or from MPMusicPlayerController.systemMusicPlayer.nowPlayingItem, is it possible to find out if this song is lossless and if it supports Spatial Audio? Thanks!
Post not yet marked as solved
When using the applicationQueuePlayer perform(queueTransaction:completionHandler:) method, it takes multiple seconds to iterate over the items of either the MPMusicPlayerControllerMutableQueue or the MPMusicPlayerControllerQueue. While the iteration happens, the app is frozen (as this is done on the main thread) and I get the following error in console:
ASYNC-WATCHDOG-1: Attempting to wake up the remote process
I am dealing with a queue of a few hundred, but I don't believe the issue is with the number of MPMediaItems as when I get a similar number of items from e.g. MPMediaPlaylist, iterations happen instantly.
Here is a simplified version of my code:
var musicPlayerController = MPMusicPlayerController.applicationQueuePlayer
self.musicPlayerController.perform { (currentQueue) in
return
} completionHandler: { (newQueue, error) in
if let e = error {
print(e)
} else {
let items = newQueue.items
print("Starting iteration")
let tracks = items.map { Track(item: $0) }
print("Ending iteration")
}
}
In the console, I'll see "Starting iteration" printed in the console straight away as the method is called. And then I'll see "Ending iteration" multiple seconds later, during which the app is frozen.
This method is called anytime the .MPMusicPlayerControllerQueueDidChange notification is posted.
Post not yet marked as solved
Hello,
I am working on a video-based app where a user uploads a video and we are showing it in a feed.
Now, everything seems to be working fine, but after the recent iOS update 14.6, the video has a crackling/popping sound when played using AVPlayer. The video is created from an Android device. Also for previous iOS versions, it is working fine.
Can somebody tell me what can be the solution for this?
Post not yet marked as solved
Is there any way of discovering the name of the device when the user started to cast to it? The only thing I found was this
let route = AVAudioSession.sharedInstance().currentRoute
for output in route.outputs where output.portType == .airPlay {
infoDict["deviceName"] = output.portName
infoDict["portType"] = output.portType.rawValue
}
but the output.portName returns the portType instead of the portName.
I want to use the ApplicationMusicPlayer in my SwiftUI App and need the song duration to build a progression bar. ApplicationMusicPlayer only provides currentPlaybackTime and the Song struct in MusicKit has no duration prop. Is there an easy way to get the song duration with MusicKit or do I have to use a separate Apple Music API request to get durationInMillis?
Post not yet marked as solved
Hi.
landscape videos work fine, but portrait videos don't.
how to enable for it?
Hello,
I'm trying out the new Apple MusicKit and I have some strange behavior. When I set de queue it is only possible to play song from user defined playlists.
Is this the right behavior?
Tracks is an
var tracks: MusicItemCollection<Track>?
ApplicationMusicPlayer.shared.queue = ApplicationMusicPlayer.Queue(for: viewModel.tracks!, startingAt: viewModel.tracks?.first!)
try await ApplicationMusicPlayer.shared.play()
I'm playing library items (MPMediaItem) and apple music tracks (Track) in MPMusicPlayerApplicationController.applicationQueuePlayer, but I can't use the actual Queue functionality because I can't figure out how to get both media types into the same queue. If there's a way to get both types in a single queue, that would solve my problem, but I've given up on that one.
Because I can't use a queue, I have to be able to detect when a song ends so that I can put the next song in the queue and play it. The only way I can figure out to detect when a song ends is by watching the playBackState, and I've actually got that pretty much working, but it's really ugly, because you get playBackState of paused when a song ends, and when a bluetooth speaker disconnects, etc.
The only answer I've been able to find on the internet is to watch the MPMusicPlayerControllerNowPlayingItemDidChange, and when that fires, and the nowPlayingItem is NIL, a song ends.. but that's not the case. When a song ends, the nowPlayingItem remains the same. There's got to be an answer to this problem, right?
Hello,
I have an app that uses the MediaPlayer framework (applicationQueuePlayer specifically) and since the introduction of iOS 14.6 and Lossless audio, some users have been reporting that sometimes they cannot play a song past 15 seconds without playback either pausing or the app making a screeching noise. As far as I knew, this was supposed to be fixed in 14.7, but users running 14.7.1 are reporting it to me whether Lossless is on or off. The problem seems to be intermittent -- there for one user one day and gone the next, though sometimes it sticks around. I am pretty much never able to reproduce it for myself.
My code to load and play the player is pretty simple and has not changed since well before this issue started cropping up. I run setQueue and set the queue with either a descriptor of storeIDs for Apple Music Items or an MPMediaItemCollection for library items, then call Play.
Is there anything I can do about this issue? Are you guys still working on this server side? I need to continue supporting users on older OSes so I am not yet able to use the new MusicKit for Swift player. I don't know if it's fixed there or not.
Thanks! (Tagging in @JoeKun)
Post not yet marked as solved
When the rss generator will start work again? https://rss.itunes.apple.com/en-us
Post not yet marked as solved
Hey,
I am trying to figure out how can I display currently playing sources of Audio on my Xcode Project.
In the new Big Sur update I believe this was possible due to the Mac Catalyst.
How can I do this on the Mac?
New to this, can someone guide please.