GithubHelp home page GithubHelp logo

python-mpv-jsonipc's People

Contributors

iwalton3 avatar neraste avatar pjeanjean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-mpv-jsonipc's Issues

Update pip package

Thanks for this module!

Could you update the project on Python Package Index? The last release is from May 12, and it doesn't have the last commit that calls the quit when the connection is lost.

Disconnecting...

I'm playing around and I can create a new instance of MPV or connect to an existing one just fine, but I am not sure how to disconnect once connected.

Looking at whats available, mpv.terminate() seems to be the right thing but now and again I get,

Socket connection died.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/python_mpv_jsonipc.py", line 168, in run
    current_data = self.socket.recv(1024)
OSError: [Errno 9] Bad file descriptor

How do I disconnect without an error?

Problem when a command has the same name as a property

vf is both a command and a property.

Because commands are added to the MPV object after properties are, this means that mpv.vf(...) issues a vf command and there's no mpv.vf to get the vf property.

In [1]: from python_mpv_jsonipc import MPV

In [2]: mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv.sock");

In [3]: mpv.vf()
---------------------------------------------------------------------------
MPVError                                  Traceback (most recent call last)
<ipython-input-3-429ca6751f2e> in <module>
----> 1 mpv.vf()

/usr/local/lib/python3.8/site-packages/python_mpv_jsonipc.py in wrapper(*args)
    594     def _get_wrapper(self, name):
    595         def wrapper(*args):
--> 596             return self.command(name, *args)
    597         return wrapper
    598

Not sure what the most elegant solution is, but in the mean time I used this simple hack to allow me to fetch the vf property.

from python_mpv_jsonipc import MPV
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv.sock");
mpv.get_property=mpv._get_wrapper("get_property")
mpv.get_property('vf')

Now I can just run mpv.get_property('vf'). This doesn't already exist because get_property is a separate JSON IPC command and not a property or input command.

Would it be reasonable to extend the MPV object with a get_property attribute? If so, can submit a simple PR.

Cheers!

asyncio support?

Just wondering if you might have any plans to support use of this controller via asyncio coroutines instead of threads. There's someone developing a similar interface here with asyncio support, but your interface is more full-featured with property observers and the like. Before I try to Frankenstein together the two projects, is this something you have any interest in supporting?

Option to use daemon threads?

Hey! I love this library but am having issues with programs not exiting. Would it be possible to add an option to make the threads daemons so they don't hold everything up? I could make a PR for it.

How to hide the main MPV window then playing audio on Windows?

Hi.

First, thanks a lot for this awesome project!

So, I'm playing radio via streaming on Windows, something like this:

mpv = MPV()
mpv.play('http://s1.myradiostream.com:12508/listen.mp3')
...

however, it displays the main MPV window as follow:

Captura de tela 2021-12-18 223112

so, is there any option to hide this window?

TIA for any help!

Cannot disable key bindings

Using mpv 0.33, I can disable key bindings manually by passing --no-input-default-bindings, but using the latest release of this package, setting no_input_default_bindings to True on an MPV instance does not have any effect.

Is it possible to support this parameter?

Bit of Confusion

Should probably mention first that I am new to this (both python and mpv)

I'm trying to use this library to write some mpv scripts but I'm confused about a few things

  1. How to return data from mpv

    • Looking at the data only figured out how to send commands using mpv.command(command, **args) but was unable to figure how to get mpv to send back data best i could do was wait for a property to change with mpv.wait_for_property but this doesnt seem to return any data
  2. Where I find the properties that you can wait on with mpv.wait_for_property using mpv.io

    • I was able to find command names for mpv.command but not property names I could find some things under https://mpv.io/manual/master/#options but they don't seem to work do I need to format them in a particular way to use them
  3. How to connect to running instance of mpv

    • I saw that you can connect to running instance of mpv that's connected to a particular socket but when I use MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket") it doesn't connect is there something I need to do to make my running mpv connect to a socket as of now I've only been able to work with mpv that is launched from PATH
  4. How to connect to running instance of mpv

    • How to use commands like mpv.volume = 20 I saw this in the docs where you change the volume with just a dot I am unsure where to find the attributes you can adjust like this I can only change things thus far with mpv.command(command, **args) not sure if this is maybe connected to the properties question I just asked, for example is there a mpv.playtime or mpv.subfile ETC.

"Socket connection died" error

Hello,

I've implemented your library and I'm getting the following error:

Socket connection died.
Traceback (most recent call last):
  File "/opt/app/env/lib/python3.11/site-packages/python_mpv_jsonipc.py", line 184, in run
    self.callback(json_data)
  File "/opt/app/env/lib/python3.11/site-packages/python_mpv_jsonipc.py", line 310, in event_callback
    self.cid_wait[data["request_id"]].set()
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 7

The odd thing is that MPV continues running just fine and I can test the socket with no issues. I think the socket is fine but the exception is causing the lib to incorrectly report the socket as being dead. I have not worked with request id's in the MPV JSON-IPC myself, so I'm not certain what the lib is doing here, but I remember seeing them mentioned in the MPV docs. I will attempt to hack at it a bit to see if I can figure it out and maybe offer a solution but I wanted to report it so that you're aware.

Running the new Debian Bookworm (Raspberry Pi OS on a Raspi 5) with a repo-installed version of MPV.

Number arguments to mpv are not parsed correctly

Number arguments to the MPV constructor are converted to "yes"/"no" when they should't be.

Example:

extra_args = {
    "video-scale-x": 1
}
MPV(**extra_args)

Expected Behavior

MPV starts

Current Behavior

python_mpv_jsonipc.MPVError: MPV process retry limit reached.

Possible Solution

Change MPVProcess_mpv_fmt() to if data is True: and elif data is False

Also: is it possible to include the mpv error in the traceback?

Does __del__ ever actually get called?

It seems like the socket thread holding a reference to the callback prevents del from being called, which means the thread never stops unless you manually call terminate() explicitly, and you get a thread leak.

And when you do call it explicitly, it sometimes stops with a nuisance error when the thread tries to read the closed socket. I work around that by changing the "while True" to "while self.should_run" and setting that to False to stop the loop before shutting down the socket and process.

Tag Pypi releases on GitHub

Hi. When we package python packages for nixpkgs, we try to pull source from GitHub so that tests are included. Even though there aren't tests yet, I'd like to follow that pattern.

It's most easily followed when releases are tagged on Git too. Can you do this so I can package a released version for nixpkgs? context: NixOS/nixpkgs#77884

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.