3 * Copyright (c) 2006 acmesystems.it - john@acmesystems.it
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19 * Feedback, Bugs... info@acmesystems.it
26 #include <sys/types.h>
27 #include <sys/socket.h>
31 #define SOCKET_PATH "/tmp/foxmp3"
34 void print_usage(void){
35 printf("mp3_play COMANND PARAMETERS\n");
36 printf(" Commands :\n");
37 printf(" PLAY filename\n");
38 printf(" STREAM url [URL OF STREAM]\n");
39 printf(" STREAM pls [URL PLS FILE]\n");
40 printf(" VOLUME [0-255]\n");
43 printf(" BASS [0-255]\n");
46 void issue_command(unsigned char *str
){
48 struct sockaddr_un remote
;
50 if ((s
= socket(AF_UNIX
, SOCK_STREAM
, 0)) == -1) {
54 printf("Connecting to mp3d ...\n");
55 remote
.sun_family
= AF_UNIX
;
56 strcpy(remote
.sun_path
, SOCKET_PATH
);
57 len
= strlen(remote
.sun_path
) + sizeof(remote
.sun_family
);
58 if (connect(s
, (struct sockaddr
*)&remote
, len
) == -1) {
62 printf("Connected ...\n\nSending command -> \n%s\n\n", str
);
63 if (send(s
, str
, strlen(str
), 0) == -1) {
67 unsigned char loop
= 1;
69 if ((t
=recv(s
, str
, 2048, 0)) > 0) {
71 printf("The answer was -> \n%s\n", str
);
72 if((strstr(str
, "OK")) || (strstr(str
, "ERROR"))){
79 printf("Server closed connection\n");
86 int main(int argc
, char **argv
){
87 unsigned char buffer
[2048];
90 if(((!strcmp(argv
[1], "STOP")) || (!strcmp(argv
[1], "STATE")))
92 sprintf(buffer
, "%s", argv
[1]);
93 } else if(((!strcmp(argv
[1], "PLAY")) || (!strcmp(argv
[1], "VOLUME"))
94 || (!strcmp(argv
[1], "BASS"))) && (argc
== 3)){
95 sprintf(buffer
, "%s %s", argv
[1], argv
[2]);
96 } else if((!strcmp(argv
[1], "STREAM")) && (argc
== 4)
97 && ((!strcmp(argv
[2], "url")) || (!strcmp(argv
[2], "pls")))){
98 sprintf(buffer
, "%s %s %s", argv
[1], argv
[2],
102 if(buffer
[0] != '\0'){
103 issue_command(buffer
);
This page took 0.05161 seconds and 5 git commands to generate.