bogerchan / Nier-Visualizer

A lightweight and efficient Android visual library.
Apache License 2.0
574 stars 75 forks source link

How to reset the visualizer after playback #39

Open kishorekumarek opened 3 years ago

kishorekumarek commented 3 years ago

When i call mVisualizerManager?.stop() and mVisualizerManager?.release(), i expect it to reset to original position, but it suddenly stop. how to reset the view to zero line after stop pls help

bogerchan commented 3 years ago

Hi, @tringkishorekumar , thanks for using the library, can you paste the codes here?

kishorekumarek commented 3 years ago

I use following renderer renderers = arrayOf(ColumnarType1Renderer(paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.parseColor("#777777") }))

I pulled out the code from sample to create the visualizer. `fun createNewVisualizerManager() { mVisualizerManager?.release() mVisualizerManager = NierVisualizerManager().apply { when (mStatus) { STATUS_MEDIA_PLAYER -> { mPlayer?.let { init(it.audioSessionId) } } STATUS_AUDIO_RECORD, STATUS_UNKNOWN -> { init(object : NierVisualizerManager.NVDataSource {

                    private val mBuffer: ByteArray = ByteArray(512)
                    private val mAudioDataConverter: AbsAudioDataConverter =
                        AudioDataConverterFactory.getConverterByAudioRecord(mAudioRecord)

                    override fun getDataSamplingInterval() = 0L

                    override fun getDataLength() = mBuffer.size

                    override fun fetchFftData(): ByteArray? {
                        return null
                    }

                    override fun fetchWaveData(): ByteArray? {
                        mAudioDataConverter.convertWaveDataTo(mBuffer)
                        return mBuffer
                    }

                })
            }
        }
    }
}`

Once I am done with recording, I am calling like below mAudioRecordState = STATE_STOP mVisualizerManager?.stop()

The problem here is it stops abrubtly with waves still raised, i want the wave to come to resting position on calling mVisualizerManager?.stop()

quensh93 commented 3 years ago

same problem here, after play one file i stop mVisualizerManager and then i change the media player and on setOnPreparedListener i will start mVisualizerManager again, i will see 2 wawe!

bogerchan commented 2 years ago

Sorry for the late reply, I'll improve it in the next release.