Qml 如何在Blackberry 10 Dev Alpha模拟器中播放SystemSounds?

Qml 如何在Blackberry 10 Dev Alpha模拟器中播放SystemSounds?,qml,blackberry-10,blackberry-cascades,Qml,Blackberry 10,Blackberry Cascades,我只是试着运行提供的示例代码,据我所知,应该可以正常工作。是否有我遗漏的东西,或者这是模拟器的限制 如果有,有什么解决办法吗 导入bb.cascades 1.0 //要使用MediaPlayer,我们必须包括 //多媒体图书馆。 导入bb.1.0多媒体 页面{ 容器{ id:主容器 布局:StackLayout{ 方向:LayoutOrientation.TopToBottom } 加总:50.0 标签{ 编号:TitleBL 文本:qsTr(“SystemSound and MediaPlay

我只是试着运行提供的示例代码,据我所知,应该可以正常工作。是否有我遗漏的东西,或者这是模拟器的限制

如果有,有什么解决办法吗

导入bb.cascades 1.0
//要使用MediaPlayer,我们必须包括
//多媒体图书馆。
导入bb.1.0多媒体
页面{
容器{
id:主容器
布局:StackLayout{
方向:LayoutOrientation.TopToBottom
}
加总:50.0
标签{
编号:TitleBL
文本:qsTr(“SystemSound and MediaPlayer\n示例应用程序”)
多行:正确
textStyle.fontSizeValue:9.0
textStyle.fontWeight:fontWeight.Bold
textStyle.fontFamily:“Verdana”
textStyle.color:color.DarkBlue
textStyle.textAlign:textAlign.Center
水平对齐:水平对齐。居中
}
//示例的第1部分:播放系统声音。
容器{
id:systemSoundsContainer
布局:StackLayout{
方向:LayoutOrientation.TopToBottom
}
topMargin:100.0
水平对齐:水平对齐。居中
下拉列表{
id:SoundSelector下拉列表
标题:“声音:”
最大宽度:600.0
选择权{
文本:qsTr(“电池报警”)
值:SystemSound.BatteryAlarm
所选:真
}
选择权{
文本:qsTr(“浏览器启动”)
值:SystemSound.BrowserStarteEvent
}
选择权{
文本:qsTr(“照相机快门”)
值:SystemSound.CameraShutterEvent
}
选择权{
文本:qsTr(“设备系绳”)
值:SystemSound.DeviceTherEvent
}
选择权{
正文:qsTr(“一般通知”)
值:SystemSound.GeneralNotification
}
}//SoundSelector下拉列表
钮扣{
id:systemSoundPlayButton
文本:qsTr(“播放所选系统声音”)
最小宽度:600.0
再次点击:{
systemSound.play();
}
}//systemSoundPlayButton
}//systemSoundsContainer
//示例的第2部分:播放自定义声音文件。
容器{
id:customSoundsContainer
布局:StackLayout{
方向:LayoutOrientation.LeftToRight
}
topMargin:100.0
钮扣{
id:customSoundPlayButton1
文本:qsTr(“播放声音1”)
layoutProperties:StackLayoutProperties{
空间配额:1.0
}
再次点击:{
//在这里,我们可以创建第二个MediaPlayer对象来
//用于播放我们的声音,但我们以编程方式
//更改了当前myPlayer的sourceUrl属性
//MediaPlayer对象,并重新使用它来播放我们的声音。
myPlayer.setSourceUrl(“asset:///sounds/Doorbell_001.wav")
myPlayer.play()
}
}//customSoundPlayButton1
钮扣{
id:customSoundPlayButton2
文本:qsTr(“播放声音2”)
layoutProperties:StackLayoutProperties{
空间配额:1.0
}
再次点击:{
//和上面一样,这里我们也可以创建第二个
//MediaPlayer对象用于播放我们的声音,但
//我们以编程方式更改了
//当前myPlayer MediaPlayer对象,并将其重新用于
//播放我们的声音。
myPlayer.setSourceUrl(“asset:///sounds/Doorbell_002.wav")
myPlayer.play()
}
}//customSoundPlayButton2
}//customSoundsContainer
}//主容器
//SystemSound和MediaPlayer对象的连接方式如下
//它们可以在我们的QML代码中用于播放声音。
附件对象:[
系统声音{
id:systemSound
声音:soundSelectorDropdown.selectedValue
},
媒体播放器{
id:myPlayer
//sourceUrl:<在按钮控件的onclick事件处理程序中设置。>
}
]//附加对象。
}

来源:

我怀疑系统声音实际上是内部的.mp3或.ogg文件,其中的“”和“”使用.wav文件。这是一个已知的问题,Blackberry开发者论坛已经讨论过,而且模拟器没有正确的编解码器来播放除.wav文件以外的任何声音。声音应该在实际硬件上正确播放。

我怀疑系统声音实际上是内部的.mp3或.ogg文件,其中的“”和“”使用.wav文件。这是一个已知的问题,Blackberry开发者论坛已经讨论过,而且模拟器没有正确的编解码器来播放除.wav文件以外的任何声音。声音应该在实际硬件上正确播放。

我用纯C++结束了声音工作,但是我仍然被这个问题弄糊涂了。这个QML解决方案应该工作。我最终得到了纯工作的基础上使用纯C++的,但我仍然困惑这个问题。这个QML解决方案应该可以工作。