Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with local files? #43

Closed
gerrithu opened this issue Mar 8, 2019 · 3 comments
Closed

How to use with local files? #43

gerrithu opened this issue Mar 8, 2019 · 3 comments

Comments

@gerrithu
Copy link

gerrithu commented Mar 8, 2019

Could you please give an example on how to use the player with local mp3 file?

That’ll be awesome!

@jorgenhenrichsen
Copy link
Owner

jorgenhenrichsen commented Mar 9, 2019

Sure 👍
Here is an example when using the DefaultAudioItem struct.

let item = DefaultAudioItem(audioUrl: "PathToYourSoundFile", sourceType: .file)
try? audioPlayer.load(item)

This of course requires you to find the correct path to your mp3 file.

@TheM4hd1
Copy link

Just a note, don't include scheme in your path
It's wrong: file:///var/container/......./music.mp3, you have to remove file://

@gerrithu
Copy link
Author

Alright. Works perfectly.

I’m getting the path now like this:

let path: String = Bundle.main.path(forResource: "soundfile", ofType: "mp3")!

Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants