Is there a way to play song from the middle in gstreamer?
<p>I've looking for method to play songs not from the begining in python gstreamer, consider this:</p>

<pre><code>import threading
import gst
import gobject

class GobInit(threading.Thread):
   ...

class BasicPlayer(threading.Thread):

    def __init__(self, musiclist):
        threading.Thread.__init__(self)
        self.musiclist = musiclist
        self.song_num = 0
        self.construct_pipeline()
        self.set_property_file()

    def construct_pipeline(self):
        self.player = gst.element_factory_make("playbin")
        self.is_playing = False
        self.connect_signals()

    def connect_signals(self):
        ...

    def play(self):
        self.is_playing = True
        self.player.set_state(gst.STATE_PLAYING)

    def set_property_file(self):
        self.player.set_property(
        "uri", "file://"+"/home/user/work/mp3/"+self.musiclist[
            self.song_num])

def main():
    gob = GobInit()
    gob.start()
    print('start')
    player = BasicPlayer(['test1.mp3', 'test2.mp3', 'test3.mp3'])
    print('player created')
    player.play()
    print('start play')

main()
</code></pre>

<p>So I have only this function to start:</p>

<pre><code>self.player.set_state(gst.STATE_PLAYING)
</code></pre>

<p>But I bet there is a way to start playing from the middle of the song, something like this:</p>

<pre><code>self.player.play_from_middle(gst.STATE_PLAYING, &lt;sec_after_begin&gt;)
</code></pre>

<p>Or maybe can I rewind the song somehow to make it be played from the middle?</p>

<p>Yes, I guess there should be a few ways, but the one (for non-live streams) that immediately comes to my mind is:</p>

<ul>
<li>Set the pipeline to PAUSED instead of PLAYING</li>
<li>Wait for the GST_MESSSAGE_ASYNC_DONE message to appear in the bus handler.</li>
<li>Query pipeline (gst_element_query()) for the duration, and then seek the pipeline (gst_element_seek()) to the duration/2 time </li>
<li>Set the pipeline to PLAYING.</li>
</ul>

python gstreamer