TealMovie Launch Commands

TealMovie supports a few launch commands which can be used to start the app
externally and use it to play movies from other applications.


sysAppLaunchCmdGoTo

This mechanism uses the standard system command intended to launch a program
in response to a global find, but may also be used to launch TealMovie with
a given movie or sound file.  Parameters are passed in a standard 
GoToParamsType structure with the following parameters:

	dbCardNo	- card of the document to open
	dbID		- LocalID of the document to open
	matchCustom	- Creator ID of the program to return to after
	           	  playing the movie or 0.

	set all other fields to zero

To play a movie from an SD card, set dbCardNo and dbID both to -1, and append
a null-terminated path to the movie file to the end of the structure.


sysAppLaunchCmdOpenDB

The openDB command, added in Palm OS 3.x, is similar, but cannot return to
the original application after playback.

	cardNo		- memory card of the document to open
	dbID		- LocalID of the document to open

To play a movie from an SD card, set cardNo and dbID both to -1, and append
a null-terminated path to the movie file to the end of the structure.


Note:  Use the PalmOS function SysUIAppSwitch() to launch the program.
The structures you pass to TealDoc must be allocated in RAM whose
owner field has been set to 0 or they will be freed when your application
exits.

Sample Code:

//
// Example usage
//
// PlayMovie( "/movies/tealpoint.pdb", 'TlBS', true );
//
// PlayMovie( "tealpoint", 'TlBS', false );
//

int PlayMovie( char *movie, long return_crid, Boolean is_vfs )
{
	UInt    card;
	LocalID dbid;
	static DmSearchStateType sst;
	GoToParamsType *gp;
	
	if ( !DmGetNextDatabaseByTypeCreator( 
				true, &sst, (ULong)'appl', (ULong)'TlMv', true, &card, &dbid )) {

		if (gp = MemPtrNew( sizeof(GoToParamsType) + StrLen(movie)+1)) {

			// set 'owner' to 0 (system) so chunk doesn't get freed on exit

			MemPtrSetOwner( gp, 0 );

			MemSet( gp, sizeof(*gp), 0 );

			gp->matchCustom = return_crid;
			StrCopy( (char *)&gp[1], movie );

			if (is_vfs) {
				gp->dbCardNo = -1;
				gp->dbID = (LocalID) -1;
			} else {
				for (gp->dbCardNo=0; gp->dbCardNo < MemNumCards() && !gp->dbID; gp->dbCardNo++) {
					if (gp->dbID = DmFindDatabase( gp->dbID, movie )) break;
				}
			}
			if (gp->dbID) {
				SysUIAppSwitch( card, dbid, sysAppLaunchCmdGoTo, (void *)gp );
				return 0;
			}
			MemPtrFree( gp );
			return -1;
		}
		return -2;
	}
	return -3;
}