0
votes

I would like to be able to share an audio file to Twitter, Facebook etc. using either UIActivityViewController or UIDocumentInteractionController when a user presses a share button for an audio clip which is played by being streamed remotely via AVPlayer.

Ideally when the share button is pressed I would to present the user with options for sharing via Twitter, Facebook etc. and then once they select the option - download the file. Conversely I can download the file before hand which is the simpler solution.

This is my attempt where I download the audio file first, which doesn't enable sharing via Twitter or Facebook.

            let item: [Any] = [url] // URL path to where audio file is written to
            let avc = UIActivityViewController(activityItems: item, applicationActivities: nil)
            self.present(avc, animated: true)

I'm surprised at how challenging this has been. If only it was as easy as sharing an image! Help greatly appreciated

1

1 Answers

0
votes

The problem I was having was in regards to the audio format. My code is correct for sharing but I am unable to do so as I had audio files that were Apple Core Audio Format (.caf) and for example on Twitter, you can only share Advanced Audio Coding (AAC).

Hope this saves some people time.