I want to save media-player object when orientation changes from portrait to landscape mode.
As i know when you change your orientation your activity get recreated so thats why my old media player object get distroyed.i tried onretainNonConfigureInstance method but it wont work for me.
I want old media player object in landscape view to display felixpalmer android-visualizer. To display Visualiser you need to link media player object with visualiser-view.
IS there any alternative way to pass old media player object to landscape view and vice versa??
Maybe you could just keep your media player object in a static variable inside the activity so it’ll be preserved on orientation changes.
Even though I’ve never used the Android Visualizer component, checking the source code of its
VisualizerViewclass I see that it uses the Android’sVisualizerclass.As you can see in the documentation of the
setCaptureSizemethod, it cannot be called while theVisualizeris enabled.This is what I would try to do for your usage pattern:
Option 1
Call the
release()method of theVisualizerViewclass when the screen orientation changes because that will call also therelease()method of the Android’sVisualizerobject thus releasing all the resources and allowing you to create a new one with a call tolink()on theVisualizerViewobject to link your media player again.Option 2
Take a look at this question and its answer. You could try to modify the source code of the
VisualizerViewclass and insertmVisualizer.setEnabled(false)inside thelink()method right after the creation of a newVisualizerinstance and before thesetCaptureSizecall.