Looping a QuickTime Movie - major cocoa to ASOBJC syntax headache

Hi All

I am going in circles at the moment, trying to loop a QT movie. Opening and playing the movie is not an issue, just the loop. All my searches lead me to the same code ( cocoa ) and I have tried to translate to asobjc but have to throw the towel in on this one.

QTMovieLoopsAttribute needs to be set to YES and as per the QTMovie.h file,

Apple’s site also referred me to the following cocoa code that is similar to what i want to achieve

  • (void)windowControllerDidLoadNib:(NSWindowController *) aController
    {
    [super windowControllerDidLoadNib:aController];
    if ([self fileName]) {
    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
    [self fileName], QTMovieFileNameAttribute,
    [[NSNumber numberWithBool:YES],
    QTMovieOpenForPlaybackAttribute, nil];
    movie = [[QTMovie alloc] initWithAttributes:attributes error:NULL];
    [movieView setMovie:movie];
    [movie release];
    [[movieView movie] play];
    }
    }
set pMovie to current application's QTMovie's alloc()'s initWithFile_(POSIX path of (choose file))

This works but i suspect it is not 100% correct.

Any help would be greatly appreciated !
Regards

Paul

Try this:

set pathToMovie to POSIX path of (choose file)
tell current application's NSDictionary to set theAtts to dictionaryWithObjects_forKeys_({pathToMovie, true, true}, {current application's QTMovieFileNameAttribute, current application's QTMovieOpenForPlaybackAttribute, current application's QTMovieLoopsAttribute})
set theMovie to current application's QTMovie's alloc()'s initWithAttributes_error_(theAtts, missing value)
movieView's setMovie_(theMovie)
tell movieView's movie() to play()

Big Thanks!! - Looping like a charm!

FYI - The movie would not play automatically. I reverted to my previous code ( play_(me)) to play and still did not play.I then added a delay command inbetween setMovie_(theMovie) and play and it played automatically.

Do you think it could be something to do with load state of the movie?

I am going to play around with QTMovieLoadStateComplete and see if that does the trick.

Once again, thanks! Now that I can compare how your code translates to the cocoa methods, I am hoping that all the other frameworks oddities will start to make a bit more sense !

Regards

Paul
( Veteran MacroMedia Lingo programmer )

UPDATE

I used autoplay() instead of play() - That works