Android Question list audio file

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Hello friends. Need help to access audio files , select one and then play it . I do not find a help in this regard. Also I wanted to edit the playback speed in another post I explained that I use soundpool . I thank my guide them.
 

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Erel Thanks . Content chosser I worked out well ! I try to play an audio soundpool only reproducide some files, you know why ? not if they are too heavy or that happens. What I need is to play audio and the user can adjust its speed during playback. I'm not sure soundpool allow me to do this if it worked .
part of code

B4X:
Sub Btnaudio_Click
    audio.Initialize ("audio")
    audio.Show ("*/*","selecciona tu musica:")
   
End Sub
Sub audio_Result (Success As Boolean, Dir As String, FileName As String)
   
   If Success  Then 
      archivo = FileName
   
If archivo.StartsWith("/") Then Return archivo 'If the user used a file manager to choose the image

  Dim Cursor1 As Cursor
  Dim Uri1 As Uri
  Dim Proj() As String = Array As String("_data")
  Dim cr As ContentResolver
  cr.Initialize("")
  If archivo.StartsWith("content://com.android.providers.media.documents") Then
  Dim i As Int = archivo.IndexOf("%3A")
  Dim id As String = archivo.SubString(i + 3)
  Uri1.Parse(archivo)
  Cursor1 = cr.Query(Uri1, Proj, "_id = ?", Array As String(id), "")
  Else
  Uri1.Parse(archivo)
  Cursor1 = cr.Query(Uri1, Proj, "", Null, "")
  End If
  Cursor1.Position = 0
  Dim res As String
  Dim res1 As String
 
  res = Cursor1.GetString("_data")
  Cursor1.Close
  res1 = res.SubString(res.LastIndexOf("/") + 1)
   
     Dim largo As Int
     Dim largo1 As Int
     Dim musica As String
    
     largo = res1.Length
     largo1 = res.Length
   
    musica = res.SubString2(0,res.LastIndexOf("/") + 1)
   
    sonido.Initialize(2) 

      load = sonido.Load(musica, res1)
    Log(res)
    Log (res1)
    Log(musica)
    play = sonido.Play(load,1,1,1,2,2)

   
   Else
   Return
   End If
   
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…