Hello,
In my app, users are supposed to select a sound file from the audio section to play when a message arrives. I store both the filename and the URI in a database.
After restarting the app, the URI is no longer valid/persistant. How can I determine a valid URI from the filename (mysoundfile.mp3)?
This app is for the play store.
Thanks
In my app, users are supposed to select a sound file from the audio section to play when a message arrives. I store both the filename and the URI in a database.
After restarting the app, the URI is no longer valid/persistant. How can I determine a valid URI from the filename (mysoundfile.mp3)?
This app is for the play store.
Thanks
Get the URI:
Private Sub but_fileselect_Click
Dim CC As ContentChooser
Dim SQL As String
Dim result As Int
Dim Datei_pur As String
CC.Initialize("cc")
CC.Show("audio/*", "Datei auswählen")
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
If Success And FileName.Length > 0 Then
Datei_pur = GetFileInfoByIndex("_display_name", FileName)
Msgbox2Async("Bisherige Datei: <" & mod_allgemein.set_Externe_SoundDatei_Klartext & "> ersetzen durch: <" & Datei_pur & ">", "Sound-Datei auswählen", "Ja", "", "Nein", Null, False)
Wait For MsgBox_Result(result As Int)
If result = DialogResponse.Positive Then
'URI in DB speichern
SQL="UPDATE tab_settings SET sFrei3 = '" & Datei_pur & TAB & FileName & "' WHERE id = 1"
mod_SQL.exec_NONQuery(SQL)
mod_allgemein.set_Externe_SoundDatei = FileName 'z.B.: content://com.android.providers.media.documents/document/audio%3A1000007252
mod_allgemein.set_Externe_SoundDatei_Klartext = Datei_pur
Label_SoundDatei.Text = Datei_pur
End If
End If
End Sub
Play the file:
Starter.MP.Load("ContentDir", mod_allgemein.set_Externe_SoundDatei)
Starter.MP.Play