Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multimedia Playing Media demo is not working #223

Open
ambitiousCC opened this issue May 24, 2023 · 0 comments
Open

Multimedia Playing Media demo is not working #223

ambitiousCC opened this issue May 24, 2023 · 0 comments

Comments

@ambitiousCC
Copy link

I wrote my own demo based on the example to test the QtMultimedia library. But it doesn't work, in onMediaStatusChanged I found mediaplayer.mediaStatus = MediaPlayer.InvalidMedia。

Window {
    id: root
    width: 800
    height: 600
    visible: true
    Rectangle {
        id: backVideo
        width: root.width
        height: root.height
        anchors.fill: parent
        z: -1
        color: "yellow"
        MediaPlayer {
            id: mediaplayer
            audioOutput: AudioOutput {}
            videoOutput: videoOutput
            source: Qt.resolvedUrl("http://xxx:xxx/test.mp4")
            onPlaybackStateChanged: {
                if (mediaplayer.playbackState === MediaPlayer.StoppedState) {
                    mediaplayer.play()
                }
            }
            onMediaStatusChanged: {
                console.log("media status changed")
                if (mediaplayer.mediaStatus === MediaPlayer.NoMedia) {
                    console.log("no media")
                } else if (mediaplayer.mediaStatus === MediaPlayer.LoadingMedia) {
                    console.log("loading")
                } else if (mediaplayer.mediaStatus === MediaPlayer.InvalidMedia) {
                    console.log("invalid")
                } else {
                    console.log("other status")
                }
             }
        }

        VideoOutput {
            id: videoOutput
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.top: parent.top
            fillMode: VideoOutput.PreserveAspectCrop
            height: parent.height
        }
    }

    Component.onCompleted: {
        mediaplayer.play()
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant