Somehow i got the media controller fixed on the screen by over-riding
the hide() method but
now the issue is that i can not go back from the activity untill the
song is finished playing.

The Code :-

public class AudioPlayerScreen extends Activity {
        private String uri;
        private MediaPlayer mp;
        VideoView vv;
        ImageView iv;
        MediaController mediaController;
        /** Called when the activity is first created. */

        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.audio_player_2);


                uri = this.getIntent().getExtras().getString("song_uri");
                  Uri path = Uri.parse(uri);

                //TextView tvDuration = (TextView)
findViewById(R.id.tv_song_duration);

                // **mp = MediaPlayer.create(this, Uri.parse(uri));
                // tvDuration.setText(mp.getDuration());

                // **mp.start();
                  vv=(VideoView)findViewById(R.id.vv);
                getWindow().setFormat(PixelFormat.TRANSLUCENT);
               // show(0);
            mediaController = new MediaController(this);
                        //mediaController.show(50000);

                //      MediaController mc;


                        vv.setMediaController(new MediaController(this)
                        {
                        public void hide()
                        {
        
System.out.println("HIDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEHELLLOO");
                mediaController.show(5000);

                        }
                        public void onBackPressed() {
                                try {
                                        mp.stop();
                                        
mediaController.setVisibility(View.GONE);
                                        mp = null;
                                        AudioPlayerScreen.this.finish();
                                } catch (Exception e) {
                                        e.printStackTrace();
                                }

                        }

                        });






               // vv.setMediaController(mediaController);
                vv.setVideoURI(path);
                vv.start();


        }

        //public void show(int timeout)
        //{}
        public void onClickPlayPauseButton(View v) {
                // if (((ToggleButton) v).isChecked()) {
                // mp.pause();
                // } else {
                // mp.start();
                // }
                if (mp.isPlaying()) {
                        mp.pause();
                } else {
                        mp.start();

                }
        }


        public void onBackPressed() {
                try {
                        mp.stop();
                        mediaController.setVisibility(View.GONE);
                        mp = null;
                        AudioPlayerScreen.this.finish();
                } catch (Exception e) {
                        e.printStackTrace();
                }
                super.onBackPressed();
        }
};

as you can see i have even overide the onBackPressed() method but
still it is not going to previous activity

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to