#! /bin/bash
#
Encoding=UTF-8
#############################################################################
#																			#
# Author D.M-Wilhelm aka Leiche <kellerleicheorig@aol.com> at Nov 05 2010	#
# Website <kellerleiche.bplaced.net> 										#
# Designed for PCLinuxOS'10													#
# Release 2010-2018 														#
# License GPL2																#
#																			#
#############################################################################
				

######## i18n - Internationalization - Internationalisierung ###########
export TEXTDOMAIN=pclos-flv-main
export TEXTDOMAINDIR="/usr/share/locale"
#
############# some functions to handle pclos-flv-player ################ 
#	
function func_playlist () {
	yad --button="gtk-ok:0" --title "$TITLE$VERSION" \
		--window-icon="$ICON" --image="$ICON0"\
		--width=300 \
		--text $"No directory selected, starting without any files! \n\nIf you have no playlist generated, so restart <b>'$TITLE'</b>, and select a directory!"
		if [ -f $TMP_DIR/browser1 ]; then
			mv $TMP_DIR/browser1 $TMP_DIR/browser
		fi
}		
function func_search () {
	find "$FIND" -name "*.mp4" -o -name "*.flv" -o -name "*.avi" -o -name "*.webm" -o -name "*.mkv"| sort -f | while read programm; do echo "$programm" >> $TMP_DIR/movfiles ; done
	yad --text $"<b>Please wait, searching for movie files!</b>" --timeout 5 \
		--title "$TITLE $VERSION" --width=350 \
		--window-icon="$ICON" --image=$ICON0 --button="gtk-ok:0" 
		if [ -f $TMP_DIR/browser1 ]; then
			mv $TMP_DIR/browser1 $TMP_DIR/browser
			echo "$FIND" > $TMP_DIR/directory
		fi	
}
		
#
######################### main variables ###############################
#
{
TITLE=$"FLV-Player and Converter"
TITLE1=$"FLV-Converter"
ICON="pclos_flv_main"
ICON0="/usr/share/icons/large/pclos_flv_main.png"
ICON1="/usr/share/PCLinuxOS-FLV-Player/icons/flv_convert64.png"
dirname="$(dirname "$(readlink -e "$0")")"
VERSION=" `cat "$dirname"/Version`"
ICON_GUI="$dirname"/icons
HELP="$dirname"/help
SETTINGS="$dirname"/settings
BATCH_C="$dirname"/batch_convert
MOVGRAB="$dirname"/movgrabgui
PROGRESSBAR="$dirname"/progressbar
xwinwrap=xwinwrap
cutter="$dirname"/mp4-cutter
TMP_DIR=$HOME/.config/pclos-flv-player
TMP_DIR1=$HOME/tmp/batch_convert
DIRECTORY=`cat $TMP_DIR/directory`
SAVE_STATUS=`cat "$TMP_DIR"/s_directory`
#
##################### create config directory ##########################
#
if [ ! -d $TMP_DIR ]; then
	mkdir $HOME/.config/pclos-flv-player
fi
#
####################### create tmp directory ###########################
#
if [ ! -d $TMP_DIR1 ]; then
	mkdir $HOME/tmp/batch_convert
fi
#
## create a file to use a directory with default value at first start ##
#
if [ -f $TMP_DIR/directory ]; then
	echo $"directory $DIRECTORY is used"
	else
	echo $HOME/Downloads > $TMP_DIR/directory
	echo $"directory created"
fi
#
# create a file to store audio files with default value at first start #
#
if [ -f "$TMP_DIR"/s_directory ]; then
	echo $"save directory found"
else
	echo $HOME > "$TMP_DIR"/s_directory
	echo $"save directory created"
fi
#		
#################### old movfiles must removed #########################
#
if [ -f $TMP_DIR/movfiles ]; then
	rm -rf $TMP_DIR/movfiles
fi
#
#################### read status of config files #######################
#
if [ $(grep -c true "$TMP_DIR"/playlistmode) -gt 0 2>/dev/null ]; then
	PLM_STATUS=true
	else
	PLM_STATUS=false
fi	
if [ $(grep -c fs "$TMP_DIR"/fullscreen) -gt 0 2>/dev/null ]; then
	FS_STATUS=true
	else
	FS_STATUS=false
fi
if [ $(grep -c novideo "$TMP_DIR"/novideo) -gt 0 2>/dev/null ]; then
	VID_STATUS=true
	else
	VID_STATUS=false
fi
if [ $(grep -c shuffle "$TMP_DIR"/shuffle) -gt 0 2>/dev/null ]; then
	SHU_STATUS=true
	else
	SHU_STATUS=false
fi
if [ $(grep -c loop "$TMP_DIR"/loop) -gt 0 2>/dev/null ]; then
	LOOP_STATUS=true
	else
	LOOP_STATUS=false
fi
if [ -f /usr/bin/avconv ]; then
	CONVERTER=avconv
	echo $"avconv is used"
	elif [ -f /usr/bin/ffmpeg ]; then
	CONVERTER=ffmpeg
	echo $"ffmpeg is used"
	else
	yad --text $"<b>Sorry, no converter is installed, please install ffmpeg or libav!</b>" \
		--title "$TITLE $VERSION" --width=350 \
		--window-icon=$ICON --image=$ICON0 --button="gtk-ok:0" 
	echo $"no converter found!"
fi
if [ -f /usr/bin/sleeptimer ]; then
	echo sleeptimer is installed
	SLEEPTIMER="<menuitem><label>Sleeptimer</label><action>exec sleeptimer &</action></menuitem>"
fi	 
if [ -f /usr/bin/alert_clock ]; then
	echo alert_clock is installed
	ALERT_CLOCK="<menuitem><label>Alert Clock</label><action>exec alert_clock &</action></menuitem>"
fi	
if [ -f /usr/bin/xwinwrap ]; then
	XWINWRAP=true
	else
	XWINWRAP=false
fi

}
#
# open and load files
# choose where to search
#
{
if [ -f $TMP_DIR/browser ];then
	FIND=`cat  $TMP_DIR/directory`
	else
	FIND=$( yad --file-selection --directory \
			--filename=$DIRECTORY \
			--title "$TITLE $VERSION" \
			--window-icon="$ICON" \
			--width=800 --height=600 \
			--text=$"\tA simple player for your stored videos from youtube or other websites \n\
	using flv/mp4 type videos. With the converter you can convert the audio \n\
	to mp3, wav, ogg, aac, flac or wma. It is easy to use.\n\
	You need only to select a directory.\n\
	<b>_________________________________________________________________________</b>"\
			)
fi			
if [ "$FIND" = "" ]; then								             # add entry
	func_playlist
	else
	func_search	
fi		
}
############################## Main Window #############################
{
export PCLOS_FLV='
<window window_position="1" title="'$TITLE$VERSION'" maximize_initially="true" allow-shrink="true" icon-name="pclos_flv_main" space-fill="true">
	<vbox space-fill="true">
	<menubar>
			<menu>
				<menuitem stock="gtk-open">
					<label>'$"Open"'</label>
					<action>mv '$TMP_DIR'/browser '$TMP_DIR'/browser1</action>
					<action>exec pclos-flv-main &</action>
					<action type="exit">PCLOS_FLV</action>
				</menuitem>	
				<menuitem icon-name="open">
					<label>'$"Reload"'</label>
					<action>rm -rf '"$TMP_DIR"'/movfiles ; find "'"$FIND"'" -name "*.mp4" -o -name "*.flv" -o -name "*.avi" -o -name "*.webm" -o -name "*.mkv" | sort -f | while read programm; do echo "$programm" >> '"$TMP_DIR"'/movfiles ; done </action>
					<action type="refresh">SELECT</action>
				</menuitem>		
			<separator></separator>
				<menuitem stock="gtk-quit">
					<action>rm -rf '$TMP_DIR'/movfiles</action>
					<action type="exit">PCLOS_FLV</action>
				</menuitem>
				<label>'$"File"'</label>
			</menu>
			
			<menu>
				<menuitem icon-name="gtk-preferences"> 
					<label>'$"Settings"'</label>
					<action>'$SETTINGS' &</action>
				</menuitem> 
				<label>'$"Edit"'</label>
			</menu>
    
			<menu>
				<menuitem>
					<label>MediaInfo</label>
					<action>if [ -f /usr/bin/mediainfo ];then xterm -hold -e mediainfo "$SELECT"; else yad --text=$"MediaInfo is not found, use Synaptic to install mediainfo_cli!" --title '"$TITLE"' --width=350 --window-icon='$ICON' --image='$ICON' --button="gtk-ok:0"; fi &</action>
				</menuitem>
				'$SLEEPTIMER'
				'$ALERT_CLOCK'
				<menuitem>
					<label>Movgrab</label>
					<action>'$MOVGRAB' &</action>
				</menuitem>
				<menuitem> 
					<label>'$"Batch Converter"'</label>
					<action>'$BATCH_C' &</action>
				</menuitem>
				<label>'$"Tools"'</label>
			</menu>

			<menu>
				<menuitem stock="gtk-help">
					<label>'$"About"'</label>
					<action>'$HELP' &</action>
				</menuitem>
					<label>'$"Help"'</label>
			</menu>
		</menubar>
		

		<frame>
			<notebook labels="'$"Available|Playlist"'" space-expand="true" space-fill="true" allow-shrink="true">
				<vbox space-expand="true" allow-shrink="true" space-fill="true">
					<vbox tooltip-text="'$"If no files are displayed below the list, maybe the list is too long, or no files are available!"'">
						<text use-markup="True"><label>"'$"Click on the file you want to open from the list below"'"</label></text>  
						<tree rules_hint="true" exported_column="0" selection-mode="3" allow-shrink="true" space-fill="true">
							<height>200</height>
							<variable>SELECT</variable>
							<label>'$"Available"'</label>
							<input file>'$TMP_DIR'/movfiles</input> 
						</tree> 
					</vbox>	 
						<vbox space-expand="true" tooltip-text="'$"Choose your settings to convert your media files!"'" space-fill="true">
							<text use-markup="True">
							<label>"'$"Select a profile, and click on Convert!"'"</label>
							</text>
							<hbox space-expand="true" space-fill="true" allow-shrink="true">
								<tree column-visible ="false|true|true" space-fill="true" allow-shrink="true">
								<height>260</height>
									<variable>CONVERT</variable>
									<label>|'$"Select a Profile				                         "'|'$"Format"'</label>
									<item>-acodec libmp3lame -ab 96k -ac 2 -ar 44100|Lame 96kb|MP3</item>
									<item>-acodec libmp3lame -ab 128k -ac 2 -ar 44100|Lame 128kb|MP3|'$"Default settings"'</item>
									<item>-acodec libmp3lame -ab 160k -ac 2 -ar 44100|Lame 160kb|MP3</item>
									<item>-acodec libmp3lame -ab 192k -ac 2 -ar 44100|Lame 192kb|MP3</item>
									<item>-acodec libmp3lame -ab 224k -ac 2 -ar 44100|Lame 224kb|MP3</item>
									<item>-acodec libmp3lame -ab 256k -ac 2 -ar 44100|Lame 256kb|MP3</item>
									<item>-acodec libmp3lame -ab 320k -ac 2 -ar 44100|Lame 320kb|MP3</item>
									<item>-acodec libvorbis -aq 0 -vn -ac 2|Vorbis 50-70kb|OGG</item>
									<item>-acodec libvorbis -aq 1 -vn -ac 2|Vorbis 65-85kb|OGG</item>
									<item>-acodec libvorbis -aq 2 -vn -ac 2|Vorbis 80-100kb|OGG</item>
									<item>-acodec libvorbis -aq 3 -vn -ac 2|Vorbis 90-130kb|OGG</item>
									<item>-acodec libvorbis -aq 4 -vn -ac 2|Vorbis 110-150kb|OGG</item>
									<item>-acodec libvorbis -aq 5 -vn -ac 2|Vorbis 145-185kb|OGG</item>
									<item>-acodec libvorbis -aq 6 -vn -ac 2|Vorbis 170-210kb|OGG</item>
									<item>-vn  -acodec wmav2 -ab 128k|Windows Media Audio 128kb|WMA</item>
									<item>-vn  -acodec wmav2 -ab 160k|Windows Media Audio 160kb|WMA</item>
									<item>-vn  -acodec wmav2 -ab 192k|Windows Media Audio 192kb|WMA</item>
									<item>-vn -acodec libfaac -ab 112k -ac 2|Advanced Audio Codec 112kb|AAC</item>
									<item>-vn -acodec libfaac -ab 128k -ac 2|Advanced Audio Codec 128kb|AAC</item>
									<item>-vn -acodec libfaac -ab 152k -ac 2|Advanced Audio Codec 152kb|AAC</item>
									<item>-acodec flac -ar 44100 -ac 2|RAW Audio 44,1 Hz|FLAC</item>
									<item>-acodec flac -ar 48000 -ac 2|RAW Audio 48 Hz|FLAC</item>
									<item>-vn -ar 44100|Wave Audio 44,1 Hz|WAV</item>
									<item>-vn -ar 48000|Wave Audio 48 Hz|WAV</item>
								</tree>
							</hbox>
						</vbox>
						<vbox space-fill="true">	
							<hbox allow-shrink="true" space-fill="true">
							
							<vbox tooltip-text="'$"You can use this video cutter program to cut MP4 file"'">
									<button hide="false" >
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/remove24.png</input>
										<label>'$"Cutter"'</label>
										<variable>CUT</variable>
										<action>echo "$SELECT" > '$HOME'/.mplayer/cut_file</action>
										<action>'$cutter' &</action>
									</button>
							</vbox>
								
							<vbox tooltip-text="'$"corrected file name, remove special characters like (),[],!?,{}"'">
									<button hide="false" >
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/correction24.png</input>
										<label>'$"Correction"'</label>
										<variable>CORRECTION</variable>
										<action>REN=`echo "$SELECT" | sed -e "s/ \[.*\]\((.*)\)\?//;s/ (.*)\(\[.*\]\)\?//;s/ {.*}\({.*}\)\?//;s/ ?//;s/ \*//;s/ &//;s/ #//;s/ (//;s/ \[//;s/ //"`; mv "$SELECT" "$REN" ; rm -rf '"$TMP_DIR"'/movfiles ; find '"$FIND"' -name "*.mp4" -o -name "*.flv" -o -name "*.avi" -o -name "*.webm" | sort -f | while read programm; do echo "$programm" >> '"$TMP_DIR"'/movfiles ; done  </action>
										<action type="refresh">SELECT</action>
									</button>
							</vbox>
								
								<vbox tooltip-text="'$"Add current file to batch-list!"'">
									<button hide="false" >
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/batch24.png</input>
										<label>'$"Batch Convert"'</label>
										<variable>BATCH_CONVERT</variable>
										<action>if [ "$SELECT" ]; then (echo && ASK=`basename "$SELECT"` && CUT=$(echo "$ASK" |  cut -d "." -f 1) && ffmpeg -y -i "$SELECT" -vn -ar 44100  "'$TMP_DIR1'/$CUT.wav") | yad --undecorated --center --no-buttons --progress --pulsate --auto-close --width=500 --title '$TITLE' --image='$ICON' --window-icon='$ICON' --text=$"Add audio, this will take some minutes, please wait..."; fi </action>
									</button>
								</vbox>
								
								<vbox tooltip-text="'$"Add a movie file to your playlist!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/add24.png</input>
										<label>'$"Add"'</label>
										<action>( echo && echo "$SELECT" >> '$TMP_DIR'/playlist) | yad  --center --progress --pulsate --width=500 --title '$TITLE' --image='$ICON' --window-icon='$ICON' --text=$"Added $SELECT..." </action>
										<action type="refresh">PLAYLIST</action>
									</button>
								</vbox>	
								
								<vbox tooltip-text="'$"See your selected video."'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/play24.png</input>
										<label>'$"Play"'</label>
										<action>ASK=`basename "$SELECT"` ; killall mplayer ;mplayer `cat '$TMP_DIR'/position` `cat '$TMP_DIR'/scale` "$SELECT" -title "$ASK" &</action>
									</button>
								</vbox>

								<vbox tooltip-text="'$"Convert selected file to mp3, wav, ogg, mpeg4 or wma. Be sure you have set a profile!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/convert24.png</input>
										<label>'$"Convert"'</label>
										<action>echo $CONVERT > '$TMP_DIR'/converter_settings</action>
										<action>if [ $(grep -c libmp3lame "'$TMP_DIR'"/converter_settings) -gt 0 ]; then EXT=mp3; elif [ $(grep -c libvorbis "'$TMP_DIR'"/converter_settings) -gt 0 ]; then EXT=ogg ; elif [ $(grep -c wmav2 "'$TMP_DIR'"/converter_settings) -gt 0 ]; then EXT=wma ; elif [ $(grep -c libfaac "'$TMP_DIR'"/converter_settings) -gt 0 ]; then EXT=aac ; elif [ $(grep -c flac "'$TMP_DIR'"/converter_settings) -gt 0 ]; then EXT=flac ; elif [ $(grep -c ar "'$TMP_DIR'"/converter_settings) -gt 0 ]; then  EXT=wav ; else  echo copy audio  ; fi ; SEL=$(echo "$SELECT" |  cut -d "." -f 1) ; ASK=`basename "$SEL"` ; if [ $(grep -c hide "$TMP_DIR"/s_directory) -gt 0 ]; then SAVE=`cat '$TMP_DIR'/s_directory` ; else SAVE=$(yad --file-selection --save --filename="$SEL.$EXT" --confirm-overwrite=$"$ASK.$EXT exist, you want to overwrite?" --window-icon='$ICON' --width=800 --height=600  --file-filter="*.$EXT" --title='$TITLE1') ; if [ $? = 0 ]; then (echo && '$CONVERTER' -y -i "$SELECT" $CONVERT "$SAVE") | yad --button=$"Hide:1" --center --progress --pulsate --auto-close --width=300 --title '$TITLE1' --image='$ICON' --window-icon='$ICON' --text=$"Convert\n\n$SELECT \n\nto \n\n$SAVE \n\nplease wait..." ; fi ; fi &</action>
									</button>
								</vbox>
			
								<vbox tooltip-text="'$"Remove the selected track!"'">
									<button>
										<label>'$"Delete"'</label>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/delete24.png</input>
										<action>yad --text=$"Are you sure you want to delete $SELECT from your drive?" --window-icon='$ICON' --width 600 --title="Remove..." ; if [ $? = 0 ]; then grep -v "$SELECT" '"$TMP_DIR"'/movfiles > '"$TMP_DIR"'/movfiles_tmp ; mv '"$TMP_DIR"'/movfiles_tmp '"$TMP_DIR"'/movfiles ; echo  "$SELECT" | sed "s:\\\n: :g"| parallel rm -rf '"{}"' ; fi</action>
										<action type="refresh">SELECT</action>
									</button>
								</vbox>
							</hbox>	
						</vbox>
					</vbox> 
					
					<vbox space-expand="true" space-fill="true" allow-shrink="true">
						<vbox tooltip-text="'$"If no files are displayed below the list, you have no playlist generated!"'" space-fill="true">  
							<text use-markup="True"><label>"'$"Click on the file you want to open from the list below"'"</label></text>  
							<tree rules_hint="true" exported_column="0" selection-mode="3" allow-shrink="true" space-fill="true">
								<height>350</height>
								<variable>PLAYLIST</variable>
								<label>'$"My playlist"'</label>
								<input file>'$TMP_DIR'/playlist</input> 
							</tree> 
						</vbox>	 		
						<frame>
							<checkbox active="'$PLM_STATUS'">
								<label>'$"Enable playlists mode!"'</label>
								<variable>PL_LIST_MODE</variable>
								<action>if true echo true > '"$TMP_DIR"'/playlistmode</action>
								<action>if false echo false > '"$TMP_DIR"'/playlistmode</action>
							</checkbox>
							<checkbox active="'$SHU_STATUS'">
								<label>'$"Play your playlist in shuffle mode!"'</label>
								<variable>SHUFFLE</variable>
								<action>if true echo -shuffle > '"$TMP_DIR"'/shuffle</action>
								<action>if false echo > '"$TMP_DIR"'/shuffle</action>
							</checkbox>
							<checkbox active="'$LOOP_STATUS'">
								<label>'$"Play your playlist in loop mode!"'</label>
								<variable>LOOP</variable>
								<action>if true echo -loop 0 > '"$TMP_DIR"'/loop</action>
								<action>if false echo > '"$TMP_DIR"'/loop</action>
							</checkbox>
							<checkbox active="'$FS_STATUS'">
								<label>'$"Play your playlist in full screen mode!"'</label>
								<variable>FULLSCREEN</variable>
								<action>if true echo -fs > '"$TMP_DIR"'/fullscreen</action>
								<action>if true disable:NOVID</action>
								<action>if false enable:NOVID</action>
								<action>if false echo > '"$TMP_DIR"'/fullscreen</action>
							</checkbox>
							<checkbox active="'$VID_STATUS'">
								<label>'$"Play your playlist without video display!"'</label>
								<variable>NOVID</variable>
								<action>if true echo -novideo > '"$TMP_DIR"'/novideo</action>
								<action>if true disable:FULLSCREEN</action>
								<action>if false enable:FULLSCREEN</action>
								<action>if false echo > '"$TMP_DIR"'/novideo</action>
							</checkbox>	
						</frame>
							<hbox allow-shrink="true" space-fill="true">  
								<vbox tooltip-text="'$"Remove a movie file from your playlist!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/remove24.png</input>
										<label>'$"Remove"'</label>
										<action>yad --text=$"Are you sure you want to remove $PLAYLIST from your playlist?" --window-icon='$ICON' --title="Remove $PLAYLIST" ; if [ $? = 0 ]; then grep -v "$PLAYLIST" '"$TMP_DIR"'/playlist > '"$TMP_DIR"'/playlist_tmp ; mv '"$TMP_DIR"'/playlist_tmp '"$TMP_DIR"'/playlist ; fi</action>
										<action type="refresh">PLAYLIST</action>
									</button>
								</vbox>	
								
								<vbox tooltip-text="'$"Save your current playlist!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/save24.png</input>
										<label>'$"Save Playlist"'</label>
										<action>SAVE_P=$(yad --file-selection --save --window-icon='$ICON' --width=800 --height=600 --title=$"Save Playlist") ; if [ $? = 0 ]; then cp '"$TMP_DIR"'/playlist $SAVE_P; fi</action>
									</button>
								</vbox>
								
								<vbox tooltip-text="'$"Load a playlist! Note: Your current playlist will be overwritten!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/open24.png</input>
										<label>'$"Open Playlist"'</label>
										<variable>LOAD_P</variable>
										<action>LOAD_P=$(yad --file-selection --window-icon='$ICON' --width=800 --height=600 --title=$"Open Playlist") ; if [ $? = 0 ]; then cp $LOAD_P '"$TMP_DIR"'/playlist; fi</action>
										<action type="refresh">PLAYLIST</action>
									</button>
								</vbox>
								
								<vbox tooltip-text="'$"Play a movie, or playlist!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/play24.png</input>
										<label>'$"Play"'</label>
										<action>if [ $(grep -c false '"$TMP_DIR"'/playlistmode) -gt 0 ]; then SEL=$(echo "$PLAYLIST" |  cut -d "." -f 1) ; ASK=`basename "$SEL"` ; killall mplayer ;mplayer `cat '$TMP_DIR'/position` `cat '$TMP_DIR'/scale` "$PLAYLIST" -title "$ASK"; else killall mplayer ; mplayer `cat '$TMP_DIR'/position` `cat '$TMP_DIR'/scale` `cat '$TMP_DIR'/loop` `cat '$TMP_DIR'/shuffle` `cat '$TMP_DIR'/fullscreen` `cat '$TMP_DIR'/novideo` -playlist '"$TMP_DIR"'/playlist ; fi&</action>
										<action>sleep 1 ; pidof mplayer > '$TMP_DIR'/pid</action>
									</button>
								</vbox>
								
								<vbox tooltip-text="'$"The shantz-xwinwrap plays your movies as your wallpaper. Note: Playlist mode must not selected, and only the shuffle mode works currently."'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/play24.png</input>
										<label>'$"XWinWrap-Play"'</label>
										<action>if [ $(grep -c false '"$TMP_DIR"'/playlistmode) -gt 0 ]; then SEL=$(echo "$PLAYLIST" |  cut -d "." -f 1) ; ASK=`basename "$SEL"` ; killall mplayer ; "'$xwinwrap'" -ni -o 1 -fs -s -st -sp -b -nf -- mplayer -wid WID -quiet  -vo gl_nosw -playlist '"$TMP_DIR"'/playlist `cat '$TMP_DIR'/shuffle` ; fi&</action>
										<action>sleep 1 ; pidof mplayer > '$TMP_DIR'/pid</action>
										<visible>'$XWINWRAP'</visible>
									</button>
								</vbox>
								
								<vbox tooltip-text="'$"Stop playback!"'">
									<button>
										<input file>/usr/share/PCLinuxOS-FLV-Player/icons/stop24.png</input>
										<label>'$"Stop"'</label>
										<action>kill `cat '$TMP_DIR'/pid`</action>
									</button>
								</vbox>
							</hbox>		
					</vbox> 
			</notebook>
		</frame>
	</vbox>
</window>
'
gtkdialog --program=PCLOS_FLV #> /dev/null 2>&1
}
