Hi all,
I am having a video, which I am playing in videoview. Now, it is initially
started playing.
After that, while it is playing, I want to click it and pause it on that,
and similarly I want to resume it on clicking it again.
I initially used onClickListener on videoView, which didn't work. Later, I
realized onTouchListener is helpful, so I used that.
It somewhat helped me. Now, I am able to pause it on first click, but after
when I reclick it, it shows strange behaviour.
Its being played when my mouse is pressed, and as soon as I release the
key, it is again paused.
The code I am using is as follows:
public class Play_video extends Activity{
private VideoView video;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.play_video);
File clip=new File("/sdcard/my.mp4");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.myvideoview);
video.setVideoPath(clip.getAbsolutePath());
video.start();
video.requestFocus();
Log.d("videoview", "before click");
video.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if(video.isPlaying())
{
Log.d("video","is playing");
video.pause();
}
else
{
video.start();
Log.d("video","is paused");
}
return true;
}
});
}
}
}
Please direct me where I am wrong, and what should I do to achieve this.
Thanks & Regards
NSR
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en