mirror of
https://github.com/rkd77/elinks.git
synced 2024-08-20 20:54:47 -04:00
contrib: cdplayer
This commit is contained in:
parent
cd1ebf97b7
commit
5f99ad9f88
2
contrib/cdplayer/Makefile
Normal file
2
contrib/cdplayer/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
cdplayer: cdplayer.c
|
||||
$(CC) -o $@ $< `libcdaudio-config --libs --cflags`
|
98
contrib/cdplayer/cdplayer.c
Normal file
98
contrib/cdplayer/cdplayer.c
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
Simple non-interactive CD Player
|
||||
|
||||
Copyright (C) 2007 Witold Filipczyk
|
||||
Email: witekfl@poczta.onet.pl
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version. See the file COPYING.
|
||||
|
||||
This program is distributed in hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even an implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <cdaudio.h>
|
||||
#include <string.h>
|
||||
|
||||
int drive;
|
||||
struct disc_info disc;
|
||||
struct disc_status status;
|
||||
|
||||
static inline int
|
||||
getCurrentTrack(void)
|
||||
{
|
||||
return status.status_current_track;
|
||||
}
|
||||
|
||||
static void
|
||||
prev(void)
|
||||
{
|
||||
int track;
|
||||
|
||||
track = getCurrentTrack();
|
||||
if (track > disc.disc_first_track)
|
||||
cd_play_track(drive, --track, disc.disc_total_tracks);
|
||||
}
|
||||
|
||||
static void
|
||||
next(void)
|
||||
{
|
||||
int track;
|
||||
|
||||
track = getCurrentTrack();
|
||||
if (track < disc.disc_total_tracks)
|
||||
cd_play_track(drive, ++track, disc.disc_total_tracks);
|
||||
}
|
||||
|
||||
static
|
||||
void pauseORcont()
|
||||
{
|
||||
if (status.status_mode == CDAUDIO_PAUSED)
|
||||
cd_resume(drive);
|
||||
else
|
||||
cd_pause(drive);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
drive = cd_init_device("/dev/cdrom");
|
||||
if (drive >= 0) {
|
||||
cd_stat(drive, &disc);
|
||||
cd_poll(drive, &status);
|
||||
if (argc > 1) {
|
||||
char *t = strrchr(argv[1], '-');
|
||||
if (t) {
|
||||
switch ((char)*++t) {
|
||||
case 'F': /* First */
|
||||
cd_play_track(drive, disc.disc_first_track, disc.disc_total_tracks);
|
||||
break;
|
||||
case 'L': /* Last */
|
||||
cd_play(drive, disc.disc_total_tracks);
|
||||
break;
|
||||
case 'N': /* Next */
|
||||
next();
|
||||
break;
|
||||
case 'P':
|
||||
if (t[1] == 'r') prev(); /* Prev */
|
||||
else pauseORcont(); /* Pause|Resume */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return cd_finish(drive);
|
||||
}
|
||||
}
|
||||
cd_play_track(drive, disc.disc_first_track, disc.disc_total_tracks);
|
||||
return cd_finish(drive);
|
||||
}
|
||||
return 1;
|
||||
}
|
53
contrib/cdplayer/cdplayer.cgi
Executable file
53
contrib/cdplayer/cdplayer.cgi
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
cat <<EOF
|
||||
Content-Type: text/html
|
||||
Cache-Control: no-cache
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title> CD Player</title>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<table border="1" cols="5" rows="2">
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<h3> CD Player 2007 </h3>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<form action="cdplayer.cgi">
|
||||
<td> <input type="submit" name="key" value="<<" />
|
||||
</td>
|
||||
<td> <input type="submit" name="key" value="<" />
|
||||
</td>
|
||||
<td> <input type="submit" name="key" value=">" />
|
||||
</td>
|
||||
<td> <input type="submit" name="key" value=">>" />
|
||||
</td>
|
||||
<td> <input type="submit" name="key" value="Pause" />
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
case "$QUERY_STRING" in
|
||||
"key=%3c%3c")
|
||||
cdplayer -F
|
||||
;;
|
||||
"key=%3e%3e")
|
||||
cdplayer -La
|
||||
;;
|
||||
"key=%3c")
|
||||
cdplayer -Pr
|
||||
;;
|
||||
"key=%3e")
|
||||
cdplayer -N
|
||||
;;
|
||||
"key=Pause")
|
||||
cdplayer -Pa
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user