1- package videoeditor . bhuvnesh . com . ffmpegvideoeditor .activity ;
1+ package protect . videotranscoder .activity ;
22
33import android .media .AudioManager ;
44import android .media .MediaPlayer ;
1010import android .support .v7 .app .AppCompatActivity ;
1111import android .view .MenuItem ;
1212import android .widget .TextView ;
13- import videoeditor .bhuvnesh .com .ffmpegvideoeditor .R ;
14- import videoeditor .bhuvnesh .com .ffmpegvideoeditor .views .VisualizerView ;
15-
16-
17- /**
18- * Created by Bhuvnesh on 09-03-2017.
19- */
20-
21- public class AudioPreviewActivity extends AppCompatActivity {
13+ import protect .videotranscoder .views .VisualizerView ;
14+ import protect .videotranscoder .R ;
2215
16+ public class AudioPreviewActivity extends AppCompatActivity
17+ {
2318 private VisualizerView mVisualizerView ;
2419
2520 private MediaPlayer mMediaPlayer ;
2621 private Visualizer mVisualizer ;
2722 private static final String FILEPATH = "filepath" ;
2823
29-
3024 @ Override
31- protected void onCreate (@ Nullable Bundle savedInstanceState ) {
25+ protected void onCreate (@ Nullable Bundle savedInstanceState )
26+ {
3227 super .onCreate (savedInstanceState );
3328 setContentView (R .layout .activity_audio_preview );
3429 ActionBar actionBar = getSupportActionBar ();
@@ -38,37 +33,41 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3833 actionBar .setDisplayShowHomeEnabled (true );
3934 }
4035
41- mVisualizerView = (VisualizerView ) findViewById (R .id .visualizerView );
42-
43-
36+ mVisualizerView = findViewById (R .id .visualizerView );
4437 }
4538
4639 @ Override
47- protected void onResume () {
40+ protected void onResume ()
41+ {
4842 super .onResume ();
4943 initAudio ();
5044 }
5145
5246 @ Override
53- public boolean onOptionsItemSelected (MenuItem item ) {
47+ public boolean onOptionsItemSelected (MenuItem item )
48+ {
5449 // handle arrow click here
55- if (item .getItemId () == android .R .id .home ) {
50+ if (item .getItemId () == android .R .id .home )
51+ {
5652 finish (); // close this activity and return to preview activity (if there is any)
5753 }
5854
5955 return super .onOptionsItemSelected (item );
6056 }
6157 @ Override
62- protected void onPause () {
58+ protected void onPause ()
59+ {
6360 super .onPause ();
64- if (mMediaPlayer != null ) {
61+ if (mMediaPlayer != null )
62+ {
6563 mVisualizer .release ();
6664 mMediaPlayer .release ();
6765 mMediaPlayer = null ;
6866 }
6967 }
7068
71- private void initAudio () {
69+ private void initAudio ()
70+ {
7271 setVolumeControlStream (AudioManager .STREAM_MUSIC );
7372 String filePath = getIntent ().getStringExtra (FILEPATH );
7473 TextView tvInstruction =(TextView ) findViewById (R .id .tvInstruction );
@@ -86,29 +85,35 @@ private void initAudio() {
8685 // non-Visualizer related code
8786 // in this callback.
8887 mMediaPlayer
89- .setOnCompletionListener (new MediaPlayer .OnCompletionListener () {
90- public void onCompletion (MediaPlayer mediaPlayer ) {
88+ .setOnCompletionListener (new MediaPlayer .OnCompletionListener ()
89+ {
90+ public void onCompletion (MediaPlayer mediaPlayer )
91+ {
9192 mVisualizer .setEnabled (false );
9293 }
9394 });
9495 mMediaPlayer .start ();
9596 mMediaPlayer .setLooping (true );
9697
9798 }
98- private void setupVisualizerFxAndUI () {
99+ private void setupVisualizerFxAndUI ()
100+ {
99101
100102 // Create the Visualizer object and attach it to our media player.
101103 mVisualizer = new Visualizer (mMediaPlayer .getAudioSessionId ());
102104 mVisualizer .setCaptureSize (Visualizer .getCaptureSizeRange ()[1 ]);
103105 mVisualizer .setDataCaptureListener (
104- new Visualizer .OnDataCaptureListener () {
106+ new Visualizer .OnDataCaptureListener ()
107+ {
105108 public void onWaveFormDataCapture (Visualizer visualizer ,
106- byte [] bytes , int samplingRate ) {
109+ byte [] bytes , int samplingRate )
110+ {
107111 mVisualizerView .updateVisualizer (bytes );
108112 }
109113
110114 public void onFftDataCapture (Visualizer visualizer ,
111- byte [] bytes , int samplingRate ) {
115+ byte [] bytes , int samplingRate )
116+ {
112117 }
113118 }, Visualizer .getMaxCaptureRate () / 2 , true , false );
114119 }
0 commit comments