2

Subtitle support added to Qt6 Multimedia and we can show a subtitle on MediaPlayer very simple. But I can't use this feature in QML, setSubtitleText seems not find in QML or at least not callable.

MediaPlayer {
    id: mediaPlayer

    Button{
    onClicked: {
        mediaPlayer.videoOutput.videoSink.setSubtitleText("I'm a subtitle!")
}
}

console.log(mediaPlayer.videoOutput.videoSink)

QVideoSink(0x203f364a8b0)

mediaPlayer.videoOutput.videoSink.setSubtitleText

undefined

mediaPlayer.videoOutput.videoSink.setSubtitleText("some text")

TypeError: Property 'setSubtitleText' of object QVideoSink(0x203f364a8b0) is not a function

fristhon
  • 21
  • 1
  • 6
  • 2
    I think you cant call `setSubtitleText` from QML because it is not `QInvokeable` or `QProperty`. [Also the docs says:](https://doc.qt.io/qt-6/qml-qtmultimedia-videooutput.html#videoSink-prop) > Normal usage of VideoOutput from QML should not require using this property. – ניר Jul 06 '22 at 03:53
  • 1
    Use [MediaPlayer,subtitleTracks](https://doc-snapshots.qt.io/qt6-dev/qml-qtmultimedia-mediaplayer.html#subtitleTracks-prop) instead. – folibis Jul 06 '22 at 06:59
  • @ניר You right, any solution? can I make my own `VideoOutput ` and make that function callable ? I mean by subclassing. – fristhon Jul 06 '22 at 15:25
  • @folibis I don't get it, that's a read-only property! what's the relation between this getter and my question ? – fristhon Jul 06 '22 at 15:34
  • 1
    @fristhon I think this is a private class and shouldn't be extended because it exists only as an "implementation detail". You can open an issue [here](https://bugreports.qt.io/secure/Dashboard.jspa) though.. – ניר Jul 06 '22 at 16:17
  • 1
    @ניר Thanks I did that and seems will be fixed in next release – fristhon Jul 14 '22 at 14:24

0 Answers0