Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getduration from media object.



Hi,

I am trying to fetch duration of streams, I am
fetching duration for some streams, but for some
streams it is throwing StdQTException, I guess most of
the new streams are throwing exception. Here I have
given code. 

Can anyone help me please, how can I fetch the
duration for all streams and can you please point me
where I have committed mistake.

#for following streams, it is working.
http://southafrica.indymedia.org/uploads/save_da_world.mov
http://media.warnerbros.com/wbmovies/thein-laws/tvspots/tvspot_2_hi_a.mov

#not working
http://movies.apple.com/movies/magnolia_pictures/nine_lives/nine_lives_h.480.mov
http://movies.apple.com/movies/wb/syriana/syriana_h.320.mov

Exception stacktrace
====================
quicktime.std.StdQTException[QTJava:6.1.3g1],-9461=Unknown
Error Code,QT.vers:7038000
	at
quicktime.std.StdQTException.checkError(StdQTException.java:38)
	at
quicktime.std.movies.media.Media.getDuration(Media.java:356)
	at Duration.main(Duration.java:30)


import quicktime.QTSession;
import quicktime.std.StdQTConstants;
import quicktime.std.StdQTConstants4;
import quicktime.std.movies.Movie;
import quicktime.std.movies.Track;
import quicktime.std.movies.media.DataRef;
import quicktime.std.movies.media.Media;

public class Duration {

    public static void main(String[] args) {
	try{
	    QTSession.open();
	    Movie movie = null;
	    DataRef urlMovie = new DataRef(args[0]);
	    movie = Movie.fromDataRef(urlMovie,
		StdQTConstants4.newMovieAsyncOK|
		StdQTConstants.newMovieActive | 
		StdQTConstants.newMovieDontAskUnresolvedDataRefs);
	    
	    while(movie.maxLoadedTimeInMovie() == 0){
	        // 0 or 100
		movie.task(100);
	    }
	    
	    int trackNo = 1;
	    while (trackNo <= movie.getTrackCount()) {

		//I need audio and video tracks
		Track track = movie.getIndTrack(trackNo);
		Media media  = track.getMedia();
		System.out.println("Duration :                      
                            "+media.getDuration());
		trackNo++;
	    }
	}catch(Exception e){
		e.printStackTrace();
	}
   }
}


Thakns
Ravi.


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-java mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-java/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.