Skip to content
Discussion options

You must be logged in to vote
import asyncio
import sys

from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QApplication, QLineEdit, QPushButton, QVBoxLayout, QWidget

from bilibili_api import live


class Listener(QThread):
    """
    监听器

    用来开启、关闭和发送弹幕给窗体
    """
    sinOut = pyqtSignal(str)  # 发送消息的信号

    def __init__(self):
        """
        room: 要连接的直播间
        loop: 异步事件循环
        """
        super().__init__()
        self.room = live.LiveDanmaku(510)
        self.loop = asyncio.new_event_loop()

    def run(self):
        """
        为直播间绑定监听并多线程开启
        """
        @self.room.on("DANMU_MSG")
        async def _(evt):
            """
            发送直播间弹幕
            """
            

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@tp1415926535
Comment options

@Drelf2018
Comment options

Comment options

You must be logged in to vote
2 replies
@Drelf2018
Comment options

@tp1415926535
Comment options

Answer selected by tp1415926535
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants