Создаю плеер таким образом:
self.vlcInstance = vlc.Instance("--no-xlib --verbose 2")
self.player = self.vlcInstance.media_player_new()
self.player.set_mrl(<линк на стрим>)
self.player.play()
Вот поток в плеере (pyqt5):
class Play(QtCore.QThread):
sig = QtCore.pyqtSignal(int, int)
def __init__(self, parent=None, *data):
super(Play, self).__init__(parent)
self.parent = parent
self.id = data[0]
self.parent.is_stop = False
self.sig.connect(self.parent.updateProgress)
self.playback = Streamer()
self.start()
def run(self):
uri = helpers.search.get_youtube_streams(self.id)
self.playback.play(uri['audio'])
def stop(self):
self.playback.stop()
self.exit()
return
import vlc
import requests
from PyQt5 import QtCore
class Streamer():
def __init__(self, *data):
self.vlcInstance = vlc.Instance("--no-xlib --verbose 2")
self.player = self.vlcInstance.media_player_new()
def stop(self):
self.player.stop()
return
def pause(self):
pass
def get_position(self):
return self.player.get_position()
def play(self, uri):
r = requests.get(uri)
if r.status_code == 200:
print('play')
self.player.set_mrl(uri)
self.player.play()
else:
return