02.04.2013 Views

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C H A P T E R 6<br />

Adding Multimedia Playback Capability<br />

}<br />

}<br />

[aMovie stop];<br />

6. Insert the following code to handle stopping of any currently playing movies and to clear the<br />

movies that were previously set for each view:<br />

- (void)closeWin:(void *)userInfo<br />

{<br />

// stop any currently playing movies<br />

[self stopPlayingMovie:[mSplitViewMovieView1 movie]];<br />

[self stopPlayingMovie:[mSplitViewMovieView2 movie]];<br />

[self stopPlayingMovie:[mSplitViewMovieView3 movie]];<br />

[self stopPlayingMovie:[mTabViewMovieView1 movie]];<br />

[self stopPlayingMovie:[mTabViewMovieView2 movie]];<br />

[self stopPlayingMovie:[mScrollViewMovieView movie]];<br />

}<br />

// clear the movies that were previously set for each view<br />

[mSplitViewMovieView1 setMovie:NULL];<br />

[mSplitViewMovieView2 setMovie:NULL];<br />

[mSplitViewMovieView3 setMovie:NULL];<br />

[mTabViewMovieView1 setMovie:NULL];<br />

[mTabViewMovieView2 setMovie:NULL];<br />

[mScrollViewMovieView setMovie:NULL];<br />

7. To get the movies you want to play and open the panel so the user can choose, insert this chunk<br />

of code:<br />

- (QTMovie *)getAMovieFile<br />

{<br />

NSOpenPanel *openPanel;<br />

openPanel = [NSOpenPanel openPanel];<br />

[openPanel setCanChooseDirectories:NO];<br />

if ([openPanel runModalForTypes:[QTMovie movieUnfilteredFileTypes]] ==<br />

NSOKButton)<br />

{<br />

return [QTMovie movieWithFile:[openPanel filename] error:NULL];<br />

}<br />

return nil;<br />

8. To set the movies, add this chunk of code:<br />

- (IBAction)doSetMovies:(id)sender<br />

// set the movies<br />

[mSplitViewMovieView1 setMovie:[self getAMovieFile]];<br />

[mSplitViewMovieView2 setMovie:[self getAMovieFile]];<br />

[mSplitViewMovieView3 setMovie:[self getAMovieFile]];<br />

[mTabViewMovieView1 setMovie:[self getAMovieFile]];<br />

[mTabViewMovieView2 setMovie:[self getAMovieFile]];<br />

[mScrollViewMovieView setMovie:[self getAMovieFile]];<br />

}<br />

9. To add a toolbar and to show the window, add the following code:<br />

Adding Code To Display and Playback Multimedia 115<br />

2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!