关于网友提出的“ NokiaS60播放midi的问题”问题疑问,本网通过在网上对“ NokiaS60播放midi的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: NokiaS60播放midi的问题
描述: 播放一个较长的midi,在处于STARTED状态时,用stop & deallocate将它停掉,然后再用start从头播放。
但在nokia NGage/QD/7610/3230等机器中运行,无法听到声音。
如果将该Player close掉,再重新load另一个midi可以播放,但重新load刚被关掉的该midi则还是听不见声音。
谁遇到过这个情况,且解决了的,请发邮件到 happyfirecn@yahoo.com.cn
另外送分,越快越好!最多送500分!
谢谢!
解决方案1: 如果咱们在自己程序里写了midp文档里规定不应该写的东西,那结果就不可预料了
CLOSED state
Calling close on the Player puts it in the CLOSED state. In the CLOSED state, the Player has released most of its resources and must not be used again.
你找到这段话,是对player的描述,下面还画了个状态转换图,CLOSE是最终的状态,只能从其他状态转换到CLOSE状态,不能从CLOSE状态转到其他状态
根据midp文档,close()之后,就不能再使用了
解决方案2: 我就
catch(Excetpion e)
{
}
然后就在里面用一个Alert把e.toString()显示出来,上面写的就是显示的结果,我用的是nokia6630
直接从文件怎么载入资源的
createPlayer("res://xxx.mid") ?
解决方案3: 我用我的nokia 6630试了一下
我个人认为close掉,是没法重新从开始播放的,因为取得的资源是不支持reset的
资源的取得 Object.getClass().getResourceAsStream("url")取得的资源类型是InputStream
InputStream有个markSupported()方法,这样取得的资源markSupported返回false
就是调用reset无法回到资源的开头,无法重新播放的.
只有对这个资源调用close()之后,然后Object.getClass().getResourceAsStream("url")重新取得,重新createPlayer才能播放
这种说法是对的,而且你那种写法“用stop & deallocate将它停掉,然后再用start从头播放”会抛出一个异常,media.MediaException: Symbian OS error: -5
我试了一下如果不重载如资源,就无法重新播放
另外我看到midp文档里的一段话这样写着
CLOSED state
Calling close on the Player puts it in the CLOSED state. In the CLOSED state, the Player has released most of its resources and must not be used again.
解决方案4: 个人认为要replay,输入的InputStream必须支持reset,就是markSupported()返回true
可以把取得资源里所有的数据读取到byte[]数组里,然后,用这个byte[]再创建一个ByteArrayInputStream,用这个stream作为播放资源,这样就可以replay了
但是你的midi比较大
解决方案5: 你是如何load资源的
/>
static Player createPlayer(String locator)
还是
static Player createPlayer(InputStream stream, String type)
player close掉后,你是如何reload这个资源的?
我个人认为close掉,是没法重新从开始播放的,因为取得的资源是不支持reset的
资源的取得 Object.getClass().getResourceAsStream("url")取得的资源类型是InputStream
InputStream有个markSupported()方法,这样取得的资源markSupported返回false
就是调用reset无法回到资源的开头,无法重新播放的.
只有对这个资源调用close()之后,然后Object.getClass().getResourceAsStream("url")重新取得,重新createPlayer才能播放
关于取得得资源调用reseet无效,我是试过的,调用read之后,调用reset,然后再调用read,取得的还是下一个字节
只是我的猜想,我今晚回去试试
解决方案6: /**
* 播放背景音乐
*/
public void playMusic() {
try {
if (isMusic && midiPlayer != null) {
midiPlayer.start();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* 停止播放背景音乐
*/
public void stopMusic() {
try {
midiPlayer.stop();
} catch (Exception ex) {
ex.printStackTrace();
}
}
以上的代码在7610上是没问题的
PS:
QD和7650不是合并成一个系列,7650不支持midi,所以只能用数组吗?
解决方案7: 声音是令人头疼的问题。不同的机器会出现不同的效果
以上介绍了“ NokiaS60播放midi的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2025422.html