0

Here I am going on with the fullscreen activity of playing video (i.e) i had two screens one is MainScreen and other one to view.In my FirstScreen I have several videos in listview if i longpress on the video it should take the video to Secondscreen there that patricular video should viewed in fullscreen.

If i am playing the video in Firstscreen with duration of(0:00 to 5:00 min) there my video is playing in duration (2:00 min)that time if i longpress the video to view in fullscreen while video playing in Firstscreen with duration between (2:00 min)there the video should continue with the same duration in fullscreen.

I can able to send the video to other screen to view fullscreen video but my problem was it plays from the beginning of the video how can i continue the same duration(2:00 min) as in firstscreen tried a lot to do this but can't able to fix it.

If anyone have idea about this please help me friends.

Here is my code below:

MainScreen:

   public void onPrepared(MediaPlayer mp) {
                     videoPosition = mp.getCurrentPosition();
                    pDialog.dismiss();
                    videoPreview.start();
                }

   videoFullScreenButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                Intent videoIntent = new Intent(MainScreen.this, FullViewScreen.class);
               videoIntent.putExtra("current_position",videoPosition);
                startActivity(videoIntent);
      }
        });

FullScreen:

public void onPrepared(MediaPlayer mp) {
                Intent intent = getIntent();
                String id = intent.getStringExtra("current_position");


                mp.seekTo(Integer.parseInt(id));

                pDialog.dismiss();

                videoPreview.start();
            }

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"


    <VideoView
        android:id="@+id/media_video_preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"

        />
</RelativeLayout>
Manoj
  • 3,947
  • 9
  • 46
  • 84

2 Answers2

0

In VideoView, you can do this:

  1. On LongPress event, capture the current position of video using getCurrentPosition method:

    int videoPosition = mVideoView.getCurrentPosition(); 
    
  2. Send this position along with video in Second Activity using intent.putExtra()

  3. In your second activity, use seekTo to start the video from that particular position.

    mVideoView.seekTo(videoPosition);
    mVideoView.start();
    

Hope it helps.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
  • let me try and know for u – Manoj Nov 15 '14 at 05:55
  • after trying this i got null point error i have edited and posted my code can u plz see it and correct me where i go wrong – Manoj Nov 15 '14 at 11:26
  • but for me in the mainscreen itself the value didn't set for duration it set as 0 – Manoj Nov 15 '14 at 11:36
  • what ever the postion of video – Manoj Nov 15 '14 at 11:37
  • what ever the postion of video it set's as 0 – Manoj Nov 15 '14 at 11:37
  • how to get the play pause button option to center of the screen by default it shows at the bottom of the screen – Manoj Nov 24 '14 at 07:30
  • @ MysticMagic how to get the play pause button option to center of the screen by default it shows at the bottom of the screen – Manoj Nov 24 '14 at 07:31
  • @Manoj you will need to make changes in xml. If possible, show code or ask question with xml and give me link. Will try to help. – MysticMagicϡ Nov 24 '14 at 07:35
  • http://stackoverflow.com/questions/27099882/how-to-get-hardware-key-option-to-center-of-screen – Manoj Nov 24 '14 at 07:41
  • I had update the above and posted a question in stackoverflow added the link please see it – Manoj Nov 24 '14 at 07:43
  • @ MysticMagic i had updated and posted a question please see it – Manoj Nov 24 '14 at 07:48
  • i had posted question for background service can plz help me here is the link ; – Manoj Nov 26 '14 at 14:36
  • i had posted question for background service can plz help me here is the link:http://stackoverflow.com/questions/27151744/how-to-stop-background-service-automatically-when-app-is-not-in-use – Manoj Nov 26 '14 at 14:37
  • @ MysticMagic i had posted question for background service can plz help me here is the link:http://stackoverflow.com/questions/27151744/how-to-stop-background-service-automatically-when-app-is-not-in-use – Manoj Nov 26 '14 at 14:39
0

you can get current position of video onbutton click for full screen and set value to fullscreen activity and play from that position.

     public void fullscreen(){ 
     int current_position=mediaPlayer.getCurrentPosition();
     Intent i=new Intent(MainActivity.this, Fullscreen.class);
     i.putextra("value",current_position)
     startActivity(i);
       }  

fullscreen activity

     Intent intent = getIntent();
     String id = intent.getStringExtra("value");

        mp.prepare();   
        mp.seekTo(Integer.parseInt(id)); 
        mp.start(); 
raj
  • 2,088
  • 14
  • 23