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
This commit is contained in:
Daniel Stenberg 2002-05-05 10:30:17 +00:00
parent 86a05c56c2
commit 1cc447afe6
2 changed files with 121 additions and 0 deletions

101
uisimulator/play.c Normal file
View file

@ -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;
}
}
}

20
uisimulator/play.h Normal file
View file

@ -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);