Look into it ~

present
随笔 - 32, 文章 - 0, 评论 - 3, 引用 - 0
数据加载中……

Using simultaneous sounds

The code sample below describes how to play two sounds at the same time. This feature is supported by the Sony Ericsson JP-5 platform and onwards.

Only one wav file can be played simultaniously but several midi files might be played at the same time. 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. The example below shows how to do this using one midi file and one wav file.

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();

example code

posted on 2008-08-15 10:34 LukeW 阅读(117) 评论(0)  编辑  收藏 所属分类: Tips, Tricks, Hints & Code


只有注册用户登录后才能发表评论。


网站导航: