Playing video in queue

Discussion in 'Mac Programming' started by Binju, Mar 30, 2010.

  1. Binju macrumors member

    Jan 31, 2010
    I want to play videos continuously(video1, video2,video3...)

    I used the below code

    for(int i=1;i<=n;)
         NSString *movieName = [NSString stringWithFormat:@"video%d", i];
    	NSString*   movieFile = [[NSBundle mainBundle] pathForResource:movieName ofType:@"mov"];
    	QTMovie*    aMovie = [QTMovie movieWithFile:movieFile error:nil];
    	[mMovieView setMovie:aMovie];
    	[aMovie autoplay];
    It always play the nth video only.
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    [aMovie autoplay]
    block? I've never used QTMovie but I'd be amazed if it did. I suspect it just starts the movie playing and returns control to your code: you need to detect the end of the movie (there are probably delegate methods for this) and then request the next movie.

    Note this is all speculation: I've not opened the QTMovie documentation but I suggest you do.
  3. Binju thread starter macrumors member

    Jan 31, 2010
    I gone through the documentation,I cannot find the method to find the end of the movie
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    What did you try, exactly?

    I used the simplest approach I could imagine, and in less than 2 minutes found a delegate method and a notification.

    First, I googled for: qtmovie reference

    That took me to Apple's reference webpage:

    I then looked at the section on delegate methods, as previously suggested by robbieduncan. One of the delegate methods is called at the begin, update, and end phases of the movie. There are only four delegate methods, so it shouldn't be hard to figure out which one.

    There is also a notification documented in the section on notifications, that is sent when the movie ends. Its name follows the normal Cocoa naming pattern, and contains "DidEnd".

Share This Page