cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

Dropbox files & folders

Get in sync with the Dropbox Community. Our members can answer all your questions on Dropbox files and folders. Join a discussion or start your own today.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Playing audio files directly from Dropbox (Swift 5)

Highlighted

Playing audio files directly from Dropbox (Swift 5)

Helpful | Level 6

Hello, in my app I want to be able to play audio files directly from Dropbox. I have already successfully connected the Dropbox API. I can get a list of user files and download them.

What other settings should I make to play audio files? What url should I use for this?

Thanks.

8 Replies 8
Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Super Collaborator | Level 20

Hi @VyacheslavBakinskiy,

As a direct streaming URL you can do something, used from SDK automatically for download. Instead of download and play, once you have token and file path or file id, you can construct the download URL yourself and use it for streaming.

Hope this gives an idea.

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Helpful | Level 6

For downloading I use .pathLower of file, but it isn't a URL. How can I create the URL for streaming?

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Super Collaborator | Level 20

@VyacheslavBakinskiy wrote:

For download I use .pathLower of file, but it isn't a URL...


Yes, of course. That's why I told you construct it yourself! The SDK, you are using, constructs it, but you don't have direct access there. It's only for internal use (don't ask me why).

 


@VyacheslavBakinskiy wrote:

... How can I create the URL for streaming?


Did you read the link in my previous post? 🤔

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Helpful | Level 6

Yes, I read. But I don't understand what is the "--header". It's a header of the HTTP request? I don't understand how I can implement this in Swift. Sorry, but I haven't come across this yet. Can you explain to me in more detail?

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Super Collaborator | Level 20

@VyacheslavBakinskiy wrote:

... But I don't understand what is the "--header". It's a header of the HTTP request? ...


🙂 Seems you haven't used terminal shell yet. The example, which confuses you, is a just a example of call a Dropbox HTTP API using a Posix's command ( more precisely 'curl' ). This is NOT a URL itself! Yes, it's strange, Dropbox hasn't provided a pure HTTP example too, but it's Dropbox, what can I say. In the particular example curl takes care for URL construction and the call invocation. It's supposed every developer have basic knowledge about what's a URL and all components. The URL is nothing more than provided in the "URL STRUCTURE" field:

https://content.dropboxapi.com/2/files/download

Here the set of parameters is empty, so you don't have to pass anything. What exactly has to be downloaded and from where (i.e. the account) gets denoted with headers (i.e. what follows the "--header"). Last, but not least, the request must be POST. For more info how this could be achieved using Swift take a look here.

Hope this gives enough directions.

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Helpful | Level 6

Thanks a lot. What other ways are there to solve my question? How about getTemporaryLink function? Can I use it for streaming audio? I found this solution here: https://stackoverflow.com/questions/39247178/how-to-play-dropbox-audio-file-using-jukebox-using-swif...

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Super Collaborator | Level 20

Yes, using a link is a possible way. I didn't mention it, as I'm guess You already have rejected such a possibility. It is more convenient and easy to implement, but have some disadvantages. Less secure and limited traffic (could be banned). If this is not a problem, Yes, of course.

The choice is yours! 😉

Highlighted

Re: Playing audio files directly from Dropbox (Swift 5)

Helpful | Level 6

Thank you, I will analyze and decide what is best for me.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?