Skip to content

Commit b537102

Browse files
committed
[功能更新与优化] 统一跨平台播放器控件实现,并新增基于 Qt 的 QPlayer 示例。
- 更新了`.github/actions/install-dependencies/action.yml`文件,将Qt版本从`6.8.0`升级到`6.8.1`。 - 在`CMakeLists.txt`中添加了`include(cmake/build_info.cmake)`,以便构建时包含构建信息。 - 更新了`README.en.md`和`README.md`文件,修改了字幕处理函数的名称,并添加了QPlayer的参考链接。 - 修改了`cmake/qt.cmake`文件,更新了Qt的安装路径,以匹配新版本的Qt。 - 添加了新目录`examples/qplayer`,用于构建基于Qt的媒体播放器示例。 - 在`examples/CMakeLists.txt`中添加了对`qplayer`目录的支持。 - 在`examples/ffmpegplayer`和`examples/ffmpegtranscoder`目录中,更新了CMakeLists.txt文件,添加了对`commonstr.hpp`的引用,并更新了Qt模块的引用。 - 在`examples/mpvplayer`目录中,更新了CMakeLists.txt和相关源文件,以使用新的Qt模块引用。 - 在`src/3rdparty/`、`src/dump/`、`src/ffmpeg/`、`src/mediaconfig/`、`src/mpv/`、`src/utils/`目录中,更新了CMakeLists.txt文件,将Qt6的模块引用更新为Qt的模块引用。 - 更新了`scripts/windows/setVsDev.ps1`脚本,以支持不同架构的Visual Studio开发环境设置。 - 更新了`vcpkg.json`文件,调整了FFmpeg的特征配置。
1 parent 14df42c commit b537102

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1172
-307
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
qt_ver:
2424
description: 'qt version'
2525
required: false
26-
default: '6.8.0'
26+
default: '6.8.1'
2727
type: string
2828

2929
runs:

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,5 @@ include_directories(src)
111111
add_subdirectory(src)
112112
add_subdirectory(tests)
113113
add_subdirectory(examples)
114+
115+
include(cmake/build_info.cmake)

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ transcodeCtx->audioPts += frame->nb_samples;
110110
qt.dbus.integration: Could not connect "org.freedesktop.IBus" to globalEngineChanged(QString)
111111
```
112112

113-
- 在Windows和Unix下,ControlWidget和TitleWidget的控制方式不同
114-
115-
1. Windows下使用 `mpv_set_property(d_ptr->mpv, "wid", MPV_FORMAT_INT64, &wid);`,使用layout布局,会使得视频窗口在最前面,遮挡ControlWidget和TitleWidget,所以将ControlWidget和TitleWidget悬浮在视频窗口上方,使用 `eventFilter`去处理大部分情况下ControlWidget和TitleWidget的显示,写的非常啰嗦,但是为了能够使用D3D11渲染,更棒的性能,只能这样处理,也是值得的;
116-
2. Unix下使用QOpenGLWidget,使用layout布局更加方便;
117-
118113
- MacOS打包需要[install_name_tool](/mac/change_lib_dependencies.rb),依赖拷贝脚本文件来自[iina](https://github.com/iina/iina/blob/develop/other/change_lib_dependencies.rb);
119114

120115
**当前 `brew`安装的 `mpv`中,`libmpv.dylib`的依赖是 `@loader_path/`,所以对脚本进行了一些修改;**
@@ -125,6 +120,10 @@ transcodeCtx->audioPts += frame->nb_samples;
125120

126121
依赖会拷贝到 `packet/Qt-Mpv.app/Contents/Frameworks/`
127122

123+
# QPlayer
124+
125+
- 参考 [Media Player Example](https://doc.qt.io/qt-6/qtmultimedia-player-example.html)
126+
128127
## QT-BUG
129128

130129
- 动态切换Video Render,从opengl切换到widget,还是有GPU 0-3D占用,而且使用量是opengl的2倍!!!QT-BUG?

cmake/qt.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
if(CMAKE_HOST_WIN32)
2-
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.8.0\\msvc2022_64")
2+
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.8.1\\msvc2022_64")
33
elseif(CMAKE_HOST_APPLE)
44

55
elseif(CMAKE_HOST_LINUX)
6-
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.8.0/gcc_64")
6+
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.8.1/gcc_64")
77
endif()
8+
9+
add_definitions(-DQT_DEPRECATED_WARNINGS)

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_subdirectory(ffmpegplayer)
22
add_subdirectory(ffmpegtranscoder)
3+
add_subdirectory(qplayer)
34

45
if(BUILD_MPV)
56
add_subdirectory(mpvplayer)

examples/common/commonstr.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <QCoreApplication>
4+
5+
namespace Common {
6+
7+
struct Tr
8+
{
9+
Q_DECLARE_TR_FUNCTIONS(Common)
10+
};
11+
12+
} // namespace Common

examples/common/controlwidget.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ ControlWidget::ControlWidget(QWidget *parent)
131131
: QWidget{parent}
132132
, d_ptr(new ControlWidgetPrivate(this))
133133
{
134-
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::Tool);
135-
setAttribute(Qt::WA_TranslucentBackground); //设置窗口背景透明
136-
137134
d_ptr->setupUI();
138135
buildConnect();
139136
d_ptr->initModelButton();
@@ -213,7 +210,7 @@ void ControlWidget::setDuration(int value)
213210
setPosition(0);
214211
}
215212

216-
#ifdef MPV_ON
213+
#if defined(MPV_ON)
217214
void ControlWidget::setChapters(const Mpv::Chapters &chapters)
218215
{
219216
QVector<qint64> nodes;
@@ -222,7 +219,7 @@ void ControlWidget::setChapters(const Mpv::Chapters &chapters)
222219
}
223220
d_ptr->slider->setNodes(nodes);
224221
}
225-
#else
222+
#elif defined(FFMPEG_ON)
226223
void ControlWidget::setChapters(const Ffmpeg::Chapters &chapters)
227224
{
228225
QVector<qint64> nodes;

examples/common/controlwidget.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef CONTROLWIDGET_HPP
22
#define CONTROLWIDGET_HPP
33

4-
#ifdef MPV_ON
4+
#if defined(MPV_ON)
55
#include <mpv/mediainfo.hpp>
6-
#else
6+
#elif defined(FFMPEG_ON)
77
#include <ffmpeg/mediainfo.hpp>
88
#endif
99

@@ -21,9 +21,9 @@ class ControlWidget : public QWidget
2121

2222
void setDuration(int value);
2323
[[nodiscard]] auto duration() const -> int;
24-
#ifdef MPV_ON
24+
#if defined(MPV_ON)
2525
void setChapters(const Mpv::Chapters &chapters);
26-
#else
26+
#elif defined(FFMPEG_ON)
2727
void setChapters(const Ffmpeg::Chapters &chapters);
2828
#endif
2929
[[nodiscard]] auto sliderGlobalPos() const -> QPoint;

examples/common/titlewidget.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ TitleWidget::TitleWidget(QWidget *parent)
2525
: QWidget{parent}
2626
, d_ptr(new TitleWidgetPrivate(this))
2727
{
28-
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::Tool);
29-
setAttribute(Qt::WA_TranslucentBackground);
3028

3129
setupUI();
3230
buildConnect();

examples/examples.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ CONFIG += ordered
33

44
SUBDIRS += \
55
ffmpegplayer \
6-
ffmpegtranscoder
6+
ffmpegtranscoder \
7+
qplayer
78

89
win32 {
910
exists("C:/3rd/x64/mpv/include"){

0 commit comments

Comments
 (0)