I am working on a program which has a rigid set of 'stages' for video recording... Think of it like a Video-Booth. I am running the program on OSX Lion, coded entirely in Cocoa.

The 'stages' are as follows:

  1. Welcome Screen
  2. Begin Recording
  3. Playback Video
  4. Confirmation for Saving/Deleting

Stages 1, 2, and 4 work perfectly every time. And Stage 3 works perfectly the FIRST time.

On the second, or later, time of going through the process, the video playback (which is done by a QTMovieView embedded within a NSPanel) is still set to the video from the FIRST run-through.

I have two methods set-up, one which is activated by a button press, the other by other code in the program. BOTH of these methods DO FIRE, I am positive. What I don't know is why [mPlaybackView setMovie: lclMov] is not setting the new movie...

To clarify (based on the code below):

  • I HAVE looked prior to starting the playback to make sure the file at TEMP_STORE actually exists (and is the new file, not the old one)
  • I HAVE also tried replacing [QTMovie movieWithFile:TEMP_STORE error:&err]; with [[QTMovie alloc] initWithFile:TEMP_STORE error:&err] (as per a recommendation I saw online somewhere)
  • The file at TEMP_STORE is a '.mov' file recorded by another code segment in my program

Any and all help is appreciated!!!

CODE

- (IBAction) startPlayback: (id) sender {
    NSError *err;
    QTMovie *lclMov = [QTMovie movieWithFile:TEMP_STORE error:&err];

    [instrPlayback orderOut:nil];

    if (err != nil) {
        [errorMessage setStringValue:[NSString stringWithFormat:@"%@", [err localizedDescription]]];
        [errorDialog makeKeyAndOrderFront:nil];
    } else {
        [self writeString: CMD_PROCEED];

        [mPlaybackView setMovie:lclMov];
        [mPlaybackView gotoBeginning:nil];
        [playbackDialog makeKeyAndOrderFront:nil];
    }
}

- (void) stopPlayback {
    QTMovie *lclMov = [mPlaybackView movie];
    if ([lclMov canUpdateMovieFile]) {
        if (![lclMov updateMovieFile]) {
            [errorMessage setStringValue:@"Error Applying Updates to MOV File.\nAsk Lab Attendant for Help."];
            [errorDialog makeKeyAndOrderFront:nil];
            }
        }

        [playbackDialog orderOut:nil];
}
有帮助吗?

解决方案

To people who come upon this in the future, here was my soltuion:

I guess I was being sort of dumb ... but I knew it had something to do with deallocating the video from memory. My resulting solution was to import the QuickTime framework (which, as I had not a clue, was different than the QTKit framework) and use the DisposeMovie() method from Movies.h

Such a simple solution, and it gave me so much trouble.

Good luck to all the developers out there who may run into this same problem :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top