QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
QuickTime Kit Programming Guide - filibeto.org
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
C H A P T E R 6<br />
Adding Multimedia Playback Capability<br />
}<br />
4. Define the actions you need before the @end directive in order to show movies in your window<br />
and to show the window itself:<br />
- (IBAction)doSetMovies:(id)sender;<br />
- (IBAction)doShowViewTestsWindow:(id)sender;<br />
That’s it. Save your ViewTestsController.h file.<br />
Adding Code To Your ViewTestController.m<br />
In this next sequence of steps, you’ll be adding a larger chunk of code to your ViewTestsController.m<br />
implementation file.<br />
To begin, in your QT<strong>Kit</strong>Player project, choose File > New File. In the Assistant window for your new<br />
file in Xcode 2.0, select Cocoa > Objective-C class and in the window that opens enter the title<br />
ViewTestsController.m . Now follow these steps<br />
1. Insert the following import line at the beginning of your file:<br />
#import "ViewTestsController.h"<br />
2. Following your import statement, you want to add this line:<br />
@implementation ViewTestsController<br />
3. You want to be notified when the window is closing so you can do a cleanup. Insert these lines<br />
of code:<br />
-(void)awakeFromNib<br />
{<br />
[ [NSNotificationCenter defaultCenter]<br />
addObserver:self selector:@selector(closeWin:)<br />
name:NSWindowWillCloseNotification object:mViewTestsWindow ];<br />
}<br />
4. Add this next block to specify if the movie is playing or not. If the movie is currently playing, it<br />
returns YES. If not, it returns NO.<br />
-(BOOL)isPlaying:(QTMovie *)aMovie<br />
{<br />
if ([aMovie rate == 0)<br />
{<br />
return NO;<br />
}<br />
return YES:<br />
}<br />
5. Next, you need to add code to stop the movie from playing. Add these lines:<br />
-(void)stopPlayingMovie:(QTMovie *)aMovie<br />
{<br />
if ([self isPlaying:aMovie] == YES)<br />
{<br />
114 Adding Code To Display and Playback Multimedia<br />
2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.