start work on mpv
This commit is contained in:
4 files changed
+99
-32
No files matched your search
+52
-30
@@ -1,6 +1,10 @@
|
||||
from mpv import MPV, MpvRenderContext, MpvGlGetProcAddressFn
|
||||
__version__ = '0.1.0'
|
||||
|
||||
import sys,os,subprocess,platform
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import platform
|
||||
from signal import SIGTERM, signal
|
||||
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget
|
||||
from PySide6.QtCore import QUrl, Slot, QObject, QProcess, Qt, QCoreApplication, Signal, QSize
|
||||
@@ -12,7 +16,7 @@ from PySide6.QtWebEngineQuick import QtWebEngineQuick
|
||||
from PySide6.QtQuick import QQuickFramebufferObject, QQuickView, QQuickItem
|
||||
from PySide6.QtOpenGL import QOpenGLFramebufferObject
|
||||
from PySide6.QtOpenGLWidgets import QOpenGLWidget
|
||||
from PySide6.QtQml import QQmlApplicationEngine, QQmlComponent,qmlRegisterType
|
||||
from PySide6.QtQml import QQmlApplicationEngine, QQmlComponent, qmlRegisterType
|
||||
from ctypes import windll, cast, c_void_p
|
||||
|
||||
# if (platform.system() == "Windows"):
|
||||
@@ -20,8 +24,8 @@ from ctypes import windll, cast, c_void_p
|
||||
# else:
|
||||
# from OpenGL import GL, GLX
|
||||
|
||||
os.environ["PATH"] = os.path.dirname(__file__) + os.pathsep + os.environ["PATH"]
|
||||
from mpv import MPV, MpvRenderContext, MpvGlGetProcAddressFn
|
||||
os.environ["PATH"] = os.path.dirname(
|
||||
__file__) + os.pathsep + os.environ["PATH"]
|
||||
|
||||
QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
|
||||
app = QApplication(["--enable-smooth-scrolling", "--enable-gpu"])
|
||||
@@ -33,62 +37,80 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def restart():
|
||||
QApplication.quit()
|
||||
status = QProcess.startDetached(sys.executable, sys.argv)
|
||||
|
||||
|
||||
class Backend(QObject):
|
||||
def __init__(self, player):
|
||||
self.player = player
|
||||
|
||||
def restart(self):
|
||||
QApplication.quit()
|
||||
status = QProcess.startDetached(sys.executable, sys.argv)
|
||||
|
||||
@Slot(str)
|
||||
def play(self, url):
|
||||
self.player.play(url)
|
||||
|
||||
@Slot(int)
|
||||
def setTime(self, time):
|
||||
self.player.setTime(time)
|
||||
|
||||
|
||||
class MainWin(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.dirRaw = os.path.dirname(os.path.realpath(__file__))
|
||||
self.dir = self.dirRaw.replace("\\","/")
|
||||
self.view= QWebEngineView()
|
||||
self.view.load(QUrl("http://localhost:2703"))
|
||||
self.dir = self.dirRaw.replace("\\", "/")
|
||||
self.view = QWebEngineView()
|
||||
self.view.load(QUrl("http://localhost:3000"))
|
||||
# self.view.load(QUrl("http://localhost:2703"))
|
||||
self.view.raise_()
|
||||
self.setCentralWidget(self.view)
|
||||
self.setWindowIcon(QIcon(QPixmap(f"{self.dir}/assets/icon.png")))
|
||||
|
||||
|
||||
self.view.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True)
|
||||
self.view.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)
|
||||
self.view.settings().setAttribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)
|
||||
self.view.settings().setAttribute(
|
||||
QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)
|
||||
self.view.settings().setAttribute(QWebEngineSettings.LocalStorageEnabled, True)
|
||||
self.view.settings().setAttribute(QWebEngineSettings.LocalContentCanAccessFileUrls, True)
|
||||
self.view.settings().setAttribute(
|
||||
QWebEngineSettings.LocalContentCanAccessFileUrls, True)
|
||||
self.view.settings().setAttribute(QWebEngineSettings.ScrollAnimatorEnabled, True)
|
||||
|
||||
|
||||
self.view.loadFinished.connect(self.handleLoaded)
|
||||
|
||||
|
||||
self.inspector = QWebEngineView()
|
||||
self.inspector.setWindowTitle("Inspector")
|
||||
|
||||
self.backend = Backend()
|
||||
|
||||
self.backend = Backend(self.playerWid)
|
||||
self.channel = QWebChannel()
|
||||
self.channel.registerObject('backend', self.backend)
|
||||
|
||||
|
||||
self.playerWid = QWidget(self)
|
||||
self.playerWid.setMinimumHeight(self.view.height)
|
||||
self.playerWid.setMinimumWidth(self.view.width)
|
||||
self.playerWid.setAttribute(Qt.WA_DontCreateNativeAncestors)
|
||||
self.playerWid.setAttribute(Qt.WA_NativeWindow)
|
||||
self.playerWid.lower()
|
||||
self.player = MPV(wid=str(int(self.playerWid.winId())),
|
||||
gpu_context="d3d11",
|
||||
hwdec="nvdec",
|
||||
log_handler=print,
|
||||
loglevel='debug')
|
||||
|
||||
def handleLoaded(self, ok):
|
||||
if ok:
|
||||
self.view.page().setDevToolsPage(self.inspector.page())
|
||||
self.inspector.show()
|
||||
|
||||
def createPlayer(self, videoUrl):
|
||||
self.container = QWidget(self)
|
||||
self.setCentralWidget(self.container)
|
||||
self.container.setAttribute(Qt.WA_DontCreateNativeAncestors)
|
||||
self.container.setAttribute(Qt.WA_NativeWindow)
|
||||
player = MPV(wid=str(int(self.container.winId())),
|
||||
gpu_context="d3d11",
|
||||
hwdec="nvdec",
|
||||
log_handler=print,
|
||||
loglevel='debug')
|
||||
player.play(videoUrl)
|
||||
|
||||
|
||||
frontend= subprocess.Popen(f"python {os.path.dirname(os.path.realpath(__file__))}/jellyplayer-jellyfin-vue/frontend/dist/server.py", shell=True)
|
||||
# frontend = subprocess.Popen(f"python {os.path.dirname(os.path.realpath(__file__))}/jellyplayer-jellyfin-vue/frontend/dist/server.py", shell=True)
|
||||
window = MainWin()
|
||||
window.showMaximized()
|
||||
exitApp = app.exec()
|
||||
frontend.kill()
|
||||
sys.exit(exitApp)
|
||||
# frontend.kill()
|
||||
sys.exit(exitApp)
|
||||
Reference in new issue
Block a user