jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
550 stars 68 forks source link

how to use custom options in python-mpv #215

Closed Manvendra-div closed 2 years ago

Manvendra-div commented 2 years ago

i was using mpv to play songs, and i use command like mpv --external-file=image.jpg --force-window --image-display-duration=inf --vid=1 song_name.mp3

and i wanted to automate this commands by using python and i decided to use python-mpv so how to do that

musicfunfan commented 2 years ago

Hi, you can add them like this.

mpv.MPV(ytdl=True, script_opts=('force-window image-display-duration=inf vid=1 song_name.mp3')"

I thing... check the scrip_opts is the same option as mpv in command line.

Manvendra-div commented 2 years ago

and what about

--external-file=image.jpg

musicfunfan commented 2 years ago

I guess you can add this as well ... I am not sure of the syntax but this is the way.

jaseg commented 2 years ago

Hi there,

an earlier commenter was confused by the issue title and suggested script-opts. This is not what you need. script-opts is only for options passed to e.g. lua scripts run inside mpv, and is not used for normal mpv command-line options.

All of the options you listed are mpv built-in options and can be passed as parameters to the constructor. Just replace the dashes ("-") with underscores ("_") like this: player = mpv.MPV(force_window=True, image_display_duration="inf", ...).

external-file is a bit special: the doc says that external-file is a cli/config only alias for external-files (note the plural "s" at the end), so in your script you will have to use external_files=["...", ...] instead. Also, since this option only makes sense for a single playlist item, you might want to pass it to loadfile instead of the constructor, as in player.loadfile(..., external_files=["..."]). This way it will only affect that one file.

musicfunfan commented 2 years ago

My mistake sorry i miss understood.

Manvendra-div commented 2 years ago

So the syntax will be player.loadfile(external_files='image.jpg')

musicfunfan commented 2 years ago

I thing this is correct syntax, i do not know what are you trying to do though.