Skip to content

Commit 99f89dc

Browse files
committed
fix: switch to libmpv2
while also building with the build_libmpv feature; mpv.lib is now redundant
1 parent b4fe010 commit 99f89dc

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

.github/workflows/dev-builds.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ on:
1111
- ".github/workflows/**.yml"
1212
- "src/**.rs"
1313
- "./Cargo.toml"
14-
- "./mpv/**.lib" # Will hopefully soon be removed when I finally get to create the damn lib file in a CI
15-
- ".cargo/**"
1614

1715
concurrency:
1816
group: ${{ github.workflow }}-${{ github.ref }}
@@ -31,14 +29,20 @@ jobs:
3129
- name: Install dependencies
3230
run: |
3331
sudo apt update
34-
sudo apt install libmpv-dev gcc-mingw-w64 -y
32+
sudo apt install libmpv-dev gcc-mingw-w64 7z -y
3533
rustup target add x86_64-pc-windows-gnu
36-
34+
35+
- name: Get libmpv for the windows build
36+
run: |
37+
wget https://downloads.sourceforge.net/project/mpv-player-windows/libmpv/mpv-dev-x86_64-20250928-git-db2b436.7z -O mpv.7z
38+
7z e -y mpv.7z -o64
39+
3740
- name: Build Linux and Windows bin
3841
run: |
42+
export MPV_SOURCE="$(pwd)"
3943
cargo build --release
4044
cargo build --release --target=x86_64-pc-windows-gnu
41-
45+
4246
- name: Rename artifacts
4347
run: |
4448
mv ./target/release/puddler puddler-${GITHUB_SHA::7}-dev

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ dirs = "6.0.0"
1414
discord-presence = "2.1.0"
1515
futures = "0.3.31"
1616
isolanguage-1 = { version = "0.2.3", git = "https://github.com/Vernoxvernax/isolanguage-1.git" }
17-
libmpv-sirno = "2.0.2-fork.1"
17+
libmpv2 = { git = "https://github.com/Vernoxvernax/libmpv2-rs.git", version = "5.0.1", features = ["build_libmpv"] }
1818
regex = "1.11.3"
1919
reqwest = { version = "0.12.15", features = ["blocking"] }
20-
serde = "1.0.219"
21-
serde_derive = "1.0.227"
20+
serde = "1.0.228"
21+
serde_derive = "1.0.228"
2222
serde_json = "1.0.140"
2323
tokio = { version = "1.44.2", features = ["full"] }
2424
tokio-tungstenite = { version = "0.28.0", features = ["native-tls"] }

config.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

mpv.lib

-140 KB
Binary file not shown.

src/mpv.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use futures::{
22
SinkExt, StreamExt,
33
stream::{SplitSink, SplitStream},
44
};
5-
use libmpv::{Mpv, events::Event};
5+
use libmpv2::{Mpv, events::Event};
66
use serde::{Deserialize, Serialize};
77
use serde_json::Value;
88
use std::{
@@ -316,7 +316,7 @@ impl Player {
316316
config.media_center_type.to_string()
317317
);
318318

319-
let mpv = Mpv::new().expect("Failed to create mpv handle!");
319+
let mut mpv = Mpv::new().expect("Failed to create mpv handle!");
320320

321321
if let Some(path) = &self.settings.mpv_config_location {
322322
mpv.set_property("config-dir", path.clone()).unwrap();
@@ -353,8 +353,7 @@ impl Player {
353353
.set_property("title", mpv_title)
354354
.expect("Failed to configure title.");
355355

356-
let mut ctx = mpv.create_event_context();
357-
ctx
356+
mpv
358357
.disable_deprecated_events()
359358
.expect("Failed to disable deprecated events.");
360359

@@ -400,11 +399,11 @@ impl Player {
400399
match json_message.Data.get("Command").unwrap().as_str().unwrap() {
401400
"PlayPause" => {
402401
if paused {
403-
mpv.unpause().unwrap();
402+
mpv.set_property("pause", false).unwrap();
404403
paused = false;
405404
old_pos -= 16.0;
406405
} else {
407-
mpv.pause().unwrap();
406+
mpv.set_property("pause", true).unwrap();
408407
paused = true;
409408
}
410409
},
@@ -416,7 +415,7 @@ impl Player {
416415
}
417416
}
418417
}
419-
while let Some(event_res) = ctx.wait_event(0.0) {
418+
while let Some(event_res) = mpv.wait_event(0.0) {
420419
let event = if let Ok(event) = event_res {
421420
event
422421
} else {
@@ -465,7 +464,7 @@ impl Player {
465464
},
466465
}
467466
}
468-
let result: Result<f64, libmpv::Error> = mpv.get_property("time-pos");
467+
let result: Result<f64, libmpv2::Error> = mpv.get_property("time-pos");
469468
if let Ok(current_time) = result {
470469
if let Ok(track) = mpv.get_property::<String>("current-tracks/audio/src-id") {
471470
audio_track = track.parse::<u32>().unwrap();

0 commit comments

Comments
 (0)