2002-05-05 10:30:17 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2002-05-16 14:48:53 +00:00
|
|
|
#include <stdio.h>
|
2002-05-05 10:30:17 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2002-05-13 12:45:46 +00:00
|
|
|
#include "file.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "button.h"
|
2002-05-05 10:30:17 +00:00
|
|
|
#include "kernel.h"
|
|
|
|
#include "tree.h"
|
2002-05-10 14:56:52 +00:00
|
|
|
#include "debug.h"
|
2002-05-29 16:38:19 +00:00
|
|
|
#include "sprintf.h"
|
2002-05-05 10:30:17 +00:00
|
|
|
|
|
|
|
#include "id3.h"
|
2002-05-24 16:12:16 +00:00
|
|
|
#include "mpeg.h"
|
2002-05-05 10:30:17 +00:00
|
|
|
|
2002-05-09 23:54:47 +00:00
|
|
|
#ifdef MPEG_PLAY
|
2002-05-24 08:08:46 +00:00
|
|
|
#include "mpegplay.h"
|
2002-05-09 23:54:47 +00:00
|
|
|
#endif
|
|
|
|
|
2002-05-10 14:56:52 +00:00
|
|
|
#define LINE_Y 1 /* initial line */
|
2002-05-05 10:30:17 +00:00
|
|
|
|
|
|
|
void playtune(char *dir, char *file)
|
|
|
|
{
|
2002-05-27 09:56:22 +00:00
|
|
|
static char mfile[256];
|
2002-05-10 14:56:52 +00:00
|
|
|
char buffer[256];
|
|
|
|
mp3entry mp3;
|
|
|
|
bool good=1;
|
2002-05-05 10:30:17 +00:00
|
|
|
|
2002-05-16 14:48:53 +00:00
|
|
|
snprintf(buffer, sizeof(buffer), "%s/%s", dir, file);
|
2002-05-10 14:56:52 +00:00
|
|
|
if(mp3info(&mp3, buffer)) {
|
|
|
|
DEBUGF("id3 failure!");
|
|
|
|
good=0;
|
|
|
|
}
|
|
|
|
lcd_clear_display();
|
2002-05-05 10:30:17 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-05-10 14:56:52 +00:00
|
|
|
lcd_setmargins(0,0);
|
|
|
|
lcd_setfont(0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(!good) {
|
|
|
|
lcd_puts(0, 0, "[no id3 info]");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
lcd_puts(0, 0, "[id3 info]");
|
|
|
|
lcd_puts(0, LINE_Y, mp3.title?mp3.title:"");
|
|
|
|
lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:"");
|
|
|
|
lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:"");
|
2002-05-05 10:30:17 +00:00
|
|
|
|
2002-05-16 14:48:53 +00:00
|
|
|
snprintf(buffer,sizeof(buffer), "%d ms", mp3.length);
|
2002-05-10 14:56:52 +00:00
|
|
|
lcd_puts(0, LINE_Y+3, buffer);
|
2002-05-05 10:30:17 +00:00
|
|
|
|
2002-05-16 14:48:53 +00:00
|
|
|
snprintf(buffer,sizeof(buffer), "%d kbits", mp3.bitrate);
|
2002-05-10 14:56:52 +00:00
|
|
|
lcd_puts(0, LINE_Y+4, buffer);
|
2002-05-05 10:30:17 +00:00
|
|
|
|
2002-05-16 14:48:53 +00:00
|
|
|
snprintf(buffer,sizeof(buffer), "%d Hz", mp3.frequency);
|
2002-05-10 14:56:52 +00:00
|
|
|
lcd_puts(0, LINE_Y+5, buffer);
|
|
|
|
#else
|
|
|
|
lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>");
|
|
|
|
lcd_puts(0, 1, mp3.title?mp3.title:"<no title>");
|
2002-05-05 10:30:17 +00:00
|
|
|
#endif
|
2002-05-10 14:56:52 +00:00
|
|
|
}
|
2002-05-16 14:48:53 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-05-10 14:56:52 +00:00
|
|
|
lcd_update();
|
2002-05-16 14:48:53 +00:00
|
|
|
#endif
|
2002-05-05 10:30:17 +00:00
|
|
|
|
2002-05-27 09:56:22 +00:00
|
|
|
snprintf(mfile, sizeof(mfile), "%s/%s", dir, file);
|
|
|
|
mpeg_play(mfile);
|
|
|
|
|
2002-05-10 14:56:52 +00:00
|
|
|
while(1) {
|
2002-05-28 12:10:12 +00:00
|
|
|
switch ( button_get(true) ) {
|
2002-05-16 14:48:53 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
2002-05-10 14:56:52 +00:00
|
|
|
case BUTTON_OFF:
|
|
|
|
case BUTTON_LEFT:
|
2002-05-16 14:48:53 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_STOP:
|
|
|
|
#endif
|
2002-05-10 14:56:52 +00:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
2002-05-05 10:30:17 +00:00
|
|
|
}
|
|
|
|
}
|