[Alsaplayer-devel]simple player example
Andy Lo A Foe
andy@alsaplayer.org
Tue, 23 Apr 2002 09:50:32 +0200
--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Tue, Apr 23, 2002 at 02:23:33PM +1000, Jason Lewis wrote:
> I would like to write an interface between irmp3 and alsaplayer, is there
> some sample code that shows how to control alsaplayer from another program
> anywhere?
I have some sample code for use with libalsaplayer. I'll include them in
the next release.
For now, I'll attach some small samples I use for testing
libalsaplayer...
Regards,
Andy
--RnlQjJ0d97Da+TV1
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: attachment; filename="speed.c"
#include <alsaplayer/control.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main (int argc, char *argv[])
{
int i;
char str[1024];
float val = 0.0;
if (ap_get_string(0, AP_GET_STRING_SONG_NAME, str) != -1) {
printf("File playing: %s\n", str);
}
if (argc == 2) {
if (sscanf (argv[1], "%f", &val) == 1) {
if (val == 0.0) {
printf ("Pausing player\n");
ap_do (0, AP_DO_PAUSE);
} else {
float tester;
printf ("Setting speed to %.2f\n", val);
ap_set_float (0, AP_SET_FLOAT_SPEED, val);
}
}
}
if (ap_get_float(0, AP_GET_FLOAT_SPEED, &val) != -1) {
printf ("Current speed = %.2f\n", val);
}
return 0;
}
--RnlQjJ0d97Da+TV1
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: attachment; filename="seek.c"
#include <alsaplayer/control.h>
int main (int argc, char *argv[])
{
int pos;
if (argc == 2) {
pos = atoi(argv[1]);
if (ap_set_int (0, AP_SET_INT_POS_SECOND, pos) != -1) {
printf("Seeked to second %d\n", pos);
}
}
return 0;
}
--RnlQjJ0d97Da+TV1
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: attachment; filename="add.c"
#include <alsaplayer/control.h>
int main (int argc, char *argv[])
{
if (argc == 2) {
printf("Adding: %s\n", argv[1]);
ap_set_string (0, AP_SET_STRING_ADD_FILE, argv[1]);
}
return 0;
}
--RnlQjJ0d97Da+TV1--