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

Feature/stop sound widget #10

Merged
merged 6 commits into from
Mar 1, 2025
Merged

Feature/stop sound widget #10

merged 6 commits into from
Mar 1, 2025

Conversation

MarielaCastillo
Copy link
Contributor

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!

@MarielaCastillo MarielaCastillo linked an issue Feb 21, 2025 that may be closed by this pull request
Copy link
Contributor

@leoMehlig leoMehlig left a 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.

}

guard let fileURL = intent.sound.file.fileURL, let newPlayer = try? AudioPlayer(url: fileURL) else {
print("Failed to create player for \(intent.sound.title)")
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3948880

} catch {
print("Playing Sound fauled error:", error.localizedDescription)
print("Playing Sound failed error:", error.localizedDescription)
activePlayer[intent.sound.id] = nil
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 032f0c0

@leoMehlig leoMehlig merged commit 8e111c4 into develop Mar 1, 2025
@leoMehlig leoMehlig deleted the feature/stop-sound-widget branch March 1, 2025 11:28
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

Successfully merging this pull request may close these issues.

terminate an audio before it finishes
2 participants