Help with QT in Cocoa

Discussion in 'Mac Programming' started by, Nov 14, 2006.

  1. macrumors newbie

    Nov 14, 2006
    I'm trying to incorporate a static QT view into a project that I am building. Specifically, I want the movie to launch in a specific area, in fact on top of a a custom view. So far, this works.

    - Two problems:

    • After importing a movie, I engage play, and the video is not present *unless* I click away from the application UI. It then appears. Keep in mind that I stress video. The audio plays with no problem as soon as I engage playback right from the get go.

    I have 'preserve aspect ratio' selected in the QTMovie view properties.

    Here is my second issue:

    • I have 2 movies with the same aspect ratio, in this case 360 x 202. When the first movie completes, I import the second movie with no problems. A replacement occurs.

    If I import a movie with a scaled 4 x 3 aspect ratio, a second instance of QTMovie view appears on top of the previous instance. It appears that the 4x3 movie is laying on top on the previous movie, without 'replacing it.

    This only happens when I move form a scaled 16x9 to a scaled 4x3 aspect ratio example.

    Can someone take a llok at this? Thanks. [ptfigg].

    /* QtController */

    #import <Cocoa/Cocoa.h>
    #import <QuickTime/Movies.h>
    #import <QTKit/QTKit.h>

    @interface QtController : NSObject
    IBOutlet QTMovieView *movieView;
    IBOutlet id window;
    - (IBAction)Open:(id)sender;

    * * * * *

    #import "QtController.h"

    @implementation QtController
    QTMovie* qtMovie;

    - (IBAction)Open:(id)sender


    NSArray* fileTypes = [NSArray arrayWithObjects:mad:"mov", @"mp4",
    @"m4a", @"mp3", @"m4p",
    @"jpg", @"jpeg",nil];
    NSString* moviesDir = [NSHomeDirectory() stringByAppendingString:
    [NSString stringWithString: @"/Movies"]];
    // ...
    NSOpenPanel* panel = [NSOpenPanel openPanel];
    [panel runModalForDirectory:moviesDir file:nil types:fileTypes ];
    NSURL* url = [[panel URLs] objectAtIndex: 0];

    NSError* openError = nil;
    qtMovie = [QTMovie movieWithURL: url error:&openError];

    [movieView setControllerVisible: YES];
    [movieView setMovie: qtMovie];

  2. HiRez macrumors 603


    Jan 6, 2004
    Western US
    You could try something like this:
    [movieView lockFocus];
    [[NSColor blackColor] set];
    NSRectFill([movieView bounds]);
    [movieView unlockFocus];
    to clear the view before loading a new movie. Since NSMovieView inherits from NSView, this may work.

Share This Page