From 1cc447afe69299e13bcf228aaea2b9943fc3b0aa Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 5 May 2002 10:30:17 +0000 Subject: 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 --- uisimulator/play.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ uisimulator/play.h | 20 +++++++++++ 2 files changed, 121 insertions(+) create mode 100644 uisimulator/play.c create mode 100644 uisimulator/play.h (limited to 'uisimulator') 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 @@ +/*************************************************************************** + * __________ __ ___. + * 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 +#include + +#include +#include +#include +#include +#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:"", + mp3.artist?mp3.artist:"", + mp3.album?mp3.album:"", + 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 0000000000..b63df29c82 --- /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); -- cgit v1.2.3