RSATom / QmlVlc

[ABANDONED] libvlc wrapper for Qt Quick 2/Qml
Other
139 stars 56 forks source link

When used through QWebChannel, .state always returns null #61

Open Ivshti opened 8 years ago

Ivshti commented 8 years ago

Here's some sample code:

main.qml

Component.onCompleted: function() {
webView.webChannel.registerObject( 'vlcPlayer', vlcPlayer );
}

index.html

<script src='qrc:///qtwebchannel/qwebchannel.js'>
<script>
new QWebChannel(qt.webChannelTransport, function(channel) {
        var vlc = channel.objects.vlcPlayer;
        setInterval(function() { console.log(vlc.state) }, 2000); // always null
        setInterval(function() { console.log(vlc.time) }, 2000); // proper integer value
});
</script>

Is the issue in the way Qt translates enums? It should be OK in theory.

Qt WebEngine 1.3 Qt WebChannel 1.0 QmlVlc 0.1

Ivshti commented 8 years ago

I did hack it by replacing

Q_PROPERTY( State state READ get_state NOTIFY stateChanged )

with

Q_PROPERTY( unsigned state READ get_state NOTIFY stateChanged )

I assume casting the enum to unsigned is a hack here, and QWebChannel should work just fine with the enum in the first place. I'll let you @RSATom figure out the clean solution

RSATom commented 8 years ago

Thanks, I'll look.

Ivshti commented 7 years ago

@RSATom any updates on this? It kind of blocks some stuff

RSATom commented 7 years ago

sorry, not yet