I often find when doing basic actions in MusicKit it is incredibly slow compared to Apple's Music App. I've tried different versions, devices, networks, Apple's sample code, it all throughout the last several years, and it is all the same. Does anyone else have this issue?
Explore the integration of media technologies within your app. Discuss working with audio, video, camera, and other media functionalities.
Post
Replies
Boosts
Views
Activity
I'm creating an app that uses AVCaptureSession to pass camera input to AVCaptureMetadataOutput and scan QRCode.
After updating to iPadOS 17.4, an issue has occurred where the delegate method of AVCaptureMetadataOutputObjectsDelegate is not called on some devices.
The following devices are experiencing this issue.
iPad (7th Gen)
iPad (6th Gen)
iPad Pro (10.5)
iPad Pro (12.9 2nd Gen)
This issue has not occur on any other devices I have.
This may only occur on devices with model number "iPad7,x".
I tried running the AVFoundation sample code on the Apple Developer site on the above device. The same problem still occurs.
https://developer.apple.com/documentation/avfoundation/capture_setup/avcambarcode_detecting_barcodes_and_faces
Are any additional settings required after iPadOS17.4?
Or is there some problem on the OS side?
Hi all, I am a graduate student who is looking into making MV-HEVC videos streamable. May I ask that is it possible to encode mv-hevc videos with the HLS (Http Live Streaming) protocol?
I've been trying to use the HLS tool by Apple to encode a spatial video recored by VP.
mediafilesegmenter -iso-fragmented -t 4 -f sp_video-1-vp spatial-video-by-vp.MOV
But the output HLS playlist file doesn't look like the format that Apple proposes in the WWDC video. For example, the attribute EXT-X-VERSION is 7 instead of 12, and no attr REQ-VIDEO-LAYOUT=CH-STEREO which should be the key indicator of the spatial video type.
From what the WWDC video showcased, I assume Apple's HLS tool supports it. Maybe my usage is not correct. Just curious what you guys think about it, thank you!
The methods described in https://developer.apple.com/forums/thread/715452?answerId=729571022#729571022 to obtain 48 MP image captures no longer seem to work on iOS 17.4 under certain circumstances.
Previously, the following steps were sufficient to get 48 MP capture from AVFoundation:
Configuration
Set the active AVCaptureDevice.Format to a format where supportedMaxPhotoDimensions contains the (8064, 6048) size
Set AVCapturePhotoOutput.maxPhotoDimensions to (8064, 6048)
Set AVCapturePhotoOutput.maxPhotoQualityPrioritization to .quality
Taking a photo
Set AVCapturePhotoSettings.maxPhotoDimensions to (8064, 6048)
Set AVCapturePhotoSettings.photoQualityPrioritization to .quality
As of iOS 17.4, the exact same code that worked through 17.3 no longer works if the session was configured manually (resulting in the .inputPriority session preset) rather than using a session preset (like .high). When configuring the session manually, all the intervening steps work (an active format can be found with the appropriate dimensions, the photo output settings can be set to 8064x6048 successfully, etc.), but the resulting photo is 4032x3024. Again, these same steps worked flawlessly prior to iOS 17.4.
Am I missing something? Did iOS 17.4 change the requirements for 48 MP capture, or is this a bug?
Hi everyone! Are there any plans or existing alternatives to include the date a track was added to a playlist within Apple Music's API[1]? This functionality exists on Spotify[2] (with their "added_at" attribute), and it would be helpful for ordering tracks retrieved from playlists. Thank in advance for any help!
[1]https://developer.apple.com/documentation/applemusicapi/get_a_catalog_playlist_s_relationship_directly_by_name
[2]https://developer.spotify.com/documentation/web-api/reference/get-playlists-tracks
Background
When I receive the InterruptionBegan notification (the interruption type is AVAudioSessionInterruptionTypeBegan) , I pause playing music.
When I receive the InterruptionEnded notification (the interruption type is AVAudioSessionInterruptionTypeEnded), I resume playing music.
however, sometimes i has got the error code: AVAudioSessionErrorCodeCannotInterruptOthers (560557684)
Some Solutions
I searched stackoverflow, there's some similar questions, and some solutions here are not very satisfying as :
I don't want my app to mix with others, and once again, it all works most of the time.
My app already uses remote control events so this doesn't solve anything.
Questions
1.Have someone ever encountered this problem ?
2.Can we solve this problem and how ?
3.In addition, I noticed that there's property named otherAudioPlaying in AVAudioSession, we can know there's another app is playing,the quetion is if we can know which app is playing ?
Some of installers which we have suddenly become broken for users running the latest version of OS X, I found that the reason was that we install Core Audio HAL driver and because I wanted to avoid system reboot I relaunched coreaudio daemon via from a pkg post-install script.
sudo launchctl kickstart -kp system/com.apple.audio.coreaudiod
So with the OS update the command fails, if a computer has SIP enabled (what is the default).
sudo launchctl kickstart -kp system/com.apple.audio.coreaudiod
Password:
Could not kickstart service "com.apple.audio.coreaudiod": 1: Operation not permitted
It would be super nice if either the change can be:
reverted OR
I and similar people to know a workaround of how to hot-plug (and unplug) such a HAL driver.
The CoreAudio framework has a process class property kAudioProcessPropertyDevices, which is used to obtain an array of AudioObjectIDs that represent the devices currently used by the process for output.
But this property behaves incorrectly. Specifically, if a process switches from one microphone to another while streaming, this property returns the output device ID as the input device ID.
Steps to reproduce:
run FaceTime
select "MacBook Pro Microphone" as an input device from the FaceTime menu
select "MacBook Pro Speaker" as an output device from the FaceTime menu
start a call
get kAudioProcessPropertyDevices for Input scope: returns ID1 - "MacBook Pro Microphone" [CORRECT]
get kAudioProcessPropertyDevices for Output scope: returns ID2 - "MacBook Pro Speaker" [CORRECT]
change the input device in the FaceTime menu to any other microphone ("AirPods Pro" - ID3)
get kAudioProcessPropertyDevices for Input scope: returns ID2 "MacBook Pro Speaker" but should be ID3 "AirPods Pro" [INCORRECT]
get "kAudioProcessPropertyDevices" for Output scope: returns ID2 "MacBook Pro Speaker" [CORRECT]
Monitoring the property change for kAudioProcessPropertyDevices could provide a means to track audio streaming processes, but its current flaw renders it unusable.
So I'm curious if the macOS developers plan to address this issue in future releases, or if anyone can come up with a reliable alternative for identifying processes and associated audio devices being used for playback or recording.
Under Sonoma 14.4 the compression option doesn't work with PNG images. It works for JPG/HEIF. Preview can export PNG file to HEIC with compression option. What am I missing? Previously this has worked. I am trying with 0.01 and 0.9 as compression quality and the file size is the same for PNG.
Is Preview using some trick to convert the image using ciContext.createCGImage?
PS: Compression option of 1.0 was broken under 14.4 RC and Preview created empty file.
func heifImageDataUsingDestination(at url: URL, compressionQuality : CGFloat) -> Data? {
guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else { return nil }
guard let cgImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) else { return nil }
var mutableData = NSMutableData()
guard let imageDestination = CGImageDestinationCreateWithData(mutableData, "public.heic" as CFString, 1, nil) else { return nil }
let options = [ kCGImageDestinationLossyCompressionQuality: compressionQuality ] as CFDictionary
CGImageDestinationAddImage(imageDestination, cgImage, options)
let success = CGImageDestinationFinalize(imageDestination)
if success {
return mutableData as Data
}
return nil
}
func heifImageDataUsingCIContext(at url: URL, compressionQuality : CGFloat) -> Data? {
guard let ciImage = CIImage(contentsOf: url) else { return nil }
let context = CIContext()
let colorspace = ciImage.colorSpace ?? CGColorSpaceCreateDeviceRGB()
let options = [CIImageRepresentationOption(rawValue: kCGImageDestinationLossyCompressionQuality as String) : compressionQuality]
return context.heifRepresentation(of: ciImage, format: .RGBA8, colorSpace: colorspace, options: options)
}
I want to take 48MP photos and get the same iso and exposure duration as I set.
Configuration
Set the active AVCaptureDevice.Format to a format where supportedMaxPhotoDimensions contains the (8064, 6048) size
Set AVCapturePhotoOutput.maxPhotoDimensions to (8064, 6048)
Set if (AVCaptureDevice.isExposureModeSupported:.custom) { AVCaptureDevice.exposureMode = .custom; }
Set AVCaptureDevice.setExposureModeCustomWithDuration:1/20 ISO:100 completionHandler:handler
Taking a photo
Set AVCapturePhotoSettings.maxPhotoDimensions to (8064, 6048)
The API discussion of setExposureModeCustomWithDuration told me
https://developer.apple.com/documentation/avfoundation/avcapturedevice/1624646-setexposuremodecustomwithduratio/
To ensure that the receiver's ISO and exposureDuration values are honored while in AVCaptureExposureModeCustom or AVCaptureExposureModeLocked, you must set your AVCapturePhotoSettings.photoQualityPrioritization property to AVCapturePhotoQualityPrioritizationSpeed.
But at last step, when I set
AVCapturePhotoSettings.maxPhotoQualityPrioritization = .speed,
the photo resolution is (4000, 3000), only 12MP, not is (8000, 6000). the iso and exposure duration on the photo are the same as what I set.
and when I set
AVCapturePhotoSettings.maxPhotoQualityPrioritization = .balanced/.qulity, the photo is (8000, 6000) , but the iso and exposeure duration obtained on the photo is different from the one I set.
What do I need to do to take 48MP photos and set the iso and exposure duration successfully?
Hi,
Could you please explain how to use SF Symbols animations in Final Cut? I would greatly appreciate your help.
Thank you!
How to programmatically open the camera the spatial mode in iOS for capturing the spatial videos. Any API for opening camera in spatial mode?
Hi
Hopefully a simple question. I just reached for AudioObjectShow() to help debug stuff and it does not appear to work on audio devices or audio streams. It prints nothing for them. It does work on AudiokAudioObjectSystemObject, I've not explored what else it does or does not work on. I could not find any other posts about this, it it expected to work? On all audio objects? I'm on macOS 14.4.
Here is a simple demo. AudioObjectShow() prints out info for the System AudiokAudioObjectSystemObject but then prints nothing as we loop through the audio devices in the system (and same for all streams on all these devices, but I'm not showing that here).
#include <CoreAudio/AudioHardware.h>
static const AudioObjectPropertyAddress devicesAddress = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain
};
static const AudioObjectPropertyAddress nameAddress = {
kAudioObjectPropertyName,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMain
};
int main(int argc, const char *argv[]) {
UInt32 size;
AudioObjectID *audioDevices;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &devicesAddress, 0, NULL, &size);
audioDevices = (AudioObjectID *) malloc(size);
AudioObjectGetPropertyData(kAudioObjectSystemObject, &devicesAddress, 0, NULL, &size, audioDevices);
UInt32 nDevices = size / sizeof(AudioObjectID);
printf("--- AudioObjectShow(kAudioObjectSystemObject):\n");
AudioObjectShow(kAudioObjectSystemObject);
for (int i=0; i < nDevices; i++) {
printf("-------------------------------------------------\n");
printf("audioDevices[%d] = 0x%x\n", i, audioDevices[i]);
AudioObjectGetPropertyDataSize(audioDevices[i], &nameAddress, 0, NULL, &size);
CFStringRef cfString = malloc(size);
AudioObjectGetPropertyData(audioDevices[i], &nameAddress, 0, NULL, &size, &cfString);
CFShow(cfString);
//AudioObjectShow() give us anything?
printf("--- AudioObjectShow(audioDevices[%d]=0x%x):\n", i, audioDevices[i]);
AudioObjectShow(audioDevices[i]);
printf("---\n");
}
}
Start of output...
AudioObjectID: 0x1
Class: Audio System Object
Name: The Audio System Object
-------------------------------------------------
audioDevices[0] = 0xd2
Darryl\u2019s iPhone Microphone
--- AudioObjectShow(audioDevices[0]=0xd2):
---
-------------------------------------------------
audioDevices[1] = 0x41
LG UltraFine Display Audio
--- AudioObjectShow(audioDevices[1]=0x41):
---
-------------------------------------------------
audioDevices[2] = 0x3b
LG UltraFine Display Audio
--- AudioObjectShow(audioDevices[2]=0x3b):
---
-------------------------------------------------
audioDevices[3] = 0x5d
BlackHole 16ch
--- AudioObjectShow(audioDevices[3]=0x5d):
---
-------------------------------------------------
As a straightforward example, I've taken Apple's MV-HEVC sample project and added two lines.
First, after the AVAssetWriterInput is created:
frameInput.performsMultiPassEncodingIfSupported = true
Second, after the call to multiviewWriter.startWriting():
print("canPerformMultiplePasses: \(frameInput.canPerformMultiplePasses)")
Which prints true.
This leads me to believe that the first encoding pass should proceed as-normal (even though I haven't handled the logic for the completion of the first pass, etc.).
However, I receive this error when the code attempts to appendTaggedBuffers to the AVAssetWriterInputTaggedPixelBufferGroupAdaptor:
Fatal error: Failed to append tagged buffers to multiview output
Am I missing a step? Or is the multi-pass encoding only supported for standard sample/pixel buffers (and not tagged buffers)?
I want to give the user the option for my text-to-speech app to use a voice that they choose - but when I call "AVSpeechSynthesisVoice.speechVoices()", I get a list of all possible voices.
Each voice has properties like .gender, .quality and voiceTraits which provides isNoveltyVoice and .isPersonalVoice - but I can't seem to find a property that tells me whether the voice has been downloaded (and can be used) or not.
How can I tell which voices the user has downloaded so I can present a list of what is currently available to use?
Also - I know I can't download voices for the user - but am I able to use a deep link to pop open the correct place for the user to download the voices? (ie Settings->Accessibility->Spoken Content->Voices->English)
Thanks in advance!
I'm working on an application that aims to deliver a DJ-like experience by overlapping songs and implementing volume fading. During development, I've encountered a roadblock due to the MusicPlayerController singleton behavior in iOS, which seems to only support playback of one audio stream at a time and doesn't support overlapping of songs or fading volume between tracks.
I understand that Apple Music content is protected and that playback through Apple MusicKit must respect the DRM and licensing agreements. However, I've noticed an application called "Mixonset" that seems to be able to stream songs from Apple Music, use the music player, and create an overlapping effect of songs for users.
Could anyone share insights on how Mixonset might be achieving this within the constraints of the Apple MusicKit? Is there any approach that I could explore to implement similar functionality, such as overlapping songs or crossfading while adhering to Apple's guidelines and without violating any terms of service?
Any advice or direction towards documentation and API capabilities that could support these features would be greatly appreciated.
Thank you for your assistance.
Hello everyone, my name is Joshua Osagie. For 2 months now, I have been trying to build my own music application, but unfortunately, I can’t because I was thinking I would get an API from maybe Apple Music or Spotify that will grant me access to over 100 million music. Even if the API is paid for, I have been doing my research, but then it's kind of impossible. So please, if anyone has an idea on what I can do to bring this application to life, I will really appreciate it. Or if anyone could share me an idea on how to get over millions of music on my app, I will be really grateful.
I'm trying to use AVPlayer to capture frames from a livestream that is remotely playing. Eventually I want to convert these frames to UIImages to be displayed. The code I have right now is not working because pixel_buffer doesn't have an actual value for some reason. When I print itemTime its value is continuously 0, which I think might be a potential cause of this issue. Would appreciate any help with getting this to work.
import RealityKit
import RealityKitContent
import AVFoundation
import AVKit
class ViewController: UIViewController {
let player = AVPlayer(url: URL(string: {webrtc stream link})!)
let videoOutput = AVPlayerItemVideoOutput(pixelBufferAttributes: [String(kCVPixelBufferPixelFormatTypeKey): NSNumber(value: kCVPixelFormatType_32BGRA)])
override func viewDidLoad() {
print("doing viewDidLoad")
super.viewDidLoad()
player.currentItem!.add(videoOutput)
player.play()
let displayLink = CADisplayLink(target: self, selector: #selector(displayLinkDidRefresh(link:)))
displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
}
@objc func displayLinkDidRefresh(link: CADisplayLink) {
let itemTime = videoOutput.itemTime(forHostTime: CACurrentMediaTime())
if videoOutput.hasNewPixelBuffer(forItemTime: itemTime) {
if let pixelBuffer = videoOutput.copyPixelBuffer(forItemTime: itemTime, itemTimeForDisplay: nil) {
print("pixelBuffer \(pixelBuffer)") // yay, pixel buffer
let image = CIImage(cvImageBuffer: pixelBuffer) // or maybe CIImage?
print("CIImage \(image)")
}
}
}
}
struct ImmersiveView: View {
var body: some View {
RealityView { content in
if let scene = try? await Entity(named:"Immersive", in: realityKitContentBundle) {
content.add(scene)
}
let viewcontroller = ViewController()
viewcontroller.viewDidLoad()
}
Hi Apple developers,
Is it possible to display lyrics synchronized with a song in my app after the song has been identified?
Just like the feature available in the general Shazam app when clicking on the middle-top icon (with music note in it) after Shazam'ing a song.
The app I'm developing is intended for the Deaf and hard-of-hearing and therefore I would love to be able to show the song lyrics to make the app accessible.
I would greatly appreciate your help because I can't find this in the documentation. Many thanks in advance!
After thoroughly scouring the internet numerous times, I came to the realization that Apple has not documented their User Authentication flow. Instead, developers are often directed to use their JavaScript solution, which proves to be insufficient and impractical for many projects.
Could we please request a comprehensive documentation outlining the process of generating a Music User Token from the Developer Token? This would greatly benefit developers seeking to integrate Apple Music functionality into their projects.