Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

MPlayer function



Hi all,

this is new version of my mplayer's completion function. Support at
least 0.50, 0.60 and CVS Version. I use cache for stock drivers and
codes list.

I need to add the completion for the skins but i don't use the GUI..

comments about _mplayer are welcome

PS : i'm looking for the way to do a periodic rehash.. it's possible ?

Thank you very much.

-- 
 Bruno Bonfils
 Admin Sys GNU/Linux
#compdef mplayer

#
# MPlayer Zsh function
#
# Feb 2002, Bruno Bonfils <asyd@xxxxxxxxx>
#
# thanks to #zsh@xxxxxxxxxxxxxxxxxxxx (specially Clint)
#

_audio-codec-list ()
{
    if ( [[ ${+_mplayer_audio_codec} -eq 0 ]] || 
	    _cache_invalid MPlayer_ac ) && 
	! _retrieve_cache MPlayer_ac; then
	
	local buffer version
	
	buffer=(${(@f)"$(mplayer -ac help)"})
	version=buffer[1]

	if [[ "$version" = *\0.50* ]]; then
	    _mplayer_audio_codec=(${buffer[3,-1]%% *})
	else
	    _mplayer_audio_codec=(${buffer[9,-1]%% *})
	fi

	_store_cache MPlayer_ac _mplayer_audio_codec
    fi

    _wanted audio-codec expl 'audio-codec' compadd $_mplayer_audio_codec
}

_audio-driver-list ()
{
    if ( [[ ${+_mplayer_audio_driver} -eq 0 ]] ||
	    _cache_invalid MPlayer_ao ) &&
	! _retrieve_cache MPlayer_ao; then
	
	local buffer version

	buffer=(${(@f)"$(mplayer -ao help)"})
	version=$buffer[1]

	if [[ "$version" = *\0.50* ]]; then
	    _mplayer_audio_driver=(${${buffer[3,-1]/[[:blank:]]/}%%[[:blank:]]*})
	else
	    _mplayer_audio_driver=(${${buffer[7,-1]/[[:blank:]]/}%%[[:blank:]]*})
	fi

	_store_cache MPlayer_ao _mplayer_audio_driver

    fi

    _wanted audio-driver expl 'audio-driver' compadd $_mplayer_audio_driver
}

_video-codec-list ()
{
    if ( [[ ${+_mplayer_video_codec} -eq 0 ]] || 
	    _cache_invalid MPlayer_vc ) && 
	! _retrieve_cache MPlayer_vc; then
	
	local buffer version
	
	buffer=(${(@f)"$(mplayer -vc help)"})
	version=buffer[1]

	if [[ "$version" = *\0.50* ]]; then
	    _mplayer_video_codec=(${buffer[3,-1]%% *})
	else
	    _mplayer_video_codec=(${buffer[9,-1]%% *})
	fi

	_store_cache MPlayer_vc _mplayer_video_codec
    fi

    _wanted video-codec expl 'video-codec' compadd $_mplayer_video_codec
}

_video-driver-list ()
{
    if ( [[ ${+_mplayer_video_driver} -eq 0 ]] ||
	    _cache_invalid MPlayer_vo ) &&
	! _retrieve_cache MPlayer_vo; then
	
	local buffer version

	buffer=(${(@f)"$(mplayer -vo help)"})
	version=$buffer[1]

	if [[ "$version" = *\0.50* ]]; then
	    _mplayer_video_driver=(${${buffer[3,-1]/[[:blank:]]/}%%[[:blank:]]*})
	else
	    _mplayer_video_driver=(${${buffer[7,-1]/[[:blank:]]/}%%[[:blank:]]*})
	fi

	_store_cache MPlayer_vo _mplayer_video_driver

    fi

    _wanted video-driver expl 'video-driver' compadd $_mplayer_video_driver
}


_arguments -C -s \
    '-abs[sound card audio buffer size(in bytes, default: measuring)]:buffer size' \
    '-ac[force usage of a specific audio codec]:audio-codec attachment:_audio-codec-list' \
    '-afm[force usage of a specific audio codec family]:audio-codec-family:(1 2 3 4 5)' \
    '-aid[select audio channel]:audio-channel' \
    '-ao[audio driver]:audio-driver attachment:_audio-driver-list' \
    '-aspect[set aspect ratio of movies]:ratio' \
    '-benchmark[use with combination with -nosound and -vo null for benchmarking]' \
    '-chapter[specify which chapter to start playing at]:chapter' \
    '-config[specifies where to search for config files]' \
    '-delay[audio delay in seconds (may be +/- float value)]:delay' \
    '-display[specify the hostname and display number of the X server]:display attachment:_x_display' \
    '-double[enable double buffering]' \
    '-dumpaudio[writes audio stream of the file to ./stream.dump]' \
    '-dvdkey[key to decrypt stream encoded with css]:key' \
    '-dvd[tell MPlayer which movies to play]:titleid' \
    '-fbmode[change videomode from /etc/fb.modes]:fbmode' \
    '-fbmodeconfig[use config file instead /etc/fb.modes]:fbmodeconfig:_files' \
    '-fb[specifies the framebuffer device to user]' \
    '-ffactor[resample alphamap of the font]:factor:(0 0.75 1 10)' \
    '-forceidx[force rebuilding of index]' \
    '-forcexv[force using xvideo (sdl)]' \
    '-fps[force frame rate (if value is wrong in the header)]:frame-rate' \
    '-framedrop[enable slow dropping (for slow machine)]' \
    '-framedrop[frame dropping]' \
    '-frames[mplayer plays number frame, and quits]:frame-number' \
    '-fs[fullscreen]' \
    '-fsmode[fullscreen mode]:fs-mode:(0 1 2 3)' \
    '-gui[start with the gui]' \
    '-idx[rebuilds index of the avi]' \
    '-include[specify config file to be parsed after the default]:config-file:_files' \
    '-lircconf[specifies a configfile for lirc]:lirc-config-files attachment:_files' \
    '-mc[maximun sync correction per 5 frames (in second)]:max-sync-correction' \
    '-monitoraspect[set aspect ratio of your screen]:ratio' \
    '-ni[force usage of non-interlaced avi parser]' \
    '-nobps[do not use avg byte/sec value for A-V sync (AVI)]' \
    '-nobps[use alternative A-V sync method for AVI files]' \
    '-nodouble[disable double buffering (default)]' \
    '-nodshow[disable usage of directshow video codecs]' \
    '-noframedrop[no frame dropping]' \
    '-nosound[no sound]' \
    '-osdlevel[specifies which mode the osd should start]:osd-level:(0 1 2)' \
    '-pp[apply postprocess filter]:filter attachment:_filter-list' \
    '-quiet[display less output, status messages]' \
    '-sb[seek to byte position]:byte' \
    '-skin[skin directory]:skin directory:_path_files -/' \
    '-srate[specifies Hz to playback audio on]:frequence' \
    '-ss[seek to given time position (format hh:mm\[:ss\])]:position' \
    '-steromode[select type of mpeg1 stereo output]:stereo-mode:(0 1 2)' \
    '-subfps[specify frame/sec rate of subtitle file only]:rate' \
    '-sub[use/display this subtitle file]:subtitle:_files' \
    '-unicode[tells mplayer to handle the subtitle file as unicode]' \
    '-utf8[tells mplayer to handle the subtitle file as utf8]' \
    '-vcd[play video cd track]:track' \
    '-vc[force usage of a specific video codec]:video-codec attachment:_video-codec-list' \
    '-v[enable verbose output]' \
    '-vfm[force usage of a specific video codec family]:video-codec-family:(1 2 3 4 5)' \
    '-vid[select video channel]:video-channel' \
    '-vm[use XF86VidMode extension for mode changing]' \
    '-vo[video driver]:video-driver attachment:_video-driver-list' \
    '-x[scale image to x width if driver supports]:width' \
    '-xy[scale image by factor if driver supports]:factor' \
    '-y[scale image to y height if driver supports]:height' \
    '-zoom[use software scaling, where available (use with -nofs)]' \
    '-z[specify compression level for png output]:compression-level:(0 1 2 3 4 5 6 7 8)' \
    '*:video file:_files -g \*\.\(\#i\)\(mpg\|avi\|mpeg\|mov\|asf\|vob\|mjpg\)' \
    && return 0
return 1

Attachment: pgpOk6yxMzKGB.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author