This article is the fourth part of the BlackBerry Application Development Guide-using audio.
Play a supported audio format tune
On BlackBerry devices that support standard audio formats, you can play audio files in one of the following formats:
◆ Audio/MPEG-1 Layer 3
◆ Audio/midi
◆ Audio/x-midi
◆ Audio/mid
BlackBerry devices use the Mobile Media APIjavax. microedition. media package to support standard audio file formats.
To determine the supported audio format at runtime, Call Manager. getSupportedContentTypes ()..
Voice Recording API
In the net. rim. device. api. system package, the voice recording API consists of the following three methods:
◆ Audio. playFile (int audioCodec, int fs, String fileName)
◆ Audio. recordFile (int audioCodec, int fs, String fileName)
◆ Audio. stopFile (int audioCodec, int fs, String fileName)
Each method accepts an encoding, a file system, and a file name. Audio Recording encoding is performed by Audio. AUDIO_CODEC_VOICENOTE. The iDEN file system is represented by net. rim. device. api. io. FILESYSTEM_PATRIOT. A file system is a common file system. Therefore, a file name parameter consists of a file name without a path name. When the recording, playback, or stop operation fails or is completed, the application should register an audio listener to receive these messages.
To register a listener, implement net. rim. device. api. system. AudioFileListener. Register by calling Audio. addListener (Application, AudioListener.
Note: the size of the file system is about KB, which restricts the recording length. The size is about 8 to 9 seconds. If the recording size exceeds the file system size, the recording will stop and save the file .)