tplay: panicked at 'Failed to init MPV builder: VersionMismatch { linked: 65644, loaded: 131072 }',

panicked at ‘Failed to init MPV builder: VersionMismatch { linked: 65644, loaded: 131072 }’

mpv 0.35.1-dirty Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
built on Fri Apr 21 07:11:25 2023
FFmpeg library versions:
libavutil 58.2.100
libavcodec 60.3.100
libavformat 60.3.100
libswscale 7.1.100
libavfilter 9.3.100
libswresample 4.10.100
FFmpeg version: n6.0

But it works on the following:

mpv 0.34.1 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects built on UNKNOWN 
FFmpeg library versions: libavutil       56.70.100 
libavcodec      58.134.100 
libavformat     58.76.100 
libswscale      5.9.100 
libavfilter     7.110.100 
libswresample   3.9.100 
FFmpeg version: 4.4.2-0ubuntu0.22.04.1

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

here is the code of rodio implementation I am planning to put it in your player.rs maybe this helps:

use std::fs::File;
use std::io::BufReader;
use std::path::Path;
use std::sync::Arc;

use rodio::decoder::Decoder;
use rodio::queue::Queue;
use rodio::source::Buffered;
use rodio::{Device, Sink};

use crate::common::errors::MyError;

/// The AudioPlayer struct handles audio playback using the rodio backend.
pub struct AudioPlayer {
    /// The rodio sink responsible for managing the audio playback.
    sink: Sink,
    /// The audio file decoder.
    decoder: Decoder<Buffered<BufReader<File>>>,
}

impl AudioPlayer {
    /// Creates a new AudioPlayer instance.
    ///
    /// # Arguments
    ///
    /// * input_path - The path to the audio file to be played.
    ///
    /// # Returns
    ///
    /// A new AudioPlayer instance.
    pub fn new(input_path: &str) -> Result<Self, MyError> {
        let path = Path::new(input_path);
        let file = File::open(path).map_err(|err| {
            MyError::Audio(format!("Failed to open audio file: {:?}", err))
        })?;
        let reader = BufReader::new(file);
        let decoder = Decoder::new(Buffered::new(reader)).map_err(|err| {
            MyError::Audio(format!("Failed to decode audio file: {:?}", err))
        })?;

        let device = Device::default();
        let sink = Sink::new(&device);
        sink.append(decoder.clone());

        Ok(Self { sink, decoder })
    }

    /// Pauses the audio playback.
    ///
    /// # Returns
    ///
    /// A `Result` indicating success or an `MyError::Audio` error.
    pub fn pause(&mut self) -> Result<(), MyError> {
        self.sink.pause();
        Ok(())
    }

    /// Resumes the audio playback.
    ///
    /// # Returns
    ///
    /// A `Result` indicating success or an `MyError::Audio` error.
    pub fn resume(&mut self) -> Result<(), MyError> {
        self.sink.play();
        Ok(())
    }

    /// Toggles the playback state (play/pause) of the audio.
    ///
    /// # Returns
    ///
    /// A `Result` indicating success or an `MyError::Audio` error.
    pub fn toggle_play(&mut self) -> Result<(), MyError> {
        if self.sink.is_paused() {
            self.resume()
        } else {
            self.pause()
        }
    }

    /// Mutes the audio playback.
    ///
    /// # Returns
    ///
    /// A `Result` indicating success or an `MyError::Audio` error.
    pub fn mute(&mut self) -> Result<(), MyError> {
        self.sink.set_volume(0.0);
        Ok(())
    }

    /// Unmutes the audio playback.
    ///
    /// # Returns
    ///
    /// A `Result` indicating success or an `MyError::Audio` error.
    pub fn unmute(&mut self) -> Result<(), MyError> {
        self.sink.set_volume(1.0);
        Ok(())
    }

    /// Toggles the mute state of the audio.
    ///
    /// # Returns
    ///
    /// A `Result` indicating success or an `MyError::Audio` error.
    pub fn toggle_mute(&mut self) -> Result<(), MyError> {
        if self.sink.volume() == 0.0 {
            self
// continued.....

Why don’t you use rodio crate and replace it with libmpv? I think it will also be a much better replacement as you will not need to have a dependency on libmpv like If it is not installed on the operating system that will not cause much of an issue.