From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- cdmp3/cmdmp3.c | 47 +++++++++++++++++++++++++++++++++ cdmp3/cmdmp3.exe | Bin 0 -> 42218 bytes cdmp3/cmdmp3win.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ cdmp3/cmdmp3win.exe | Bin 0 -> 43643 bytes cdmp3/readme.txt | 3 +++ 5 files changed, 124 insertions(+) create mode 100644 cdmp3/cmdmp3.c create mode 100644 cdmp3/cmdmp3.exe create mode 100644 cdmp3/cmdmp3win.c create mode 100644 cdmp3/cmdmp3win.exe create mode 100644 cdmp3/readme.txt (limited to 'cdmp3') diff --git a/cdmp3/cmdmp3.c b/cdmp3/cmdmp3.c new file mode 100644 index 0000000..1e92d0f --- /dev/null +++ b/cdmp3/cmdmp3.c @@ -0,0 +1,47 @@ +// cmdmp3 +// A command-line MP3 player for Windows +// (console-mode version) +// +// License: MIT / X11 +// Copyright (c) 2009, 2015, 2022 by James K. Lawless +// jimbo@radiks.net http://jiml.us +// See https://jiml.us/license2022.htm +// +// To build, use the following MinGW command: +// gcc cmdmp3.c -lwinmm -o cmdmp3.exe + +#include +#include +#include + +void sendCommand(char *); + +int main(int argc,char **argv) { + char cmdBuff[MAX_PATH + 64]; + printf("cmdmp3 v2.10\n"); + printf("Command-line MP3 player\n"); + printf("by Jim Lawless - https://jiml.us\n\n"); + + if(argc<2) { + fprintf(stderr,"Syntax:\n\tcmdmp3 \"c:\\path to file\\file.mp3\"\n"); + return 1; + } + sendCommand("Close All"); + + sprintf(cmdBuff,"Open \"%s\" Type MPEGVideo Alias theMP3",argv[1]); + sendCommand(cmdBuff); + + sendCommand("Play theMP3 Wait"); + return 0; +} + + // Send a string to the Media Control Interface + // If an error occurs, display it and the string + // that produced the error. +void sendCommand(char *s) { + int i; + i=mciSendString(s,NULL,0,0); + if(i) { + fprintf(stderr,"Error %d when sending %s\n",i,s); + } +} diff --git a/cdmp3/cmdmp3.exe b/cdmp3/cmdmp3.exe new file mode 100644 index 0000000..dc05768 Binary files /dev/null and b/cdmp3/cmdmp3.exe differ diff --git a/cdmp3/cmdmp3win.c b/cdmp3/cmdmp3win.c new file mode 100644 index 0000000..229694f --- /dev/null +++ b/cdmp3/cmdmp3win.c @@ -0,0 +1,74 @@ +// cmdmp3win +// A command-line MP3 player for Windows +// (window-mode version) +// +// License: MIT / X11 +// Copyright (c) 2009, 2015, 2022 by James K. Lawless +// jimbo@radiks.net https://jiml.us +// See https://jiml.us/license2022.htm +// +// To build, use the following MinGW command: +// gcc cmdmp3win.c -lwinmm -mwindows -o cmdmp3win.exe + + +#include +#include +#include + +char msg[256]; +char *title="cmdmp3win v2.20"; + +char *parse_arg(char *); +void sendCommand(char *); + +int WINAPI WinMain( HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow ) { + + char cmdBuff[MAX_PATH + 64]; + char *arg; + + arg=parse_arg(lpCmdLine); + + if(arg==NULL) { + sprintf(msg,"Syntax:\n\tcmdmp3win \"c:\\path to file\\file.mp3\"\n"); + MessageBox(NULL,msg,title,MB_OK); + return 1; + } + sendCommand("Close All"); + sprintf(cmdBuff,"Open \"%s\" Type MPEGVideo Alias theMP3",arg); + sendCommand(cmdBuff); + + sendCommand("Play theMP3 Wait"); + return 0; +} + + // parse a single command-line argument. + // remove enclosing double-quotes if present + // return a new string +char *parse_arg(char *s) { + char *p; + char c; + p=strdup(s); + while((*p==' ')||(*p=='\t')) + p++; + c=*p; + if(c=='\"') + p=strtok(p+1,"\""); + else + p=strtok(p," \t"); + return p; +} + + // Send a string to the Media Control Interface + // If an error occurs, display it and the string + // that produced the error. +void sendCommand(char *s) { + int i; + i=mciSendString(s,NULL,0,0); + if(i) { + sprintf(msg,"Error %d when sending %s\n",i,s); + MessageBox(NULL,msg,"cmdmp3win",MB_OK); + } +} diff --git a/cdmp3/cmdmp3win.exe b/cdmp3/cmdmp3win.exe new file mode 100644 index 0000000..101456d Binary files /dev/null and b/cdmp3/cmdmp3win.exe differ diff --git a/cdmp3/readme.txt b/cdmp3/readme.txt new file mode 100644 index 0000000..8746543 --- /dev/null +++ b/cdmp3/readme.txt @@ -0,0 +1,3 @@ +Please see the blog post at: + +https://jiml.us/posts/cmdmp3/ -- cgit v1.2.3