Skip to content

Commit

Permalink
Compiles but MPV not working
Browse files Browse the repository at this point in the history
  • Loading branch information
core1024 committed Jun 10, 2024
1 parent 0bd82f0 commit 3b6a031
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ set(SOURCES
qml.qrc
)

set(QT_DEFAULT_MAJOR_VERSION 6)
set(MPV_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/libmpv/include)
if(WIN32)
list(APPEND SOURCES deps/chroma/chroma stremio.rc)
set(QT_DEFAULT_MAJOR_VERSION 6)
set(ENV{Qt6_DIR} $ENV{QTDIR})
set(MPV_LIBRARY_mpv ${CMAKE_CURRENT_SOURCE_DIR}/deps/libmpv/win32/mpv.lib)
endif()
Expand All @@ -57,7 +57,7 @@ add_subdirectory(deps/singleapplication)

set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)

find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Widgets Network Gui Quick WebEngine WebChannel DBus OpenGL REQUIRED)
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} COMPONENTS Widgets Network Gui Quick WebEngineQuick WebEngineWidgets WebChannel DBus OpenGL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(MPV REQUIRED)

Expand Down Expand Up @@ -117,7 +117,8 @@ target_link_libraries(${PROJECT_NAME} LINK_PUBLIC
Qt::Quick
Qt::Network
Qt::Widgets
Qt::WebEngine
Qt::WebEngineWidgets
Qt::WebEngineQuick
Qt::WebChannel
Qt::DBus
Qt::OpenGL
Expand Down
2 changes: 1 addition & 1 deletion autoupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <QQueue>
#include <QVector>
#include <QProcess>
#include <QNetworkConfigurationManager>
// #include <QNetworkConfigurationManager>

// Mixing C and C++ :(
extern "C" {
Expand Down
8 changes: 5 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <QQmlApplicationEngine>
#include <QtWebEngine>
// #include <QtWebEngine>
#include <QSysInfo>

#include <QQmlContext>
#include <QDebug>
#include <clocale>

#define APP_TITLE "Stremio - Freedom to Stream"
Expand Down Expand Up @@ -78,7 +79,8 @@ int main(int argc, char **argv)

MainApp app(argc, argv, true);
#ifndef Q_OS_MACOS
if( app.isSecondary() ) {
if( false && app.isSecondary() ) {
qDebug() << "Secondary instance, sending message";
if( app.arguments().count() > 1)
app.sendMessage( app.arguments().at(1).toUtf8() );
else
Expand Down
41 changes: 21 additions & 20 deletions main.qml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import QtQuick 2.7
import QtWebEngine 1.4
import QtWebChannel 1.0
import QtQuick.Window 2.2 // for Window instead of ApplicationWindow; also for Screen
import QtQuick.Controls 1.4 // for ApplicationWindow
import QtQuick.Dialogs 1.2
import com.stremio.process 1.0
import com.stremio.screensaver 1.0
import com.stremio.libmpv 1.0
import com.stremio.clipboard 1.0
import QtQml 2.2
import QtQuick
import QtWebEngine
import QtWebChannel
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Dialogs
import com.stremio.process
import com.stremio.screensaver
import com.stremio.libmpv
import com.stremio.clipboard
import QtQml

import "autoupdater.js" as Autoupdater

Expand Down Expand Up @@ -441,7 +441,8 @@ ApplicationWindow {
// In the app, we use open-external IPC signal, but make sure this works anyway
property string hoveredUrl: ""
onLinkHovered: webView.hoveredUrl = hoveredUrl
onNewViewRequested: function(req) { if (req.userInitiated) Qt.openUrlExternally(webView.hoveredUrl) }
// FIXME: this is not working
// onNewViewRequested: function(req) { if (req.userInitiated) Qt.openUrlExternally(webView.hoveredUrl) }

// FIXME: When is this called?
onFullScreenRequested: function(req) {
Expand All @@ -464,34 +465,34 @@ ApplicationWindow {
id: ctxMenu
MenuItem {
text: "Undo"
shortcut: StandardKey.Undo
// shortcut: StandardKey.Undo
onTriggered: webView.triggerWebAction(WebEngineView.Undo)
}
MenuItem {
text: "Redo"
shortcut: StandardKey.Redo
// shortcut: StandardKey.Redo
onTriggered: webView.triggerWebAction(WebEngineView.Redo)
}
MenuSeparator { }
MenuItem {
text: "Cut"
shortcut: StandardKey.Cut
// shortcut: StandardKey.Cut
onTriggered: webView.triggerWebAction(WebEngineView.Cut)
}
MenuItem {
text: "Copy"
shortcut: StandardKey.Copy
// shortcut: StandardKey.Copy
onTriggered: webView.triggerWebAction(WebEngineView.Copy)
}
MenuItem {
text: "Paste"
shortcut: StandardKey.Paste
// shortcut: StandardKey.Paste
onTriggered: webView.triggerWebAction(WebEngineView.Paste)
}
MenuSeparator { }
MenuItem {
text: "Select All"
shortcut: StandardKey.SelectAll
// shortcut: StandardKey.SelectAll
onTriggered: webView.triggerWebAction(WebEngineView.SelectAll)
}
}
Expand Down Expand Up @@ -563,7 +564,7 @@ ApplicationWindow {

FileDialog {
id: fileDialog
folder: shortcuts.home
// folder: shortcuts.home
onAccepted: {
var fileProtocol = "file://"
var onWindows = Qt.platform.os === "windows" ? 1 : 0
Expand Down Expand Up @@ -600,7 +601,7 @@ ApplicationWindow {
data: fileDialog.data
})
}
property var data: {}
// property var data: {}
}

//
Expand Down
10 changes: 5 additions & 5 deletions mpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <QtGlobal>
#include <QOpenGLContext>

#include <QtGui/QOpenGLFramebufferObject>
#include <QOpenGLFramebufferObject>

#include <QtQuick/QQuickWindow>
#include <QtQuick/QQuickView>
Expand Down Expand Up @@ -65,7 +65,7 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer
// init mpv_gl:
if (!obj->mpv_gl)
{
mpv_opengl_init_params gl_init_params{get_proc_address_mpv, nullptr, nullptr};
mpv_opengl_init_params gl_init_params{get_proc_address_mpv, nullptr};
mpv_render_param params[]{
{MPV_RENDER_PARAM_API_TYPE, const_cast<char *>(MPV_RENDER_API_TYPE_OPENGL)},
{MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params},
Expand All @@ -81,7 +81,7 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer

void render()
{
obj->window()->resetOpenGLState();
// obj->window()->resetOpenGLState();

QOpenGLFramebufferObject *fbo = framebufferObject();
mpv_opengl_fbo mpfbo{static_cast<int>(fbo->handle()), fbo->width(), fbo->height(), 0};
Expand All @@ -100,7 +100,7 @@ class MpvRenderer : public QQuickFramebufferObject::Renderer
// other API details.
mpv_render_context_render(obj->mpv_gl, params);

obj->window()->resetOpenGLState();
// obj->window()->resetOpenGLState();
}
};

Expand Down Expand Up @@ -308,7 +308,7 @@ QVariant MpvObject::getProperty(const QString& name) {
}
QQuickFramebufferObject::Renderer *MpvObject::createRenderer() const
{
window()->setPersistentOpenGLContext(true);
// window()->setPersistentOpenGLContext(true);
window()->setPersistentSceneGraph(true);
return new MpvRenderer(const_cast<MpvObject *>(this));
}

0 comments on commit 3b6a031

Please sign in to comment.