#!/bin/bash
touch ~/.tmp_mplay
dialog --title 'Assistant MPlayer' --msgbox 'VisuLinux par UNSIGNED (Script bash a la con)' 10 20
#Choix du support
dialog --title 'Assistant MPlayer' --menu 'Ou se trouve votre fichier ?' 15 30 2 disque 'Disque dur' cdrom 'Lecteur Cdrom' 2>~/.tmp_mplay
CHOIX_SUPPORT=`cat < ~/.tmp_mplay`

case $CHOIX_SUPPORT in
	disque)
		dialog --title 'Choisissez le fichier' --inputbox 'Nom du fichier :' 20 30 '/' 2>~/.tmp_mplay
		FICHIER=`cat < ~/.tmp_mplay`
	;;
	
	cdrom)
		TROUVE=`find /mnt/cdrom/ -name '*.avi' -print`
		#Recherche avec des majuscules
		if [ $TROUVE='' ]; then
			TROUVE=`find /mnt/cdrom/ -name '*.AVI' -print`
		fi

		#Il n'y a tjours rien
		if [ $TOUVE!='' ];then
			dialog --title 'Choisissez le fichier' --inputbox 'Nom du fichier :' 20 30 $TROUVE 2>~/.tmp_mplay
			FICHIER=`cat < ~/.tmp_mplay`
			
			#Check si le fichier existe ...
			#if ! [ -e $TROUVE ]; then
			#echo 'Impossible de le trouver'	
			#read
			#echo 'Fin du script'
			#exit 0;
			#fi
		fi
	;;
	*)
		echo 'Erreur dans le script !!'
		echo 'Veuillez envoyer un mail a soulrider@ifrance.com pour un rapport de Bug'
		
		exit 0
	;;
esac

#Choix de la resolution
dialog --title 'Assistant MPlayer' --menu 'Quelle resolution voulez-vous ?' 20 30 3 resolution1 '650x500' resolution2 '650x550' resolution3 '650x650' 2>~/.tmp_mplay

RESOLUTION=`cat < ~/.tmp_mplay`

case $RESOLUTION in
	resolution1)
	X=650
	Y=500
	;;
	resolution2)
	X=650
	Y=550
	;;
	resolution3)
	X=650
	Y=650
	;;
esac

#Efface le fichier tmp
rm -rf ~/.tmp_mplay


echo 'fichier :  ' $TROUVE 
echo 'resolution :' $X 'x' $Y

mplayer -vo x11 -afm 1 -x $X -y $Y "$TROUVE"
#mplayer -vo x11 -afm 1 -x 650 -y 500 /mnt/cdrom/CRYING\ FREEMAN.AVI
