Use WKSessionFile as Data for AVAudioPlayer?
Use WKSessionFile as Data for AVAudioPlayer?
- Subject: Use WKSessionFile as Data for AVAudioPlayer?
- From: "Eric E. Dolecki" <email@hidden>
- Date: Wed, 08 Feb 2017 02:49:18 +0000
I am transferring an audio file from Apple Watch extension to iOS
application.
In the Extension:
func sendAudioFileProper(){
WCSession.default().transferFile(saveURL as! URL, metadata: nil)
}
I create saveURL like this:
let fileManager = FileManager.default
let container =
fileManager.containerURL(forSecurityApplicationGroupIdentifier:
"group.net.ericd.WatchRecord")
let fileName = "audioFile.wav"
saveURL = container?.appendingPathComponent(fileName) as NSURL?
iOS application:
func session(_ session: WCSession, didReceive file: WCSessionFile)
{
DispatchQueue.main.async
{
self.versionLabel.text = "We got a real audio file."
self.versionLabel.textColor = UIColor.blue
* // ? How do I use the file to instantiate an AVAudioPlayer?*
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.
I am using an app group if that matters. Should I be saving the file when
received, then use it to create the AVAudioPlayer? If so, how should I do
that?
_______________________________________________
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