Italian suoni nella mia app (risolto)

LordZenzo

Well-Known Member
Licensed User
Longtime User
mi sta accadendo una cosa strana
inizializzo il soundpool
e carico tre file wav ottenendone l'id
quindi ne faccio partire 1
mSoundPool.play(Suono3 , 1, 1, 1000, -1, 1)

-1 serve a farlo entrare in loop infinito

quando vado a cercare di bloccarlo con
mSoundPool.stop(Suono3)

non si ferma...
Consigli?
 

LordZenzo

Well-Known Member
Licensed User
Longtime User
dopo varie prove, funziona solo usando queste due sub
B4X:
Sub Suona(IdSuono As Int)
Dim k As Int   
    mSoundPool.Initialize(1)
    Select Case IdSuono
        Case 1:k=mSoundPool.Load(File.DirAssets,"Applauso1.wav")
        Case 2:k=mSoundPool.Load(File.DirAssets,"Applauso2.wav")
        Case 3:k=mSoundPool.Load(File.DirAssets,"intro.wav")
    End Select
    mSoundPool.Play(k , 1, 1, 1000, -1, 1)   
End Sub
Sub StopSuono
    mSoundPool.Release
End Sub
 

LordZenzo

Well-Known Member
Licensed User
Longtime User
fatta classe con mediaplayer
funzionale, da migliorare
B4X:
Sub Class_Globals
    Private nFilePath As String
    Private nFileNome As String
    Private nLoop As Boolean
    Private nSound As MediaPlayer
    Type SuoniFileName (Spath As String,Sname As String,Sloop As Boolean)
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(path As String, name As String)
    nFilePath=path
    nFileNome=name
    nSound.Initialize
End Sub
public Sub getFilePath As String
    Return nFilePath
End Sub
public Sub getFileNome As String
    Return nFileNome
End Sub
public Sub setIsLoop (s As Boolean)
    nLoop=s
End Sub
public Sub getIsLoop As Boolean
    Return nLoop
End Sub
public Sub Suona
    nSound.Looping=nLoop
    nSound.Load(nFilePath, nFileNome)
    nSound.play
End Sub
public Sub Ferma
    nSound.Stop
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…