[SailfishDevel] Playing a wav in Sailfish

christopher.lamb at thurweb.ch christopher.lamb at thurweb.ch
Fri Jun 14 06:49:18 UTC 2013


Hi João

I have just made a little demo project, importing QtMultimediaKit 1.1,  
and a SoundEffect Component.

I added a Button component to the Column to play the sound when clicked.

My Demo works, I get a swish sound when the button is clicked.

You will find the code of my FirstPage at the bottom of this mail.  
Create a new demo project, and paste my code into the FirstPage.

Note I copied my wav to the pages folder (alongside FirstPage). Please  
substitute your own wav file - I grabbed the first one I could find on  
the train. Put you wav in the Pages folder.


Do you get any sound at all from the Emulator? For instance on a demo  
new project with the PullDownMenu you should get a distinct "click"  
sound when the menu opens.

On the known issues page  
https://sailfishos.org/wiki/SDK_Alpha_Known_Issues#Emulator I found  
this:

"The sound is not enabled in the Emulator. Fix: Shutdown the emulator;  
Open virtualbox manager; Pick "SailfishOS Emulator", Pick Settings,  
pick Audio, Enable audio (default driver). Accept. Start Emulator. The  
Pulley menus make a sound for testing purposes."

Assuming that you do get sound, do you have QtMultimedia installed?

Connect to the SDK by SSH and search for QtMultimedia with zipper:

zypper se multi

I get this:

S | Name                                             | Zusammenfassung  
                                | Typ
--+--------------------------------------------------+------------------------------------------------+------
   | libdeclarative-multimedia                        | Qt Mobility  
Multimedia QML plugin              | Paket
   | libqtmultimediakit1                              | Qt Mobility  
MultimediaKit module               | Paket
i | multi_c_rehash                                   | A c_rehash  
implementation in C                 | Paket
   | multi_c_rehash-debuginfo                         | Debug  
information for package multi_c_rehash   | Paket
   | multi_c_rehash-debugsource                       | Debug sources  
for package multi_c_rehash       | Paket


Repeat with the the Emulator:

If  you don't get anything like this then you will have to install  
QtMultimedia.

Chris


//Start FirstPage.qml
import QtQuick 1.1
import Sailfish.Silica 1.0
import QtMultimediaKit 1.1

Page {
     id: page

     // To enable PullDownMenu, place our content in a SilicaFlickable
     SilicaFlickable {
         anchors.fill: parent

         // PullDownMenu and PushUpMenu must be declared in  
SilicaFlickable, SilicaListView or SilicaGridView
         PullDownMenu {
             MenuItem {
                 text: "Show Page 2"
                 onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
             }
         }

         // Tell SilicaFlickable the height of its content.
         contentHeight: childrenRect.height

         // Place our content in a Column.  The PageHeader is always  
placed at the top
         // of the page, followed by our content.
         Column {
             width: page.width
             spacing: theme.paddingLarge
             PageHeader {
                 title: "UI Template"
             }
             Label {
                 x: theme.paddingLarge
                 text: "Hello Sailors"
                 color: theme.secondaryHighlightColor
                 font.pixelSize: theme.fontSizeLarge
             }
             Button {
                 text: "Sound"
                 onClicked: mySound.play()
             }
         }
         SoundEffect { id: mySound
             //substitue your own wav file here, and copy it to the  
pages directory!
             //this is the first one I could find while experimenting  
on the train
             source: "92909__Robinhood76__01526_swoosh_2.wav"

         }
     }
}
//End FirstPage.qml






Zitat von "joao morgado" <joaodeusmorgado at yahoo.com>:

> Hi
>
> I'm porting a app from Meego/Symbian, I need to play a wav file. I  
> used importQtMultimediaKit1.1 and SoundEffect element. I  
> tought QtMultimediaKit was only available in Meego / Symbian, but my  
> app runs fine in the emulator, so I guess I'm good to go. I don't  
> hear any sound, I'm assuming it's a emulator limitation, can please  
> someone confirm that ?
>
> Thanks
> João de Deus





More information about the Devel mailing list