from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWebEngineWidgets import QWebEngineView
from PySide2.QtWebEngineWidgets import QWebEngineSettings
import os
class WebWidget(QMainWindow):
def __init__(self):
super().__init__()
self.browser=QWebEngineView(self)
self.browser.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)
self.browser.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True)
self.browser.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)
"""self.browser.setHtml('<!DOCTYPE html>\
<html>\
<head>\
<meta charset="utf-8">\
<title>菜鸟教程(runoob.com)</title>\
</head>\
<body>\
<iframe src="https://xbeibeix.com/api/bilibili/biliplayer/?url=BV1UT4y1C7uB" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" style="width: 640px; height: 430px; max-width: 100%"> </iframe>\
</body>\
</html>')"""
self.browser.load('https://xbeibeix.com/api/bilibili/biliplayer/?url=BV1UT4y1C7uB')
self.browser.setFixedSize(1080,720)
可以嵌入HTML,不过我搜了一下,默认不支持播放视频需要自己编译源码,这个太麻烦直接弃坑。
如果播放b站视频的话会提示安装flash,安装完毕以后虽然能播放声音,但是会黑屏,并且有报错。