Header Sep
Java Tips, Tricks & Code
我的评分 用户评价
登录票选本页

April 2004
Using simultaneous sounds

[Back]

The code sample below describes how to play two sounds at the same time. This feature is supported by the Sony Ericsson V800, Z800, K750, W800 and K600 series of phones.

In these phones the number of existing players is only limited by available memory, and you have the possibility to play more than one player at the same time. To do this you need to use one midi file and one wav file. The wav file must have a sample rate of 8 or 16 kHz.

The code is straight-forward - just load the resource, create the player and start playing the file.

Here's the sample:

InputStream is = getClass().getResourceAsStream(file);
InputStream is1 = getClass().getResourceAsStream(file1);

player = Manager.createPlayer(is, " audio/midi");
player.setLoopCount(-1);
player.prefetch();
player.realize();

player1 = Manager.createPlayer(is1, "audio/x-wav");
player1.setLoopCount(1);
player1.prefetch();
player1.realize();

player.start();
player1.start();

Download source code>>


我的评分 用户评价
登录票选本页