Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python gst分段错误_Python_Pygtk_Gstreamer - Fatal编程技术网

Python gst分段错误

Python gst分段错误,python,pygtk,gstreamer,Python,Pygtk,Gstreamer,我想创建一个播放器类来使用gst播放音乐。这是代码: from gi.repository import GObject GObject.threads_init() import gst class PlayerControl: def __init__(self, main_window): self.player = gst.element_factory_make("playbin2", "player") self.sink = gst.el

我想创建一个播放器类来使用gst播放音乐。这是代码:

from gi.repository import GObject
GObject.threads_init()
import gst

class PlayerControl:
    def __init__(self, main_window):

        self.player = gst.element_factory_make("playbin2", "player")
        self.sink = gst.element_factory_make("autoaudiosink", "player Output")
        self.videosink= gst.element_factory_make("fakesink", "player fake Output")
        self.player.set_property("video-sink", self.videosink)
        self.player.set_property("audio-sink", self.sink)
        self.player_bus = self.player.get_bus()
        self.player_bus.add_signal_watch()
        self.player_bus.connect("message", self.on_messages)
        self.player.connect("about-to-finish", self.on_finish)
        self.main_window = main_window
        self.main_window.seek_bar.connect("value-changed", self.on_slider_changed)
        self.main_window.seek_bar.set_range(0, 100)
        self.playing = False

    def on_messages(self, bus, message):
        print(message)


    def play(self, file):
        self.playing = True
        self.player.set_state(gst.STATE_READY)
        self.player.set_property("uri", "file:///"+str(file)) # örnek olsun diye
        self.player.set_state(gst.STATE_PLAYING)
        GObject.timeout_add(100, self.update_slider)
    [...]
我从另一个类似这样的班级打电话来播放声音:

from file import PlayerControl
class PlayerExample():
    def __init__( self ):
    self.player_gst = PlayerControl(self)
    [...]
    def play(self, file):
        self.playing = True
        self.player.set_state(gst.STATE_READY)
        self.player.set_property("uri", "file:///"+str(file))
        self.player.set_state(gst.STATE_PLAYING)
        GObject.timeout_add(100, self.update_slider)
    [...]
我已经连接了一个gtk按钮来播放功能。当我点击按钮时,我在没有任何信息的情况下选择了
分段错误
。 另外,如果我从我的PlayerControl类中删除
self.player\u bus.add\u signal\u watch()
self.player.connect(“即将完成”,self.on\u finish)
行,它工作并播放声音,但我需要用“即将完成”信号调用完成的函数。 为什么它不工作?

GObject.threads\u init()
来自gi.repository的文件不能与pygst“0.10”一起工作 您需要添加:

import gobject
gobject.threads_init()
import gst
顶级球员。 或使用Gst-1.0