start work on mpv

This commit is contained in:
Prayag committed 2022-06-10 13:06:54 +05:30
1 parent 464be525f1
commit 15826b0615
4 files changed
+99 -32

No files matched your search

+5 -1
View File
@@ -45,4 +45,8 @@
## Roadmap to Alpha 1
![roadmap alpha 1](https://i.imgur.com/lBd6etl_d.webp?maxwidth=640&shape=thumb&fidelity=medium)
Estimated release date: 15 July, 2022
- [ ] Integration of libMPV for video playback (30% completed).
- [ ] Add Jellyplayer specific player function to jf-vue for video playback (1% completed).
- [ ] Use github action workflow to build JellyPlayer for multiple target OS.
+52 -30
View File
@@ -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)
Generated
+41 -1
View File
@@ -28,6 +28,18 @@ docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
[[package]]
name = "autopep8"
version = "1.6.0"
description = "A tool that automatically formats Python code to conform to the PEP 8 style guide"
category = "dev"
optional = false
python-versions = "*"
[package.dependencies]
pycodestyle = ">=2.8.0"
toml = "*"
[[package]]
name = "click"
version = "8.1.3"
@@ -203,6 +215,14 @@ category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pycodestyle"
version = "2.8.0"
description = "Python style guide checker"
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "pyinstaller"
version = "5.0.1"
@@ -333,6 +353,14 @@ category = "main"
optional = false
python-versions = "<3.11,>=3.6"
[[package]]
name = "toml"
version = "0.10.2"
description = "Python Library for Tom's Obvious, Minimal Language"
category = "dev"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]]
name = "tomli"
version = "2.0.1"
@@ -387,7 +415,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
[metadata]
lock-version = "1.1"
python-versions = "~3.8"
content-hash = "e833a433cd43e523186875865be62d3a7e7cb88c807d487dcbf778f3494b6c1d"
content-hash = "211d7daff296440dc5ab6e8a40953f8245b930a81e39b137319c095f32b58c9b"
[metadata.files]
altgraph = [
@@ -402,6 +430,10 @@ attrs = [
{file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"},
{file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"},
]
autopep8 = [
{file = "autopep8-1.6.0-py2.py3-none-any.whl", hash = "sha256:ed77137193bbac52d029a52c59bec1b0629b5a186c495f1eb21b126ac466083f"},
{file = "autopep8-1.6.0.tar.gz", hash = "sha256:44f0932855039d2c15c4510d6df665e4730f2b8582704fa48f9c55bd3e17d979"},
]
click = [
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
@@ -502,6 +534,10 @@ py = [
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
]
pycodestyle = [
{file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"},
{file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"},
]
pyinstaller = [
{file = "pyinstaller-5.0.1-py3-none-macosx_10_13_universal2.whl", hash = "sha256:0dc19ccf97584fff1766dcaf9c0425e4cd714ccc41c9f4d1222cab8c756624e4"},
{file = "pyinstaller-5.0.1-py3-none-manylinux2014_aarch64.whl", hash = "sha256:100ba42f5885e1044e45a9a1d6fa9bb17be49d8731a34ebde39519a49095d509"},
@@ -559,6 +595,10 @@ shiboken6 = [
{file = "shiboken6-6.3.0-cp36-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:e68e3cbb595c3047c4d893b84ef88eb5b23dea4e94241e80f5509dcb6613ad3d"},
{file = "shiboken6-6.3.0-cp36-abi3-win_amd64.whl", hash = "sha256:096e6b2254e59729ae61acbb80d09c31ad7ea35b6624ec120c15a35b95c70b69"},
]
toml = [
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
]
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
+1
View File
@@ -25,6 +25,7 @@ PyOpenGL = "^3.1.6"
[tool.poetry.dev-dependencies]
pytest = "~5.2"
poethepoet = "^0.13.1"
autopep8 = "^1.6.0"
[tool.poe.tasks]
jellyplayer = "python jellyplayer/__init__.py"