2013-02-07 2 views
1

제공된 샘플 코드를 실행하려고하는데, 아는 한 정상적으로 작동해야합니다. 실종되었거나 시뮬레이터의 제한 사항이 있습니까?Blackberry 10 Dev Alpha Simulator에서 SystemSounds를 재생하는 방법?

그렇다면 해결 방법이 있습니까?

import bb.cascades 1.0 
// To use the MediaPlayer, we must include 
// the 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 and 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 the sample: Playing system sounds. 
     Container { 
      id: systemSoundsContainer 
      layout: StackLayout { 
       orientation: LayoutOrientation.TopToBottom 
      } 
      topMargin: 100.0 
      horizontalAlignment: HorizontalAlignment.Center 
      DropDown { 
       id: soundSelectorDropdown 
       title: "Sound: " 
       maxWidth: 600.0 
       Option { 
        text: qsTr("Battery Alarm") 
        value: SystemSound.BatteryAlarm 
        selected: true 
       } 
       Option { 
        text: qsTr("Browser Start") 
        value: SystemSound.BrowserStartEvent 
       } 
       Option { 
        text: qsTr("Camera Shutter") 
        value: SystemSound.CameraShutterEvent 
       } 
       Option { 
        text: qsTr("Device Tether") 
        value: SystemSound.DeviceTetherEvent 
       } 
       Option { 
        text: qsTr("General Notification") 
        value: SystemSound.GeneralNotification 
       } 
      } // soundSelectorDropdown 
      Button { 
       id: systemSoundPlayButton 
       text: qsTr("Play Selected System Sound") 
       minWidth: 600.0 
       onClicked: { 
        systemSound.play(); 
       } 
      } // systemSoundPlayButton 
     } // systemSoundsContainer 
     // Part 2 of the 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 we could have created a second MediaPlayer object to 
        // use to play our sound, but instead we programmatically 
        // changed the sourceUrl property of the current myPlayer 
        // MediaPlayer object, and re-used it to 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 as above, here we also could have created a second 
        // MediaPlayer object to use to play our sound, but instead 
        // we programmatically changed the sourceUrl property of the 
        // current myPlayer MediaPlayer object, and re-used it to 
        // play our sounds. 
        myPlayer.setSourceUrl("asset:///sounds/Doorbell_002.wav") 
        myPlayer.play() 
       } 
      } // customSoundPlayButton2 
     } // customSoundsContainer 
    } // mainContainer 

    // The SystemSound and MediaPlayer objects are attached so 
    // they can be used in our QML code to play sounds. 
    attachedObjects: [   
     SystemSound { 
      id: systemSound 
      sound: soundSelectorDropdown.selectedValue 
     }, 
     MediaPlayer { 
      id: myPlayer 
      // sourceUrl: < Set in the Button control's onClicked event handler. > 
     } 
    ] // Attached objects. 
} 

출처 : https://developer.blackberry.com/cascades/documentation/design/audio_video/playing_sounds_code_sample.html

+0

"Cowbell"샘플 프로젝트 (https://github.com/blackberry/Cascades-Samples/tree/master/cowbell)를 기반으로 순수한 C++을 사용하여 소리가 나지 만, 여전히 이 문제로 인해 당황 스러웠다. 이 QML 솔루션 _ 작동해야합니다. – tcdowney

답변

1

은 그 시스템의 사운드는 "Cowbell sample"와 "Pull My Beard는".wav 파일을 사용하고 내부적으로 .MP3 또는에는 OGG 파일이 실제로 있다고 생각한다. 알려진 문제이며 Blackberry 개발자 포럼 hereherehere에서 시뮬레이터에 .wav 파일을 제외한 모든 사운드를 재생할 올바른 코덱이 없다고 논의되었습니다. 사운드는 실제 하드웨어에서 올바르게 재생되어야합니다.