QML MediaPlayer with timer to reconnect streaming
Unsolved
QML and Qt Quick
-
Good morning,
I programmed a QML MediaPlayer streaming an IP camera. I coded a timer to reconnect if the video signal is lost. I tried this on Linux and it works perfectly when I disconnect the camera it emits the signal "OnError" but when I try this on Windows (with 5.15.2 MinGW 64 bit) the code doesn't emit the signal "OnError" after disconnecting the camera and I don't know the reason. If anyone has any idea about what could be the difference between Windows and Linux about this code I would be very grateful. Thanks in advance.
import QtQuick 2.7 import QtMultimedia 5.5 import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 Rectangle { property alias source: mediaPlayer.source property alias volume: mediaPlayer.volume property alias title: videoTitle.text property bool inverted: false property alias fadeOverlay: fade property alias player: mediaPlayer property alias color: background.color width: 640 height: 360 // Reconnection timer Timer { id: timer } function delay( delayTime, callback ) { timer.interval = delayTime; timer.repeat = false; timer.triggered.connect( callback ); timer.start( ); } MediaPlayer { id: mediaPlayer autoPlay: true autoLoad: false loops: MediaPlayer.Infinite volume: usv.sound onPlaying: { busyIndicator.running = false } onError: { busyIndicator.running = true; console.log( "Error" ); // Retry connection delay( 5000, function( ) { mediaPlayer.play( ); } ); } } // Info overlay PropertyAnimation { id: fade //target: overlay target: overlay properties: "opacity" to: 1 - overlay.opacity duration: 200 } Rectangle { id: overlay color: "transparent" anchors.fill: parent border.color: "#00000000" opacity: 1 z: 2 Text { id: videoTitle x: 5 y: 5 color: "#e4ff04" text: qsTr("Title") z: 1 style: Text.Outline font.pixelSize: 14 styleColor: "#000000" } } // Video output VideoOutput { id: videoOutput anchors.fill: parent source: mediaPlayer Rectangle { anchors.fill: parent id: background color: "#000000" border.color: "#00000000" z: -1 } transform: Scale { yScale: inverted ? ( -1 ) : 1 origin.x: width / 2 origin.y: height / 2 } } BusyIndicator { id: busyIndicator anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter } }