addon.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:plugin.video.douyutv2 作者: yangqian 项目源码 文件源码
def play_video(roomid):
    """
    Play a video by the provided path.
    :param path: str
    :return: None
    """
    cdnindex=__addon__.getSetting("cdn")
    player=xbmc.Player()
    if cdnindex != "0":
      cdndict={"1":"ws","2":"ws2","3":"lx","4":"dl","5":"tct","6":""}
      cdn=cdndict[cdnindex]
      room=get_room(roomid,cdn)
      path,play_item=get_play_item(room)
      # Pass the item to the Kodi player.
      xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
      # directly play the item.
      player.play(path, play_item)
    else:
      cdnlist=["ws","ws2","lx","dl","tct"]
      itemlist=[get_play_item(get_room(roomid,x)) for x in cdnlist]
      if __addon__.getSetting("excludeRTMP") == 'true':
        newitemlist=[]
        for path,x in itemlist:
          if 'rtmp' not in path:
            newitemlist.append((path,x))
        itemlist=newitemlist
      playlist=xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
      playlist.clear()
      for path,x in itemlist:
        playlist.add(path,x)
      player.play(playlist)
    with closing(OverlayText(alignment=0)) as overlay:
      #print "starting",i
      while not player.isPlaying():
        xbmc.sleep(100)
      overlay.show()
      overlay.text=u'????????'
      textlist=[u'??????????']
      danmu=douyudanmu(roomid)
      print danmu.roominfo,roomid
      if danmu.roominfo==None:
        return
      while not xbmc.abortRequested and player.isPlaying():
      #while not xbmc.abortRequested:
        s=danmu.get_danmu()
        if len(s)!=0:
          textlist.append(s)
          if(len(textlist)>20):
            textlist.pop(0)
        overlay.text=u'\n'.join(textlist)
        #print "looping",i
    danmu.exit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号