qml - How to play SystemSounds in the Blackberry 10 Dev Alpha Simulator? -
i trying run provided sample code which, far know, should work fine. there missing or limitation of simulator.
if so, there workarounds?
class="lang-qml prettyprint-override">import bb.cascades 1.0 // utilize mediaplayer, must include // multimedia library. import bb.multimedia 1.0 page { container { id: maincontainer layout: stacklayout { orientation: layoutorientation.toptobottom } toppadding: 50.0 label { id: titlelbl text: qstr("systemsound , mediaplayer\n sample app") multiline: true textstyle.fontsizevalue: 9.0 textstyle.fontweight: fontweight.bold textstyle.fontfamily: "verdana" textstyle.color: color.darkblue textstyle.textalign: textalign.center horizontalalignment: horizontalalignment.center } // part 1 of sample: playing scheme sounds. container { id: systemsoundscontainer layout: stacklayout { orientation: layoutorientation.toptobottom } topmargin: 100.0 horizontalalignment: horizontalalignment.center dropdown { id: soundselectordropdown title: "sound: " maxwidth: 600.0 alternative { text: qstr("battery alarm") value: systemsound.batteryalarm selected: true } alternative { text: qstr("browser start") value: systemsound.browserstartevent } alternative { text: qstr("camera shutter") value: systemsound.camerashutterevent } alternative { text: qstr("device tether") value: systemsound.devicetetherevent } alternative { text: qstr("general notification") value: systemsound.generalnotification } } // soundselectordropdown button { id: systemsoundplaybutton text: qstr("play selected scheme sound") minwidth: 600.0 onclicked: { systemsound.play(); } } // systemsoundplaybutton } // systemsoundscontainer // part 2 of sample: playing custom sound files. container { id: customsoundscontainer layout: stacklayout { orientation: layoutorientation.lefttoright } topmargin: 100.0 button { id: customsoundplaybutton1 text: qstr("play sound 1") layoutproperties: stacklayoutproperties { spacequota: 1.0 } onclicked: { // here have created sec mediaplayer object // utilize play our sound, instead programmatically // changed sourceurl property of current myplayer // mediaplayer object, , re-used play our sounds. myplayer.setsourceurl("asset:///sounds/doorbell_001.wav") myplayer.play() } } // customsoundplaybutton1 button { id: customsoundplaybutton2 text: qstr("play sound 2") layoutproperties: stacklayoutproperties { spacequota: 1.0 } onclicked: { // same above, here have created sec // mediaplayer object utilize play our sound, instead // programmatically changed sourceurl property of // current myplayer mediaplayer object, , re-used // play our sounds. myplayer.setsourceurl("asset:///sounds/doorbell_002.wav") myplayer.play() } } // customsoundplaybutton2 } // customsoundscontainer } // maincontainer // systemsound , mediaplayer objects attached // can used in our qml code play sounds. attachedobjects: [ systemsound { id: systemsound sound: soundselectordropdown.selectedvalue }, mediaplayer { id: myplayer // sourceurl: < set in button control's onclicked event handler. > } ] // attached objects. } source: https://developer.blackberry.com/cascades/documentation/design/audio_video/playing_sounds_code_sample.html
i suspect that scheme sounds .mp3 or .ogg files internally, "cowbell sample" , "pull beard" using .wav files. it's known issue, , has been discussed on blackberry developer forums here , here, , here, simulator not have right codecs play sounds except .wav files. sounds should play correctly on actual hardware.
qml blackberry-10 blackberry-cascades
No comments:
Post a Comment