summaryrefslogtreecommitdiff
path: root/uisimulator/play.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-05-05 10:30:17 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-05-05 10:30:17 +0000
commit1cc447afe69299e13bcf228aaea2b9943fc3b0aa (patch)
treecb34c225fcbba803776967deb4ae649a14f3958c /uisimulator/play.c
parent86a05c56c2431b74eabbcd96eba0ed6d145ac590 (diff)
downloadrockbox-1cc447afe69299e13bcf228aaea2b9943fc3b0aa.tar.gz
rockbox-1cc447afe69299e13bcf228aaea2b9943fc3b0aa.zip
Play a tune. Uses the id3-info now and display it on screen.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@428 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/play.c')
-rw-r--r--uisimulator/play.c101
1 files changed, 101 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
35void 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}