- User must tap once to make it visible
- Once it is visible then user is trapped in the activity unless the song ends since the back button is not functioning the way it should be
The code is :-
package com.hungama.myplay.activity;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.VideoView;
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();
}
});
// 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();
mp = null;
} catch (Exception e) {
e.printStackTrace();
}
super.onBackPressed();
}
};
On Thu, Feb 3, 2011 at 2:36 AM, Robin Talwar <r.o.b.i.n.abhishek@gmail.com> wrote:
Do i need to make a custom Media Controller??
Is there any Framelayout related in this stuff anywhere in layout file?On Thu, Feb 3, 2011 at 2:26 AM, Abhishek Talwar <r.o.b.i.n.abhishek@gmail.com> wrote:
Guys i am playing an video with a video view .
So far it is cool and video plays nice but the media Controller which
comes at the bottom of the screen appears
only on touch and i want that it should be there permanently.
I googled and i thot the following code should be fine :-
Uri path = Uri.parse("android.resource://com.vid1/" + R.raw.p1);
vv=(VideoView)findViewById(R.id.vv);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mc = new MediaController(this);
mc.setAnchorView(vv);
mc.show(0);
mc.requestFocus();
vv.setMediaController(mc);
vv.setVideoURI(path);
and this gives me a force close and a Null Pointer in log cat.
i am sorry this may be a duplicate post but this one has detailed code
and more clear understanding of situation.
Thanks in advance
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment