Migrate Player from pw-play to mpv

This commit is contained in:
2026-07-07 04:47:37 +02:00
parent 0bbc1ca003
commit 02bbf5cc2e
2 changed files with 17 additions and 3 deletions

View File

@@ -128,10 +128,23 @@ Player::~Player()
stop_all(); stop_all();
} }
void Player::play_file(const QString& file_path, const QString& target_node/* = "auto" */) void Player::play_file(const QString& file_path,
const QString& target_sink/* = "auto" */, float speed/* = 1.0f */)
{ {
QString target = target_sink;
if (target_sink != "auto") {
target = "pipewire/" + target_sink;
}
QStringList args;
args << "--vo=null" << "--no-video"
<< "--audio-pitch-correction=no"
<< "--audio-device=" + target
<< "--speed=" + QString::number(speed, 'f', 1)
<< file_path;
auto process = std::make_unique<QProcess>(); auto process = std::make_unique<QProcess>();
process->start("pw-play", { "--target", target_node, file_path }); process->start("mpv", args);
m_playing_processes.push_back(std::move(process)); m_playing_processes.push_back(std::move(process));
} }

View File

@@ -57,7 +57,8 @@ class Player
public: public:
~Player(); ~Player();
void play_file(const QString& file_path, const QString& target_node = "auto"); void play_file(const QString& file_path,
const QString& target_sink = "auto", float speed = 1.0f);
void stop_all(); void stop_all();
private: private: