3

I have a simple example program with AVAudioPlayer and am getting this message when I run it. This occurs before .play() is called:

2019-10-08 12:34:53.093726+1100 PlayNotes2[1587:137643] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000c580e0> F8BB1C28-BAE8-11D6-9C31-00039315CD46

The program works fine, but I'm concerned to be getting this message.

Here is my complete code. It just has one button on the view with the playButtonTap outlet. Note that the same thing happens if I use the commented out declaration for var audioPlayer.

import UIKit
import AVFoundation

class ViewController: UIViewController {

    let soundFileName = "E_64kb"

    //  var audioPlayer = AVAudioPlayer()
    var audioPlayer: AVAudioPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()

        let sound = Bundle.main.path(forResource: soundFileName, ofType: "mp3")
        do {
             audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound!))
        } catch {
            print(error)
        }
    }

    @IBAction func playButtonTap(_ sender: Any) {
        audioPlayer!.play()
    } 
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ian
  • 109
  • 2
  • 10
  • Are you running on Mac OS Catalina? I had a similar console output not long ago and it was suggested to me that it would go away once I was on Catalina... which I will be upgrading to tonight (even if just for the SwiftUI preview pane). – Radagast the Brown Oct 08 '19 at 02:02
  • Thanks @RadagasttheBrown - good suggestion. I actually thought it may be due to clashes with older versions of Xcode when I've updated, so I'm in the process of uninstalling and reinstalling Xcode. If that doesn't work, I'll also do an update tonight... Probably should do the update anyway! – Ian Oct 08 '19 at 02:54
  • So, I did a clean install of Xcode and still have the message. I guess it's Catalina next... – Ian Oct 08 '19 at 04:30
  • I am running macOS Big Sur and developing a macOS app using XCode 12.3 on an Intel based iMac. I am getting this error as well. I make a call to the prepareToPlay() method prior to playing the audio. Upon calling that method I am getting the message in the console. I have verified the URL being passed is present. The mp3 file plays without a problem as desired, but this message appears the first time this method is called. Queueing and playing subsequent mp3 files does not generate this message. It's not crashing my app either. Anyone having any luck getting rid of the message? – SouthernYankee65 Jan 22 '21 at 16:25

4 Answers4

5

The warning is unimportant. If you really object to it, run the app on a device instead of in a simulator. The console message will go away.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • 4
    Just to add to this - as @matt says, the warning isn't there for actual devices. – Ian Oct 13 '19 at 02:45
1

I'm on xcode 12 macos-bigsur.

I have just got this message while im working on a MacOS app. It is definetly about AVFoundation framework. Because i have just managed to play a tiny .wav file with AudioToolbox without that warning:

Here is that code:

import Cocoa
import AudioToolbox


class ViewController: NSViewController
{   
    override func viewDidLoad()
    {
        super.viewDidLoad()
    }
    
    override func viewWillAppear()
    {
        let path = Bundle.main.path(forResource: "wr", ofType: "wav")!
        let url = URL(fileURLWithPath: path)
        var soundID : SystemSoundID = 4543523
        let cfURL = CFURLCreateWithString(kCFAllocatorDefault, url.absoluteString as CFString, nil)
        AudioServicesCreateSystemSoundID(cfURL!, &soundID)
        AudioServicesPlaySystemSound(soundID)
    }

}

This code creates a system sound from wr.wav file and plays that sound without any warning. I think this proves that this warning will go away once apple updates xcode or bigsur. So i will ignore that warning and continue using AVAudioPlayer

!!IMPORTANT do not use this code for production. It is low level C code, i don't know if it's leaking and it's also very limiting. Here read this documentation:

Sound files that you play using this function must be: No longer than 30 seconds in duration. In linear PCM or IMA4 (IMA/ADPCM) format. Packaged in a .caf, .aif, or .wav file.

In addition, when you use the AudioServicesPlaySystemSound function: Sounds play at the current system audio volume, with no programmatic volume control available. Sounds play immediately. Looping and stereo positioning are unavailable. Simultaneous playback is unavailable: You can play only one sound at a time. The sound is played locally on the device speakers; it does not use audio routing.

EFE
  • 3,732
  • 4
  • 22
  • 30
0

I got the same error and found that the sound file path was nil.

-2

You can try something like this:

import UIKit
import AVFoundation
class abdicateDef: UIViewController {

    var playabdicatesound = URL(fileURLWithPath: Bundle.main.path(forResource: "abdicatesound", ofType: "wav")!)

    var playerabdicatesound = AVAudioPlayer()

    @IBOutlet weak var popupDef: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()

        popupDef.layer.cornerRadius = 10
        popupDef.layer.masksToBounds = true

        //Getting error on this line of code Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)
        playerabdicatesound = try! AVAudioPlayer(contentsOf: playabdicatesound, fileTypeHint: nil)

    }
    @IBAction func backButton(_ sender: Any) {
        dismiss(animated: true, completion: nil)

    }
    @IBAction func soundButton(_ sender: Any) {
        playerabdicatesound.play()
    }

}
Dino
  • 7,779
  • 12
  • 46
  • 85