It turned out that it didn't like to instantiate an NSViewControl class in its xib. So, instead, I created it in the code and it made "loadView" returns.
However, I still have some problems. Although audio is played, video is not played. So, I changed its view class for setting player like this ( by refering ViewController sample codes ) - (void) setPlayer:(AVPlayer *)player { // [(AVPlayerLayer *)[self layer] setPlayer:player]; AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; [playerLayer setFrame:[self.layer bounds]]; [playerLayer setAutoresizingMask:(kCALayerWidthSizable | kCALayerHeightSizable)]; [self setLayer:playerLayer]; } However, it still doesn't display any video frame. Any ideas? FYI, This is how it looks in ViewController sample codes : Thank you. - (void)awakeFromNib { NSString* moviePathStr = [[NSBundle mainBundle] pathForResource:@"adam" ofType:@"mov"]; player = [[AVPlayer alloc] init]; AVURLAsset *file = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:moviePathStr isDirectory:NO]]; [file loadValuesAsynchronouslyForKeys:nil completionHandler:^(void) { // The asset invokes its completion handler on an arbitrary queue when loading is complete. // Because we want to access our AVPlayer in our ensuing set-up, we must dispatch our handler to the main queue. dispatch_async(dispatch_get_main_queue(), ^(void) { // Create an AVPlayerLayer and add it to the player view if there is video, but hide it until it's ready for display AVPlayerLayer *newPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; [newPlayerLayer setFrame:[[self.view layer] bounds]]; [newPlayerLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; [[self.view layer] addSublayer:newPlayerLayer]; // Create a new AVPlayerItem and make it our player's current item. AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:file]; [player replaceCurrentItemWithPlayerItem:playerItem]; playingForward = YES; [[NSNotificationCenter defaultCenter] addObserverForName:AVPlayerItemDidPlayToEndTimeNotification object:playerItem queue:nil usingBlock:^(NSNotification *note) { if(playingForward) { [player seekToTime:CMTimeMultiplyByFloat64(playerItem.duration, 0.99f)]; [player play]; player.rate = -1; playingForward = NO; } else { [player seekToTime:kCMTimeZero]; [player play]; player.rate = 1; playingForward = YES; } }]; [player play]; [player release]; }); }]; } On Nov 4, 2011, at 9:46 AM, JongAm Park wrote: > > Hello, > > I tried to use AV Foundation's playback capability. > So, by following AV Foundation Programming Guideline, it wrote codes for Mac. > ( The document is written for iOS. ) > Also, I looked up "View Controller" sample codes and "AnimatedTableView". > > What is strange is that it doesn't return after loadView was called in my > testing project, although it does in those sample codes. > I didn't find any semantic difference yet. > > This is from my sample codes : > > An app delegate class : > > - (void)applicationDidFinishLaunching:(NSNotification *)aNotification > { > // Insert code here to initialize your application > > NSLog( @"AppDelegate >> applicationDidFinishLaunching" ); > > [_placeholderView addSubview:_viewController.view]; => calls loadView > of a child class of NSViewController > [_viewController.view setFrame:_placeholderView.frame]; > [_viewController setRepresentedObject:[NSNumber > numberWithUnsignedLong:[[_viewController.view subviews] count]]]; > } > > > The child class of NSViewController > > - (void)loadView > { > [self viewWillLoad]; > [super loadView]; <= doesn't return > [self viewDidLoad]; > } > > Does anyone know why the loadView doesn't return? > Can you spare me your idea? > > Thank you. > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com