Jump to content

Trying to control MPV Player through a python script


TheBajaBust

Recommended Posts

Hey guys, I am pretty new to this. I am working on turning my Le Potato into a TV shuffler. I have decided to go with Armbian, since I can't SSH (which is required for the CoreElec method), because I use college internet, and it just isn't configured properly. I am currently trying to get a script going that will open a folder and begin randomly playing videos from within, but I cannot figure out where to start really. I think I need to import mpv into the script somehow, but I honestly cannot find any resources on how to do this. 

 

Any help is appreciated, thanks in advance.

Link to comment
Share on other sites

I guess you could do something as simple as a bash[0] script, really.  But something like Kodi would give you a lot more control, I think (among many other niceties).

 

I would also try and figure out how to communicate with the device over the network, if at all possible.  Barring that, I guess you could use an IR remote (especially in Kodi).

 

[0] or Python, or whatever language you like

Link to comment
Share on other sites

#!/bin/bash

TOP=/home/share/video/music

if [ -n "$1" ];
then
    TOP=$1
fi

OLDIFS=$IFS
IFS=$'\n'

find $TOP -name "*.[maowf][povgklm][gvim]" -print | shuf -n 100 > randomplaylist
mpv -fs -vf=pp=de --playlist=randomplaylist
rm randomplaylist

IFS=$OLDIFS

This will play 100 randomly selected files from /home/share/video/music and subdirectories or whatever directory you pass on the command line.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines