0

I am making a simple playlist player on qml. I am using FolderListModel to read folders. I want to run each video in turn. But my player only plays the first video, then the program crashes. My error is invalid property name onStopped in Thong.qml. My source code:

main.qml

Rectangle {
    id: root
    width: 1024
    height: 600
    color: "black"
    property bool onStart: true
    Thong {
        id: playlist
        mediaPlayer: player
        fm: FolderListModel {
            id: fm
            folder: "file:///home/pi/Documents/nhacmp4test"
            showDirs: false
            showDotAndDotDot: false
            nameFilters: ["*.wmv"]
            property bool ready: count > 0
            onReadyChanged: {if (player.status == MediaPlayer.NoMedia) {
                                playlist.setIndex(0);
                                player.play();
                            }}
        }
    }
    MediaPlayer { id: player }
    VideoOutput {
        anchors.fill: parent
        source: player
    }
}/*Thong.qml*/ Item{
id: a
property int index: 0
property MediaPlayer mediaPlayer
property FolderListModel fm
Component.onCompleted: {
    mainWindow.showNormal();
}    
function setIndex(i)
{
    index = i;
    console.log("setting index to: " + i);
    index %= fm.count;
    mediaPlayer.source = "file://" + fm.get(index,"filePath");
    console.log("setting source to: " + mediaPlayer.source);
}
function next()
{
    setIndex(index+1);        
}
Connections {
    target:  a.mediaPlayer
    onStopped: {
        if (a.mediaPlayer.status == MediaPlayer.EndOfMedia) {
            a.next();
            a.mediaPlayer.play();
            console.log("ok");
        }
    }       
}    
Parisa.H.R
  • 3,303
  • 3
  • 19
  • 38
MinhThong
  • 3
  • 3

0 Answers0