• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Use WKSessionFile as Data for AVAudioPlayer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use WKSessionFile as Data for AVAudioPlayer?


  • Subject: Re: Use WKSessionFile as Data for AVAudioPlayer?
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Wed, 08 Feb 2017 13:48:11 +0000

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@hidden> wrote:

>
> On Feb 7, 2017, at 6:49 PM, Eric E. Dolecki <email@hidden> 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@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Use WKSessionFile as Data for AVAudioPlayer?
      • From: Jens Alfke <email@hidden>
    • Re: Use WKSessionFile as Data for AVAudioPlayer?
      • From: "Eric E. Dolecki" <email@hidden>
References: 
 >Use WKSessionFile as Data for AVAudioPlayer? (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Use WKSessionFile as Data for AVAudioPlayer? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Mobile Cross Platform Solutions
  • Next by Date: Re: Use WKSessionFile as Data for AVAudioPlayer?
  • Previous by thread: Re: Use WKSessionFile as Data for AVAudioPlayer?
  • Next by thread: Re: Use WKSessionFile as Data for AVAudioPlayer?
  • Index(es):
    • Date
    • Thread