In (1), the function of detecting e680i music playing ability is realized, and a sequence of musical notes is played at the appropriate time. Of course, in the game it is generally not used in such a simple tone, but rather a more expressive midi or other sound format. The same simple way to play these files. This time we implemented a simple music player to enable playback of these files.
First, take a look at the steps to play a music file:
1. Get the input stream of the sound file, GetClass (). getResourceAsStream (String);
2, create the player according to the format of the sound file, Manager.createplayer (InputStream, String);
3. Call the player's Prefectch () method to reduce playback lag
4. Call the Start () method to start playback
5. Turn off the player, close ().
Second, there may be some auxiliary methods used in the process of playing a sound file:
1, setloopcount (int), set the number of times the loop plays, where 1 is the loop playing all the time
2, Getduration (), get the total length of the sound file
3, Getmediatime (), get the current playback time
4, Setmeidatime (long), set the current playback time
5, GetControl (String), to obtain some type of controller, in the program used to Volumecontrol
The example of this article is still tested on e680i.
The following is the result of the program running on the emulator:
Http://download1.csdn.net/down3/20070615/15092215160.gif
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.