📄 midiplayer.c
字号:
/*===========================================================================
FILE: MIDIPlayer.c
SERVICES: Sample MIDI Player applet showing usage of AEE ISoundPlayer interface
DESCRIPTION
This file contains the implementation of a MIDI Player applet using the
AEE ISoundPlayer interface services.
To use the services of ISoundPlayer interface, perform the following steps:
--------------------------------------------------------------------------
1. Create the ISoundPlayer object by calling ISHELL_CreateInstance() with
AEECLSID_SOUNDPLAYER as class id. This operation is preferably done in
the applet event handler
2. Register the ISoundPlayer callback function. ISoundPlayer interface always
uses this callback function to notify the applet of any events or status
changes. There are primarily four types of callback sent from ISoundPlayer:
AEE_SOUNDPLAYER_PLAY_CB, AEE_SOUNDPLAYER_SOUND_CB, AEE_SOUNDPLAYER_STATUS_CB,
AEE_SOUNDPLAYER_TIME_CB.
Each callback type, in turn, will
contain a set of status indications that are only valid to that callback.
For example, for AEE_SOUNDPLAYER_PLAY_CB, the status type can be
AEE_SOUNDPLAYER_SUCCESS, AEE_SOUNDPLAYER_PAUSE, AEE_SOUNDPLAYER_RESUME, etc.
See SoundPlayerCBFn() and UpdatePlay() functions in this example.
3. Set the source of the MIDI media (file/buffer/MIME) using ISOUNDPLAYER_Set() API
4. In the applet event handler, call
ISOUNDPLAYER_Play(): To play the MIDI file. Specify full path name of the file.
ISOUNDPLAYER_Stop(): To stop the playback
ISOUNDPLAYER_Rewind(): To rewind playback for n milliseconds
ISOUNDPLAYER_FastForward(): To fast forward playback for n milliseconds
ISOUNDPLAYER_Pause(): To pause the playback
ISOUNDPLAYER_Resume: To resume the playback
5. Always call ISOUNDPLAYER_Stop() before exit. Call it in EVT_APP_STOP.
6. More on callback:
1. During playback, every second, applet is notified of AEE_SOUNDPLAYER_TICK_UPDATE status
via AEE_SOUNDPLAYER_PLAY_CB. This can be used by applet to update the progress
of playback.
2. After rewind, fforward, pause or resume, the dwParam of AEE_SOUNDPLAYER_PLAY_CB
callback function points to the current position, in milliseconds, of the play.
Again, applet can use this to update the playback progress
These mechanisms are demonstrated in this applet for rewind and fforward.
PUBLIC CLASSES:
N/A
INITIALIZATION AND SEQUENCING REQUIREMENTS:
The following explanation applies to this sample containing one applet which serves
as a base for app developers to create their own applets using AEE Services:
In the applet source file (like this one), include AEEAppGen.h.
Mandatory Sections in Applet Source (this file):
-----------------------------------------------
Following Mandatory Sections are required for each applet source file.
(Search for "Mandatory" to identify these sections)
Includes:
Copy this section as-is from the sample applet. It contains:
AEEAppGen.h: For AEEApplet declaration
Type Declarations:
A data structure must be defined to hold the app specific data. In this structure,
the first element must be of type AEEApplet.
Functions: (For more details, see corresponding function description in this applet)
App_HandleEvent(): is the Event Handler to this applet.
Copy the function outline from the sample applet and add app specific code.
AEEClsCreateInstance(): creates an instance of the applet and initializes it.
It is called by AEEModGen when applet is being created.
Important Notes:
---------------
1. DO NOT use any "static data" in the applet. Always use the functions exported by
AEEStdlib or by IHeap services to dynamically allocate data and make it a member of
the applet structure.
2. DO NOT include and link "standard C library". Use AEE Memory Services (in AEEHeap.h) and Standard Library macros(in AEEStdLib.h).
For example, use MALLOC() to allocate memory, WSTRCPY() to make a copy of Unicode (wide) string.
3. BREW is Unicode(wide string) compliant ONLY (no ISOLATIN1/ANSI) except for file names which are ISOLATIN1/ANSI.
ALWAYS USE AECHAR instead of "char". Use string services provided in AEEStdLib.h for string manipulation.
4. It is always a good idea to DEFINE RESOURCES using BREW ResourceEditor. Make Strings, Bitmaps, Dialogs, etc.
as resources. ResourceEditor saves resources as .bri file, generates resource header file
and compiles .bri into a .bar binary file, which can be used by the applet.
Miscellanoeus Notes:
-------------------
1. Make sure that the class ID used for the app is the same as that defined corresponding in .MIF file
2. Always make sure that compiled resource (.bar) file and corresponding
resource header (a) reside in app directory and (b) are included in the applet code.
Define a constant APP_RES_FILE containing the name of the compiled resource file (with .bar extension).
More than one applet:
--------------------
If more than one applet needs to be defined, then do the following
(1) Follow the above description for each applet
Copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -