SmartThings has alot of documentation including a section for learning groovy. There are some bugs and it’s lacking in some areas, but it’s gotten a lot better over the last couple of months.
The documentation is located: http://docs.smartthings.com/en/latest/
I went through the documentation at the beginning of the year, but I don’t remember reading anything that would help you with the validation. I probably go overboard or validation, but the easiest thing to do is ensure that the preferences you create have a default value and the number is within range.
For example, see the preferences documentation to learn how to restrict the volume preference to values 1-100.
Once you become more familiar with Groovy and you want to play the notification at the same volume that the device is already set to, you can get use the volume preference as a fallback and attempt to play it using the same volume that the device is already set to. The Music Player device should have the level attribute so you would just pass that into the function instead. It’s more complex than that, but it’s basically all it does.
Restore Track isn’t related to Groovy. I think the speaker allows you to pass in a track that can be restored to a specific spot after the message is played, but I don’t have a speaker so that’s just a guess.