rleiman Well-Known Member Licensed User Longtime User Apr 7, 2016 #1 Hi Everyone, I would like to use select an audio file which is an mp3 file, get the uri for that file, then create another mp3 file in a different location on a phone so it can be used as a ringtone. So far I use this content chooser coding to get hold of the mp3 file and store the uri for that file into a string. Code: CC.Show("audio/*", "Choose an audio file") Code: Sub ContentChooser_Result (Success As Boolean, Dir As String, FileName As String) If Success = True Then strUriChosen = FileName StartActivity(SoundFiles) End If End Sub I tried to create a temporary mp3 file with File.Copy2 but it won't compile because it tells me I have an error on the 1st parameter of File.Copy2. It seems it need an InputStream but I don't know how to convert the uri of the audio file to an InputStream. Code: Dim out As OutputStream out = File.OpenOutput(File.DirDefaultExternal, "Temp.mp3" , False ) File.Copy2(strUriChosen , out) out.Close I'm guessing at this coding because I did not find a tutorial or sample showing how to get this to work. If someone would be kind enough to upload a sample app showing how to do this, it will be greatly appreciated. Thanks.
Hi Everyone, I would like to use select an audio file which is an mp3 file, get the uri for that file, then create another mp3 file in a different location on a phone so it can be used as a ringtone. So far I use this content chooser coding to get hold of the mp3 file and store the uri for that file into a string. Code: CC.Show("audio/*", "Choose an audio file") Code: Sub ContentChooser_Result (Success As Boolean, Dir As String, FileName As String) If Success = True Then strUriChosen = FileName StartActivity(SoundFiles) End If End Sub I tried to create a temporary mp3 file with File.Copy2 but it won't compile because it tells me I have an error on the 1st parameter of File.Copy2. It seems it need an InputStream but I don't know how to convert the uri of the audio file to an InputStream. Code: Dim out As OutputStream out = File.OpenOutput(File.DirDefaultExternal, "Temp.mp3" , False ) File.Copy2(strUriChosen , out) out.Close I'm guessing at this coding because I did not find a tutorial or sample showing how to get this to work. If someone would be kind enough to upload a sample app showing how to do this, it will be greatly appreciated. Thanks.
DonManfred Expert Licensed User Longtime User Apr 7, 2016 #2 Read the content of the result uri from contentresolver into a byte array Create a inputstream from this bytearray Create a outputstream like in your code Copy the data with file.copy2 Upvote 0
Read the content of the result uri from contentresolver into a byte array Create a inputstream from this bytearray Create a outputstream like in your code Copy the data with file.copy2