Pmplay - mplayer search / play script

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
stu90

Pmplay - mplayer search / play script

#1 Post by stu90 »

Not sure where to post this but maybe some one might find some use for it.

What is it?
A basic 2 box GUI for Mplayer made with Zenity / Yad.

Image

What does it do?
In the first GUI box you type path or drag and drop a directory that contains some media file/s you want to play with terminal Mplayer.
click ok and it will open the second GUI box
In the second box you enter either a word of file format to search for in that directory- example: Maiden or .mp3 or .avi

It then creates a playlist in /tmp out of the results that have Maiden in the file name or files that have an .mp3 extension and then terminal Mplayer plays that playlist.

To play a single meida file, example:
/root/music_video.avi
Type path or drag media file into GUI box one and leave GUI box two blank and click ok.

Word search.
If you know how your media files are formated blank space or under score - you can search for more than a one word string as long as it matches part of the actual file name.
example:
iron_maiden (if your files have under score instead of blank spaces.
iron maiden (if your files have black spaces instead of under scores)

requires Zenity / Yad it is only 26KB in size:
http://www.murga-linux.com/puppy/viewtopic.php?t=58306

pmplay Script.
http://dl.dropbox.com/u/3009188/pmplay.gz

Move Script to
/root/my-applications/bin
a click on it to decompress.

You can then drag it to desktop or run from terminal with command: pmplay
Last edited by stu90 on Sat 19 Feb 2011, 04:35, edited 1 time in total.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

Media Playing

#2 Post by seaside »

Here's a variation using Gxine and Xdialog to run in puppy without adding Zenity/Yad or Mplayer.

Of course you could use Mplayer by uncommenting the line containing "mplayer" and commenting the line containing "gxine"

Code: Select all

#!/bin/bash

list="/tmp/list.txt"
loc="`Xdialog --backtitle "Please choose directory..." --title "pmplay-1" --stdout --no-buttons --dselect /root/My-Music 0 0`"
if [ ! $? -eq 0 ];then
 exit
fi
string="`Xdialog --stdout --title "pmplay-2" --inputbox "Enter a word or format to search for:" 0 0 *.mp3`"

#find $loc -maxdepth 1 \( -iname "*$string*" \) 2> /dev/null > $list | rxvt -e mplayer -playlist $list
find $loc -maxdepth 1 \( -iname "*$string*" \) 2> /dev/null > $list | rxvt -e gxine -a $(cat /tmp/list.txt)

# make sure those filenames don't have spaces
# execute in dir
# for files in *.mp3; do mv "$files" `echo $files | tr ' ' '_'`; done

Cheers,
s

stu90

#3 Post by stu90 »

Hey nice one seaside :)

Here is update for Yad / Zenity Pmplay:

Now all in one window + added a third Box for playing pre made Mplayer playlists - leave Box1 and Box2 as the are and enter the path or drag the playlist to box three.

Image

Code: Select all

#!/bin/bash
#stu90 - pmplay v0.3

BOXR="/tmp/boxr"
PLAYL="/tmp/playlist"

yad --title "Pmplay" --form --separator=' ' \
--text " In Box1 enter or drag a directory to seach.  \n 
 In Box2 enter a file format or word to seach. \n
 Or In Box3 enter a pre made playlist to play." \
--field=Box1 '/root' \
--field=Box2  '.mp3' \
--field=Playlist > $BOXR

if [ $? = 1 ];
then exit
fi

PL=$(cat $BOXR | awk '{ print $3 }') 

if [ $PL ]; then
echo "playlist found '$PL'" 
rxvt -e mplayer -playlist $PL 
else  

DIR=$(cat $BOXR | awk '{ print $1 }')
STRING=$(cat $BOXR | awk '{ print $2 }')

retval=$?
case $retval in
0)
echo "Directory to search is '$DIR'"
echo "String to search for is '$STRING'"
find $DIR -maxdepth 1 \( -iname "*$STRING*" \) 2> /dev/null > $PLAYL | rxvt -e mplayer -playlist $PLAYL 
;;
1)
echo "Cancel pressed.";;
esac
rm $BOXR $PLAYL
fi
exit

Post Reply