summaryrefslogtreecommitdiff
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
parent86a05c56c2431b74eabbcd96eba0ed6d145ac590 (diff)
downloadrockbox-1cc447afe69299e13bcf228aaea2b9943fc3b0aa.zip
rockbox-1cc447afe69299e13bcf228aaea2b9943fc3b0aa.tar.gz
rockbox-1cc447afe69299e13bcf228aaea2b9943fc3b0aa.tar.bz2
rockbox-1cc447afe69299e13bcf228aaea2b9943fc3b0aa.tar.xz
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
-rw-r--r--uisimulator/play.c101
-rw-r--r--uisimulator/play.h20
2 files changed, 121 insertions, 0 deletions
diff --git a/uisimulator/play.c b/uisimulator/play.c
new file mode 100644
index 0000000..7b2b6d7
--- /dev/null
+++ b/uisimulator/play.c
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 Daniel Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <file.h>
+#include <types.h>
+#include <lcd.h>
+#include <button.h>
+#include "kernel.h"
+#include "tree.h"
+
+#include "id3.h"
+
+#define LINE_Y 8 /* initial line */
+#define LINE_HEIGTH 8 /* line height in pixels */
+
+void playtune(char *dir, char *file)
+{
+ char buffer[256];
+ int fd;
+ mp3entry mp3;
+ bool good=1;
+
+ sprintf(buffer, "%s/%s", dir, file);
+
+ if(mp3info(&mp3, buffer)) {
+ Logf("Failure!");
+ good=0;
+ }
+ else {
+ printf("****** File: %s\n"
+ " Title: %s\n"
+ " Artist: %s\n"
+ " Album: %s\n"
+ " Length: %d ms\n"
+ " Bitrate: %d\n"
+ " Frequency: %d\n",
+ buffer,
+ mp3.title?mp3.title:"<blank>",
+ mp3.artist?mp3.artist:"<blank>",
+ mp3.album?mp3.album:"<blank>",
+ mp3.length,
+ mp3.bitrate,
+ mp3.frequency);
+ }
+#ifdef HAVE_LCD_BITMAP
+ lcd_clear_display();
+ if(!good) {
+ lcd_puts(0, 0, "[no id3 info]", 0);
+ }
+ else {
+ lcd_puts(0, 0, "[id3 info]", 0);
+ lcd_puts(0, LINE_Y, mp3.title?mp3.title:"", 0);
+ lcd_puts(0, LINE_Y+1*LINE_HEIGTH, mp3.album?mp3.album:"", 0);
+ lcd_puts(0, LINE_Y+2*LINE_HEIGTH, mp3.artist?mp3.artist:"", 0);
+
+ sprintf(buffer, "%d ms", mp3.length);
+ lcd_puts(0, LINE_Y+3*LINE_HEIGTH, buffer, 0);
+
+ sprintf(buffer, "%d kbits", mp3.bitrate);
+ lcd_puts(0, LINE_Y+4*LINE_HEIGTH, buffer, 0);
+
+ sprintf(buffer, "%d Hz", mp3.frequency);
+ lcd_puts(0, LINE_Y+5*LINE_HEIGTH, buffer, 0);
+ }
+ lcd_update();
+#endif
+
+ while(1) {
+ int key = button_get();
+
+ if(!key) {
+ sleep(30);
+ continue;
+ }
+ switch(key) {
+ case BUTTON_OFF:
+ case BUTTON_LEFT:
+ return FALSE;
+ break;
+ }
+ }
+}
diff --git a/uisimulator/play.h b/uisimulator/play.h
new file mode 100644
index 0000000..b63df29
--- /dev/null
+++ b/uisimulator/play.h
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 Daniel Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+void playtune(char *dir, char *file);