0

My Java Code and I know How To Play / Stop / Pause Video

videoView=(VideoView)findViewById(R.id.videoView);
// Video from raw Folder 

mediaController = new MediaController(this);
uri = Uri.parse("android.resource://" + getPackageName() + "/"+ R.raw.abc);
videoView.setVideoURI(uri);
mediaController.setMediaPlayer(videoView);
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.start();
Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
  • Have you seen the [Toasts page](http://developer.android.com/guide/topics/ui/notifiers/toasts.html) including tutorial, and tried to do that? Seems like you have a `Context` available and could just use `Toast.makeText(context, "Text", Toast.LENGTH_SHORT).show();` – AlexWalterbos Jun 08 '15 at 13:16
  • Sorry but I want to get event from mediacontroller. like user Press in button pause in medi controller at time want toast – Android Devloper's Jun 08 '15 at 13:28
  • I think this link will help you..http://stackoverflow.com/questions/7934556/event-for-videoview-playback-state-or-mediacontroller-play-pause/8046523#8046523 – Tushar Patil Jun 08 '15 at 14:31

3 Answers3

0

If you know how to pause / start / stop you just need to add a toast in your onClickListener for each button, if, however, you don't really know how to do that here is a simple example

in your layout XML containing the Buttons

<Button
            android:id="@+id/Start"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="onClick" />

<Button
                android:id="@+id/Stop"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="onClick" />

Then, in your java activity you need to create the defined "onClick" method to handle the click

public void onClick(View view){
    int id = view.getId();

    if(id == R.id.Start){
        Toast.makeText(getApplicationContext(), "Start", Toast.LENGTH_SHORT).show();
    }

    else if(id == R.id.Stop){
        Toast.makeText(getApplicationContext(), "Stop", Toast.LENGTH_SHORT).show();
    }
}
Galax
  • 367
  • 1
  • 13
0

Check the videoView state like:

if(videoView.isPlaying()){
 Toast.makeText(context, "Paused", Toast.LENGTH_SHORT).show();
}
Suman Dey
  • 66
  • 1
  • 10
0

You can extend your VideoView in which you can override pause() and start():

MediaController mediaController = //Setup of your MediaController
mediaController.setMediaPlayer(CustomVideoView);

where your CustomVideoView looks something like this:

public class CustomVideoView extends VideoView {
   @Override
   public void start() {
       super.start();
       Toast.makeText(getContext, "This is your text", Toast.LENGTH_SHORT).show();
   }

   @Override
   public void pause() {
       super.pause();
       Toast.makeText(getContext, "This is your text", Toast.LENGTH_SHORT).show();
   }
}
AlexWalterbos
  • 408
  • 4
  • 12
  • Can you provide more of your code as it is now? Then I'll know where to start, and I can update my answer accordingly. Please post it in your original question. – AlexWalterbos Jun 08 '15 at 13:53
  • this is my complete code, i cant post image bt like in when we playing some video at time we touch the screen at time its diplay controll pre- paly/pause - next at time user do any action on that button at time i want to get event – Android Devloper's Jun 08 '15 at 13:57
  • sry bro bt now i understan and get Answer Exm. Like when user is pressd any button at time action create ad i will check the event with boolean isPlaying or pause – Android Devloper's Jun 08 '15 at 14:06
  • So if I understand correctly you've found your answer, since you've marked @Suman Dey's answer as accepted? – AlexWalterbos Jun 08 '15 at 14:08
  • yes bt thanx and sry i m new in android and also in stack so – Android Devloper's Jun 08 '15 at 14:10