Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Contributor
Posts: 5
Registered: ‎11-29-2012
My Device: Playbook 16gb
My Carrier: ATT

Listview & Mediaplayer

Hi guys, I'm in the process of learning about Cascades and I ran into a little problem(probably very simple), hopefully the community can help me solve it.


I want to create a listview and anytime a listitem is clicked it should use mediaplayer to play a sound.  

Here is a sample of the data model i'm using:



<listItem title="Test0" file="asset:///sounds/test0.ogg" />

<listItem title="Test1" file="asset:///sounds/test1.wav" />

<listItem title="Test2" file="asset:///sounds/test2.mp3" />



And here is the QML:


import bb.cascades 1.0
import bb.multimedia 1.0

TabbedPane {
    showTabsOnActionBar: false
    Tab {
        title: qsTr("Waps")
        Page {
            id: tab1
            Container {
                ListView {
                    id: waps
                    dataModel: XmlDataModel {
                        source: "models/wapmodel.xml"
                    listItemComponents: [
                        ListItemComponent {
                            type: "listItem"
                            StandardListItem {
                                title: ListItemData.title
                    onTriggered: {
                        var selectedItem = dataModel.data(indexPath);

            attachedObjects: [
                MediaPlayer {
                    id: myPlayer
    onCreationCompleted: {
        console.log("TabbedPane - onCreationCompleted()")
        OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;

 *Note* I was able to get the mediaplayer working just fine using buttons, but when it came time to implement it for listviews it wouldn't work.  When I build and run the code above the listview shows up, but when I click on an item nothing happens.


Thanks in advance