小编Ken*_*nji的帖子

GStreamer总线发送无消息

我一直在项目中使用pygst,它一直运行良好.我正在尝试将其迁移到新的内省系统(GI),但我已经得到了不同的行为.

在旧的pygst我有这样的事情:

... # other imports
import pygst
pygst.require('0.10')
import gst
... # other imports

gobjects.threads_init()

...

def my_handler(bus, message):
    # handle the message

...

player = gst.element_factory_make('playbin2', 'my_player')
bus = player.get_bus()
bus.connect('message', my_handler)
bus.add_signal_watch()
...
player.set_state(gst.STATE_PLAYING)
# start the main Glib loop
Run Code Online (Sandbox Code Playgroud)

消息参数具有属性.TYPE它可用于选择性处理(我只流(EOS)和错误的结束有兴趣).使用新系统我有:

... # other imports
from gi.repository import Gst
import glib
import gobject
.... # other imports

gobject.threads_init()

loop = glib.MainLoop(None, False)

def bus_handler(bus, message):
    print message
    # handle the message
...

Gst.init_check(None) …
Run Code Online (Sandbox Code Playgroud)

python gstreamer

5
推荐指数
1
解决办法
3275
查看次数

标签 统计

gstreamer ×1

python ×1