I am using the Phone.RingtoneManager to allow the user to select a sound for an alarm app, and it returns a URI of the selected sound.
Yes, the RingtoneManager does have a ".Play" method that will take a URI. But it does not have a ".Stop" method to stop playing long sound files. Yeah, I might be able to find a way to kill the RM object to stop it, but that is ugly.
The MediaPlayer requires separate Directory and File parameters, so it can't take a URI. Yes there are examples of how to extract the directory and filenames from a URI, but it's not guaranteed to work.
So, is there a way an alarm app can play the selected sound URI and then stop playing it on demand?
Yes, the RingtoneManager does have a ".Play" method that will take a URI. But it does not have a ".Stop" method to stop playing long sound files. Yeah, I might be able to find a way to kill the RM object to stop it, but that is ugly.
The MediaPlayer requires separate Directory and File parameters, so it can't take a URI. Yes there are examples of how to extract the directory and filenames from a URI, but it's not guaranteed to work.
So, is there a way an alarm app can play the selected sound URI and then stop playing it on demand?