Android Question Making a Vumeter with a Vizualizer PeakLevelAudio for Exoplayer

scsjc

Well-Known Member
Licensed User
Longtime User
I use this code to create a Vumeter with the Vizualizer class playing audio url with Exoplayer.

B4X:
Sub Process_Globals
    Dim Timer As Timer
    Private player1 As SimpleExoPlayer
End Sub
Sub Globals
    Dim Viz As Vizualizer
End Sub
Sub Activity_Create(FirstTime As Boolean)

    player1.Initialize("player")
    Dim sources As List
    sources.Initialize
    sources.Add(player1.CreateUriSource("http://icecast-streaming.nice264.com/europafm"))
    player1.Prepare(player1.CreateListSource(sources))
    
    'Initialize the Visualizer
    Dim audiosession As Int = player1.CurrentWindowIndex
    Viz.Initialize(Me, audiosession)
    Viz.CaptureSize = Viz.CaptureSizeRange(1)
    Viz.SetDataCaptureListener(Viz.GetMaxCaptureRate / 2,True,True)
    Viz.MeasurementMode = 1

    Timer.Initialize("Timer", 100)
    Timer.Enabled=True
    Viz.Enabled = True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
    Viz.StopDataCapture
    Viz.Release
End Sub
Sub FFT_Capture(Data() As Byte,SamplingRate As Int)
'    Log("FFT " & Data.Length)
'    Log(SamplingRate)
End Sub
Sub Wave_Capture(Data() As Byte,SamplingRate As Int)
'    Log("Wav " & Data.Length)
'    Log(SamplingRate)
End Sub
Sub Timer_Tick
    Log("Peak LevelAudio: " & Viz.getMeasurementPeakRms.mPeak)
End Sub

Sub Player_Ready
    Log("Player_Ready")
    player1.Play
End Sub

Sub Player_Error (Message As String)
    Log("Player_Error " & Message)
End Sub

Sub Player_Complete
    Log("Player_Complete")
End Sub

This example works correctly, but I do not know why because when I try to add it to my code it gives me this error:




I have read on https://github.com/felixpalmer/android-visualizer/issues/31 that may be due "android.permission.RECORD_AUDIO", but I have it correctly.

Has anyone had a similar problem? or have some better solution than this to be able to do a Vumeter using the ExoPlayer
 

Attachments

  • Vizualizer PeakLevelAudio Exoplayer.zip
    8.6 KB · Views: 410

stevel05

Expert
Licensed User
Longtime User
I have not used SimpleExoplayer, but player1.CurrentWindowIndex does not return a valid audiosystem id that can be used to initialize the Visualizer engine.
 
Upvote 0

scsjc

Well-Known Member
Licensed User
Longtime User
I have not used SimpleExoplayer, but player1.CurrentWindowIndex does not return a valid audiosystem id that can be used to initialize the Visualizer engine.

It's true, I just realized. But leaving that variable at 0, it continues to work perfectly in this example. and I do not know why it could be that in an app that I have in production, applying the same does not work.

Thank you
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…