diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /cdmp3/cmdmp3.c | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'cdmp3/cmdmp3.c')
-rw-r--r-- | cdmp3/cmdmp3.c | 47 |
1 files changed, 47 insertions, 0 deletions
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 <windows.h> +#include <stdio.h> +#include <string.h> + +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); + } +} |