#include "config.h" #include #include #include "caviplay.h" #include #include "ctrackbar.h" #define DESC "AVI player for XMMS" // #define VERSION "1.0.1" cPlayer *pl=NULL; void showConfig(); void showAbout(); extern "C" { extern InputPlugin *get_iplugin_info(void); }; #define EXT(a) (!strcasecmp(ext,"." a)) || static gint detect(gchar *filename) { char *ext = strrchr(filename, '.'); if (!ext) return FALSE; return ( EXT("avi") EXT("msvideo") EXT("asf") EXT("wma") EXT("wmv") EXT("divx") 0 )?TRUE:FALSE; } static void play(gchar *filename) { pl=new cPlayer(); if (!pl->open(filename)) { delete pl; pl=NULL; return; }else { pl->play(); get_iplugin_info()->set_info(filename,pl->len(),1000,44100,2); } } static void stop(void) { if (pl) { pl->close(); delete pl; pl=NULL; } } static void pause(short p) { if (pl) { pl->pause(p); } } static void seek(gint time) { if (pl) pl->seek(time); } static gint get_time(void) { if (pl) { /* FIXME */ if ( (pl->len()-pl->tell())<60) return -1; else { int tl=pl->tell(),ln=pl->len(); if ((tl>0)&&(ln>0)) trk_seek((double)tl/(double)ln); return pl->tell(); } } else return -1; } void call_gettime() {get_time();} static void songinfo(gchar * filename, gchar ** title, gint * length) { cPlayer *tmp=new cPlayer(); long l; char *tt; if (tmp->query(filename,&l,&tt)) { *length=l; *title=tt; }else { *length=-1; *title=strdup("(unable to read AVI)"); } delete tmp; } void init() { cPlayer::init(); } void deinit() { if (pl) {pl->close();delete pl;} cPlayer::deinit(); trk_deinit(); } void config(void) { showConfig(); } static void about(void) { showAbout(); } static InputPlugin plgAvi= { 0, 0, DESC " " VERSION, init, about, config, detect, 0,// scan_dir, play, stop, pause, seek, 0, get_time, 0,// getvol, 0,// setvol, deinit, 0, 0, 0,//setinfo 0,//setinfotext songinfo, 0, 0 }; InputPlugin *get_iplugin_info(void) { return &plgAvi; }