Qt World Summit: Register Today!

Render same video on 2 different surfaces

  • Hello,

    Basically I'm trying to render the same video source onto 2 locations in my window, using QtMultimedia5.
    I'm doing it in QML, but if there is a solution in C++ I will be happy to implement it instead.

    What I see is happening is that QMediaService::requestControl is called, which returns a QVideoRendererControl object. Then QVideoRendererControl::setSurface is called to set the surface to which it renders the video.
    So from what I gather QMediaService has one surface to which it renders the video.

    How can I render to 2 surfaces or more?


  • Well, this was fairly simple, not the way I expected though. You gotta love QtQuick2.

    So I have a MediaPlayer source and a VideoOutput item in my QML code:

    @MediaPlayer {
    id: mp1
    source: "slide-1.wmv"
    VideoOutput {
    id: tbltSlides
    anchors.fill: parent
    visible: true
    source: mp1

    All I had to do was just to add a ShaderEffectSource and set tbltSlides as its source. So simple:

    @ShaderEffectSource {
    id: slides
    x: 600
    height: 250
    sourceItem: tbltSlides
    visible: true

Log in to reply