-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/stop sound widget #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just two small improvments.
App/IntentRunner.swift
Outdated
} | ||
|
||
guard let fileURL = intent.sound.file.fileURL, let newPlayer = try? AudioPlayer(url: fileURL) else { | ||
print("Failed to create player for \(intent.sound.title)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we throw an error here, the user will get an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3948880
App/IntentRunner.swift
Outdated
} catch { | ||
print("Playing Sound fauled error:", error.localizedDescription) | ||
print("Playing Sound failed error:", error.localizedDescription) | ||
activePlayer[intent.sound.id] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activePlayer[intent.sound.id] = nil
can be moved after the catch block to avoid repeating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually we should probably throw an error if the sounds fails to play. in this case you can use defer
to still nil the active player.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 032f0c0
Fix based on the suggestion in this ticket:
#7
Now there’s a consistent behavior between the app and the widget. Also updated to use the id instead of the title because if two sounds had the same name, both would get stopped. You can now play multiple sounds and stop them individually!