device://midi是怎么使用的啊?

stamp80 2005-12-12 12:58:07
在mmapi(jsr 135)中,以“device://midi”方式创建的player是如何播放midi的呢?谢谢
------------------------------------
...全文
156 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhengyun_ustc 2005-12-12
  • 打赏
  • 举报
回复
在代码中可以找到如何播放MIDI、MP3、wav、以及Nokia定义的Sounds数组的细节。

源代码下载说明:

下载midlet:TwinsMusic-Effect1-deployed.rar ,大约26KB。
http://www.cnblogs.com/Files/zhengyun_ustc/TwinsMusic-Effect1-deployed.rar


代码TwinsMusic-Effect1.rar,大约65KB。
http://www.cnblogs.com/Files/zhengyun_ustc/TwinsMusic-Effect1.rar
以及
http://www.cnblogs.com/Files/zhengyun_ustc/TwinsMusic-Effect2-withNokiaUIAPISound.rar

zhengyun_ustc 2005-12-12
  • 打赏
  • 举报
回复
// 播放jazz.midi文件音乐
/*
* 用createPlayer的方式播放背景音效
*/
m_Audio.playSound(Audio.MUSIC);

而Audio封装了player调用的细节,你可以从http://www.cnblogs.com/Files/zhengyun_ustc/TwinsMusic-Effect2-withNokiaUIAPISound.rar和http://www.cnblogs.com/Files/zhengyun_ustc/TwinsMusic-Effect1.rar下载我的源代码,
更多信息可看http://www.cnblogs.com/zhengyun_ustc/archive/2005/11/23/playsounds2.html:
public class Audio implements PlayerListener
{
。。。。

/**
* Creates a player for specified sound
* and popuplates the Player array.
* @param snd The sound to create
*/
protected void createSound(int snd) throws Exception
{
System.out.println("Audio::createSound snd>>" + snd);

{
int rsc = 0;
String type = TYPE_MIDI;
switch(snd)
{
case MUSIC:
rsc = CommandResources.SND_JAZZY;
break;
case BEEP:
type = TYPE_WAVE;
rsc = CommandResources.SND_WAVE_BEEP;
break;
case END:
type = TYPE_WAVE;
rsc = CommandResources.SND_WAVE_END;
break;
case TIMEOUT:
type = TYPE_WAVE;
rsc = CommandResources.SND_WAVE_TIMEOUT;
break;
case XUXU:
type = TYPE_WAVE;
rsc = CommandResources.SND_WAVE_XUXU;
break;
case CHANGJIN:
type = TYPE_AMR;
rsc = CommandResources.SND_AMR_CHANGJIN;
break;
case MESSAGE:
type = TYPE_MIDI;
rsc = CommandResources.SND_MESSAGE;
break;
}

InputStream isInputMusic = CommandResources.getResource(rsc);
if(isInputMusic != null)
{
System.out.println("Audio::createSound createPlayer Begin:" + type);
m_sounds[snd] =
Manager.createPlayer(isInputMusic, type);
System.out.println("Audio::createSound createPlayer End");
if (snd == MUSIC || snd == CHANGJIN)
{
System.out.println("loop intro tune for ever and ever!");
m_sounds[snd].setLoopCount(-1); // loop intro tune for ever and ever
m_sounds[snd].realize();
// Set Volume.
VolumeControl volume = (VolumeControl)
m_sounds[snd].getControl("VolumeControl");
if (volume != null)
volume.setLevel(35);// 小点声!!
}
}
else
{
System.out.println("ERROR!Cannot find music resource!");
}

}
}
。。。。

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧