When I try the following I get a "OSStatus error 2003334207"

func session(_ session: WCSession, didReceive file: WCSessionFile)
    {
        DispatchQueue.main.async
        {
            self.versionLabel.text = "We got a real audio file."
            self.versionLabel.textColor = UIColor.blue
            do {
                try self.player = AVAudioPlayer(contentsOf: file.fileURL!)
                print("It seems that we have a player. \(self.player)")
                self.player?.prepareToPlay()
                self.player?.play()
            } catch let error as NSError {
                *print(error.localizedDescription) // This is firing...*
            }

file.fileURL! reports in the console as:

Documents/Inbox/com.apple.watchconnectivity/711E4215-77E2-422A-80C5-6ECA8621778E/Files/AE2DCCA0-EAA0-4E4C-8E46-D1AC77101760/audioFile.wav
-- 
file:///var/mobile/Containers/Data/Application/5E72A755-D60B-4633-8283-02A0891CA8B8/

file.fileURL!.path reports as:

/var/mobile/Containers/Data/Application/26CFE356-7FB1-483B-B918-BC0A2026DE46/Documents/Inbox/com.apple.watchconnectivity/711E4215-77E2-422A-80C5-6ECA8621778E/Files/90D004CE-88F7-4C66-9B9A-5580445A0572/audioFile.wav

So I tried
try self.player = AVAudioPlayer(contentsOf: file.fileURL!.path)* //
expecting URL and not a string so I tried:*

let myURL = URL(fileURLWithPath: file.fileURL!.path)
try self.player = AVAudioPlayer(contentsOf: myURL)

And got: *The operation couldn’t be completed. (OSStatus error 2003334207.)*

Seems kind of odd. I would think this might be easy, but for me so far it's
not.

Any help appreciated!!! I just want to play the .wav file that was sent to
the phone.



On Tue, Feb 7, 2017 at 11:25 PM Jens Alfke <[email protected]> wrote:

>
> On Feb 7, 2017, at 6:49 PM, Eric E. Dolecki <[email protected]> wrote:
>
> Now, I want to instantiate an AVAudioPlayer and play that sent file. I know
> that it's received (didFinish file transfer fires in the Watch Extension).
> How do I do that? I don't know how to make that file Data.
>
>
> Can’t you just create the AVAudioPlayer from the file's URL? I’m not super
> handy with Swift, but it should be something like
> `AVAudioPlayer(contentsOfURL: fileURL)`.
>
> —Jens
>
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to