home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-27 | 7.4 KB | 235 lines | [TEXT/CWIE] |
- // This project was made using Code Warrior 10
-
- // This project shows a way to play a movie in a pane by specifying just the file name.
- // No movie controller is used. The project also uses a custom type CPPb resource in
- // Constructor. I modified some code from the book "Ultimate Mac Programming" by Dave Mark,
- // from the program "Very Simple Player" by Peter Hoddie.
- // The main goal of this program is to build a library of classes for Multi-Media use.
- // As soon as I have better code, I will release it.
-
- // I am not a professional programmer. I am a photographer, trying to learn programming.
- // I want nothing for this source code except the hope that it may help someone like me
- // who is trying to learn this endless maze of languages, styles, and class libraries that
- // is Macintosh Programming. This is my first full-fledged Power Plant App. I started with
- // the basic Power Plant project and using code from some of the examples provided on the disk
- // and from the above mentioned book.
-
- // I want to thank John Daub at MetroWerks for his help on this project.
- // The amount of personal help that is available for Macintosh programmers is way out
- // of balance in comparison to what is available to Dos and Windows programmers, at least
- // for us beginners. If Apple doesn't realize this and start providing better local
- // support, like Macintosh programming classes at colleges etc., it won't matter how good
- // of a machine Apple makes, if no one is writing software for it anymore. The only hope
- // we have right now is companies like MetroWerks who provide such good support and tools
- // and people like John Daub who are willing to take the time to share thier experience.
- // O.K. I'll get off my soap box now! :)
-
-
- // What I am happy about in this program:
- // 1.) The program successfully gets the movie's file name from the CPPb resource and opens
- // the movie from the file name.
- // 2.) The program uses ::ShowMoviePoster() to display the first frame of the movie before
- // actually playing the movie.
- // 3.) The program successfully sends a message from the braodcaster ( the play button )
- // to a listener ( MMovieView ) to play the movie.
-
- // What I am not happy about in this program:
- // 1.) The movie does not play as smooothly as I would like, and the movie poster image
- // is not stable enough, as the poster flashes onto the screen annoyingly during
- // separate play cycles.
- // 2.) The program's memory keeps getting filled even though I call ::DisposeMovie()
- // several times in the program. After a few plays, the app asks to close some
- // windows or other apps.
- // 3.) The MMovieView pane resizes itself, but does not center itself in it's immediate
- // surroundings.
-
-
- // Program by: Earl Schellhous
- // e-mail as of 10/26/96 : szschell@peseta.ucdavis.edu OR monkey@calweb.com
- // If you write a better version, I would appreciate a copy! =)
-
-
- // ===========================================================================
- // MMapp.cp
-
-
- #include "MMapp.h"
- #include "MMovieView.h"
- #include "MMappConstants.h"
-
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
- #include <PP_Resources.h>
- #include <PPobClasses.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
- #include <LEditField.h>
- #include <UReanimator.h>
- #include <LGADefaultPushButton.h>
- #include <UGALibRegistry.h>
-
-
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
-
- MMapp theApp; // replace this with your App type
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------
- // • MMapp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Constructor
-
- MMapp::MMapp()
- {
- // Register functions to create core PowerPlant classes
-
- RegisterAllPPClasses();
- RegisterGALibraryClasses();
- URegistrar::RegisterClass( MMovieView::class_ID,
- (ClassCreatorFunc) MMovieView::CreateMoviePaneStream );
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~MMapp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- MMapp::~MMapp()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // This function lets you do something when the application starts up
- // without a document. For example, you could issue your own new command.
-
- void
- MMapp::StartUp()
- {
- ObeyCommand(cmd_New, nil); // EXAMPLE, create a new window
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- MMapp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // Deal with command messages (defined in PP_Messages.h).
- // Any that you don't handle will be passed to LApplication
-
- case cmd_New:
- {
- // EXAMPLE, create a new window
-
- MM_Window = LWindow::CreateWindow( kPPob_Main_Window, this );
-
- // link the listener to the controls
- UReanimator::LinkListenerToControls( this, MM_Window, kRidL_Main_Window );
-
- // Get the button.
- LGADefaultPushButton *thePlayButton;
- thePlayButton = (LGADefaultPushButton *) MM_Window->FindPaneByID( kPlayButton );
-
- // Get the Movie View Pane and make it listen to the button
- MMovieView *theMoviePane;
- theMoviePane = (MMovieView *) MM_Window->FindPaneByID( kMoviePane );
- thePlayButton->AddListener( theMoviePane );
-
- MM_Window->Show();
- break;
- }
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // This function enables menu commands.
- //
-
- void
- MMapp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
-
- switch (inCommand) {
-
- // Return menu item status according to command messages.
- // Any that you don't handle will be passed to LApplication
-
- case cmd_New: // EXAMPLE
- outEnabled = true; // enable the New command
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- void
- MMapp::ListenToMessage(MessageT theMessage, void *ioParam)
- {
- #pragma unused (ioParam )
-
- MMovieView *moviePane;
-
- switch( theMessage )
- {
- case msg_PlayMovie:
- {
- /* I'm not really sure if this does anything at all here =) */
- moviePane = (MMovieView *)MM_Window->FindPaneByID( kMoviePane );
- moviePane->Show();
- moviePane->Activate();
- break;
- }
- }
- }
-