Videoview getDuration()

All your problems with Audio, Video and Images.

Videoview getDuration()

Postby hkswaroop » Tue Jun 09, 2009 8:13 am

hi i have an app which plays mp4 file from sdcard, and am using videoview.
But getDuration() is returning -1.
I tried to get the duration after setVideoPath() and even also after start(), in both cases am getting -1.
Does anyone know why is that. Is there any other way to get the duration of video file am playing.
Thanks.
hkswaroop
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed May 20, 2009 8:15 am
Location: Bangalore

Top

Postby Sowmya » Fri Jun 12, 2009 9:14 am

I got the video duration of an 3gp using this listener to check if the 3gp is loaded...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. vidView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()  {
  2.  
  3.                 @Override
  4.  
  5.                 public void onPrepared(MediaPlayer mp) {                         
  6.  
  7.                  long mediatime = vidView.getDuration();//this returned the duration instead of -1
  8.  
  9.                      }
  10.  
  11.          });
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Haven't tried with mp4 file..
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Postby hkswaroop » Tue Jun 16, 2009 9:06 am

Thanks sowmya. it solved my problem, i have been looking for this.
hkswaroop
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed May 20, 2009 8:15 am
Location: Bangalore

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 13 guests