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

Inconsistencies between static methods and instances #55

Closed
trentjones21 opened this issue May 29, 2020 · 2 comments
Closed

Inconsistencies between static methods and instances #55

trentjones21 opened this issue May 29, 2020 · 2 comments

Comments

@trentjones21
Copy link

This is working for me:

let fileURL = Bundle.main.url(forResource: "MyMusic", withExtension: "mp3")!
Sound.play(url: fileURL) // Music plays

While this is not

let fileURL = Bundle.main.url(forResource: "MyMusic", withExtension: "mp3")!
let mySound = Sound(url: fileURL)!
mySound.play()

I'm running both these snippets in the exact same spot in my code, so I have no idea why one would work and the other wouldn't. May very well be user error, but I think I'm following the documentation correctly.

@trentjones21
Copy link
Author

I fixed the issue by moving the reference to the Sound instance to a higher scope

@aloveric
Copy link

aloveric commented Jan 5, 2021

Same for me. It is not working.

let mySound = Sound(url: fileURL)
mySound.play()

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

2 participants