0
        self.player.set_state(Gst.State.READY)
        self.player.set_property("suburi", name)
        self.player.set_property("subtitle-font-desc", "Sans, 18")
        self.player.set_state(Gst.State.PLAYING)

When a certain button is clicked, the above code sets subtitles for video in playing state. I used the above code to set the subtitles to a video which was already in PLAYING state, when clicked on certain button. When I click on it, subtitles are displayed; but the videos does not resume from current location; it starts over. I also tried the following,

        _, duration = self.player.query_duration(Gst.Format.TIME)
        print(duration)
        self.player.set_state(Gst.State.NULL)
        self.player.set_property("uri", self.filename)
        self.player.set_property("suburi", name)
        self.player.set_property("subtitle-font-desc", "Sans, 18")
        self.player.set_state(Gst.State.PLAYING)
        self.player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH, duration)

Even this does not seek. Is there any alternative way to set the suburi without restarting the video?

1 Answers1

0

As Florian in their comment pointed out, there is no need to change the state.
Simply set the property suburi, although you may also want to look at setting the flags property as well.
As in:

self.player.set_property('flags', self.GST_VIDEO|self.GST_AUDIO|self.GST_TEXT|self.GST_SOFT_VOLUME|self.GST_DEINTERLACE)

when the subtitles are On
and:

self.player.set_property('flags', self.GST_VIDEO|self.GST_AUDIO|self.GST_SOFT_VOLUME|self.GST_DEINTERLACE)

when the subtitles are Off

Where the GST properties are declared as:

self.GST_VIDEO         = (1 << 0)
self.GST_AUDIO         = (1 << 1)
self.GST_TEXT          = (1 << 2)
self.GST_VIS           = (1 << 3)
self.GST_SOFT_VOLUME   = (1 << 4)
self.GST_NATIVE_AUDIO  = (1 << 5)
self.GST_NATIVE_VIDEO  = (1 << 6)
self.GST_DOWNLOAD      = (1 << 7)
self.GST_BUFFERING     = (1 << 8)
self.GST_DEINTERLACE   = (1 << 9)
self.GST_SOFT_COLORBALANCE = (1 << 10)

See: https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-playbin.html#GstPlayBin--flags

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60