summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/play.c109
-rw-r--r--apps/play.h20
2 files changed, 129 insertions, 0 deletions
diff --git a/apps/play.c b/apps/play.c
new file mode 100644
index 0000000000..89dfa5503e
--- /dev/null
+++ b/apps/play.c
@@ -0,0 +1,109 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Daniel Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <stdio.h>
21#include <string.h>
22#include <stdlib.h>
23
24#include "file.h"
25#include "lcd.h"
26#include "button.h"
27#include "kernel.h"
28#include "tree.h"
29#include "debug.h"
30
31#include "id3.h"
32
33#ifdef MPEG_PLAY
34#include "common/mpegplay.h"
35#endif
36
37#define LINE_Y 1 /* initial line */
38
39void playtune(char *dir, char *file)
40{
41 char buffer[256];
42 mp3entry mp3;
43 bool good=1;
44
45 snprintf(buffer, sizeof(buffer), "%s/%s", dir, file);
46
47 if(mp3info(&mp3, buffer)) {
48 DEBUGF("id3 failure!");
49 good=0;
50 }
51 lcd_clear_display();
52#ifdef HAVE_LCD_BITMAP
53 lcd_setmargins(0,0);
54 lcd_setfont(0);
55#endif
56
57 if(!good) {
58 lcd_puts(0, 0, "[no id3 info]");
59 }
60 else {
61#ifdef HAVE_LCD_BITMAP
62 lcd_puts(0, 0, "[id3 info]");
63 lcd_puts(0, LINE_Y, mp3.title?mp3.title:"");
64 lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:"");
65 lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:"");
66
67 snprintf(buffer,sizeof(buffer), "%d ms", mp3.length);
68 lcd_puts(0, LINE_Y+3, buffer);
69
70 snprintf(buffer,sizeof(buffer), "%d kbits", mp3.bitrate);
71 lcd_puts(0, LINE_Y+4, buffer);
72
73 snprintf(buffer,sizeof(buffer), "%d Hz", mp3.frequency);
74 lcd_puts(0, LINE_Y+5, buffer);
75#else
76 lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>");
77 lcd_puts(0, 1, mp3.title?mp3.title:"<no title>");
78#endif
79 }
80
81#ifdef HAVE_LCD_BITMAP
82 lcd_update();
83#endif
84
85#ifdef MPEG_PLAY
86 snprintf(buffer,sizeof(buffer), "%s/%s", dir, file);
87 mpeg_play(buffer);
88 return;
89#endif
90
91 while(1) {
92 int key = button_get();
93
94 if(!key) {
95 sleep(30);
96 continue;
97 }
98 switch(key) {
99#ifdef HAVE_RECORDER_KEYPAD
100 case BUTTON_OFF:
101 case BUTTON_LEFT:
102#else
103 case BUTTON_STOP:
104#endif
105 return;
106 break;
107 }
108 }
109}
diff --git a/apps/play.h b/apps/play.h
new file mode 100644
index 0000000000..b63df29c82
--- /dev/null
+++ b/apps/play.h
@@ -0,0 +1,20 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Daniel Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20void playtune(char *dir, char *file);