Open ambitiousCC opened 1 year ago
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() } }
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。