Android Question Making a Vumeter with a Vizualizer PeakLevelAudio for Exoplayer

Discussion in 'Android Questions' started by scsjc, Oct 27, 2018.

  1. scsjc

    scsjc Well-Known Member Licensed User

    I use this code to create a Vumeter with the Vizualizer class playing audio url with Exoplayer.

    Code:
    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:

    upload_2018-10-27_14-7-20.png


    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
     

    Attached Files:

  2. stevel05

    stevel05 Expert Licensed 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.
     
    Peter Simpson likes this.
  3. scsjc

    scsjc Well-Known Member Licensed User

    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
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice