diff options
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/play.c | 101 | ||||
-rw-r--r-- | uisimulator/play.h | 20 |
2 files changed, 121 insertions, 0 deletions
diff --git a/uisimulator/play.c b/uisimulator/play.c new file mode 100644 index 0000000000..7b2b6d7b4a --- /dev/null +++ b/uisimulator/play.c | |||
@@ -0,0 +1,101 @@ | |||
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 <string.h> | ||
21 | #include <stdlib.h> | ||
22 | |||
23 | #include <file.h> | ||
24 | #include <types.h> | ||
25 | #include <lcd.h> | ||
26 | #include <button.h> | ||
27 | #include "kernel.h" | ||
28 | #include "tree.h" | ||
29 | |||
30 | #include "id3.h" | ||
31 | |||
32 | #define LINE_Y 8 /* initial line */ | ||
33 | #define LINE_HEIGTH 8 /* line height in pixels */ | ||
34 | |||
35 | void playtune(char *dir, char *file) | ||
36 | { | ||
37 | char buffer[256]; | ||
38 | int fd; | ||
39 | mp3entry mp3; | ||
40 | bool good=1; | ||
41 | |||
42 | sprintf(buffer, "%s/%s", dir, file); | ||
43 | |||
44 | if(mp3info(&mp3, buffer)) { | ||
45 | Logf("Failure!"); | ||
46 | good=0; | ||
47 | } | ||
48 | else { | ||
49 | printf("****** File: %s\n" | ||
50 | " Title: %s\n" | ||
51 | " Artist: %s\n" | ||
52 | " Album: %s\n" | ||
53 | " Length: %d ms\n" | ||
54 | " Bitrate: %d\n" | ||
55 | " Frequency: %d\n", | ||
56 | buffer, | ||
57 | mp3.title?mp3.title:"<blank>", | ||
58 | mp3.artist?mp3.artist:"<blank>", | ||
59 | mp3.album?mp3.album:"<blank>", | ||
60 | mp3.length, | ||
61 | mp3.bitrate, | ||
62 | mp3.frequency); | ||
63 | } | ||
64 | #ifdef HAVE_LCD_BITMAP | ||
65 | lcd_clear_display(); | ||
66 | if(!good) { | ||
67 | lcd_puts(0, 0, "[no id3 info]", 0); | ||
68 | } | ||
69 | else { | ||
70 | lcd_puts(0, 0, "[id3 info]", 0); | ||
71 | lcd_puts(0, LINE_Y, mp3.title?mp3.title:"", 0); | ||
72 | lcd_puts(0, LINE_Y+1*LINE_HEIGTH, mp3.album?mp3.album:"", 0); | ||
73 | lcd_puts(0, LINE_Y+2*LINE_HEIGTH, mp3.artist?mp3.artist:"", 0); | ||
74 | |||
75 | sprintf(buffer, "%d ms", mp3.length); | ||
76 | lcd_puts(0, LINE_Y+3*LINE_HEIGTH, buffer, 0); | ||
77 | |||
78 | sprintf(buffer, "%d kbits", mp3.bitrate); | ||
79 | lcd_puts(0, LINE_Y+4*LINE_HEIGTH, buffer, 0); | ||
80 | |||
81 | sprintf(buffer, "%d Hz", mp3.frequency); | ||
82 | lcd_puts(0, LINE_Y+5*LINE_HEIGTH, buffer, 0); | ||
83 | } | ||
84 | lcd_update(); | ||
85 | #endif | ||
86 | |||
87 | while(1) { | ||
88 | int key = button_get(); | ||
89 | |||
90 | if(!key) { | ||
91 | sleep(30); | ||
92 | continue; | ||
93 | } | ||
94 | switch(key) { | ||
95 | case BUTTON_OFF: | ||
96 | case BUTTON_LEFT: | ||
97 | return FALSE; | ||
98 | break; | ||
99 | } | ||
100 | } | ||
101 | } | ||
diff --git a/uisimulator/play.h b/uisimulator/play.h new file mode 100644 index 0000000000..b63df29c82 --- /dev/null +++ b/uisimulator/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 | |||
20 | void playtune(char *dir, char *file); | ||