Форум — Ответы     (  К темам )
 ?  Stas: Тэги (13-12-2002 21:45:47)
Люди помогите!
Как в Builder-е работать с тегами mp3 файлов,
ну там надо их прочитать, занести изменения.
 Владимир (14-12-2002 16:40:56)
Посмотрите пример программы здесь — 70 Кб
Там есть и .dll для воспроизведения .mp3 файлов
Программа извлекает из .mp3 файла теги и можете соответственно
переименовать .mp3 файл, а также воспроизвести его.
Если чего непонятно — пишите, спрашивайте
(там правда в примере есть компонент TPListBox, но можете заменить его на типа TListBox — с именами LB2,LB3 — разместите их на Panel1 и Panel2),
а как извлекать теги из файла есть там в функции InfFind()
 Stas (20-12-2002 21:31:41)
Для Владимира.
Но в этом компоненте нет примера как добыть биррейд и длину песни.
 Владимир (24-12-2002 18:18:07)
Такие функции в dll по-моему были.
Сейчас, где-то завалялось описание этой dll, найду, сразу здесь выложу.
 Stas (31-12-2002 09:50:49)
Большое спасибо!Владимир.
И с Новым годом!!!
 Владимир (04-01-2003 14:09:56)
Описание MP3.DLL (версия 1.0.0.x)
0. Предисловие
Оглавление:
• Определения Методов
• Структура PlayRecord
• Описание методов
- Маркер(дескриптор) Сообщений
МРЗ библиотека позволяет Вам запускать MP3 файлы в Windows 95 и Windows NT (в NT, это должно работать, но я не проверял это). Я надеюсь, так что это описание поможет Вам узнать об использовании этой библиотеки.
Вместе с МРЗ библиотечным модулем была поставлена простая программу в Delphi 3, которая демонстрирует, как использовать эту библиотеку.
Если, в конце концов, у Вас остались любые вопросы, отправьте мне, по адресу robin@arrakis.cs.put.poznan.pl , и я попробую ответить.
1. Определения Методов
В библиотеке были объявлены следующие методы (чтобы у Вас не было проблем с параметрами, я показываю Вам, как эти методы были объявлены):

Play function:
extern "C" {
void WINAPI _export mp3play(PlayRecord far *DATA);
}
Stop function:
extern "C" {
void WINAPI _export mp3stop(void);
}
Seek function:
extern "C" {
void WINAPI _export mp3seek(int32 position);
}
Функция, позволяющая получать информацию о времени файла:
extern "C" {
void WINAPI _export mp3gettime(PlayRecord far *DATA, double far *total, double far *perframe);
}

2. Структура PlayRecord
Метод, который воспроизводит .МРЗ файл, получает информацию о треке от структуры PlayRecord, которая является параметром метода. Объявление этой структуры:
typedef struct {
char *FileName;
DWORD SeekAtStart;
HWND Owner;
DWORD Result;
} PlayRecord;
Описание Полей:
- FileName- указатель на строку с нулевым символом в конце, которая содержит полное имя файла
- SeekAtStart — стартовая позицию (в фреймах).
- Owner — дескриптор окна, которое будет получать сообщения от библиотеки.
- Result — после возвращения mp3play метода, это поле содержит код завершения (нуль если никакой ошибки не произошло)
3. Описание методов
• З.1 Получить информацию о времени
mp3gettime(PlayRecord far *DATA, double far *total, double far *perframe)
Описание Полей:
- DATA  — структура, описанная в пункте 2.
- total  — длина трека в миллисекундах
- perframe — число миллисекунд во фрейме
Описание: Этот метод возвращает в полях total и perframe информацию, необходимую для определения параметров времени проигрываемого трека.

Вы должны заполнить только DATA -> FileName поле.
Если файл не существует, или файл не имеет МРЗ заголовка, поле DATA->Result будет равно 1.
3.2 PlayFile
mp3play(PlayRecord far *DATA)
- Описание Полей:
- DATA- структура, описанная в пункте 2.
Описание:
Этот метод проигрывает МРЗ файл, указанный в структуре DATA. Вы можете запустить проигрывание с позиции, указанной в поле
DATA-> SeekAtStart .
Внимание! Этот метод не создает thread, которая позволяет возвратиться из метода перед остановкой трека. Так, Вы должны создать нить для этого метода, если Вы хотите иметь управление над процессом проигрывания.
Если файл не существует, или файл не имеет МРЗ заголовка, поле DATA ->Result будет равно 1. Если во время проигрывания файла были зарегистрированы ошибки , это поле будет равно 2. Но лучший способ обнаружить ошибку — выяснить, почему метод Play был остановлен (см. Messages handle).
3.3 Seeking
mp3seek(int32 position)
Описание Полей:
- position — содержит номер фрейма, который будет проигрываться

3.4 Stop playing
mp3stop(void)
Этот метод останавливает проигрывание файла.

Внимание! Возвращение из этого метода не означает остановку игры и не освобождает аудиоканал. Так, Вы могли бы иметь проблемы, если Вы записываете последовательность подобно этой:
{
CreateThread(nil,0,&mp3play,&FirstTrack,0,dwThreadId);
mp3stop();
CreateThread(nil,0,&mp3play,&SecondTrack,0,dwThreadId);
}
Процесс проигрывания будет остановлен , когда Вы получите сообщение PLAY_STOP (см. Message handle).

4. Messages handle
Структура PlayRecord содержит определяющее поле (дескриптор) окна, которое будет получать служебные сообщения от МРЗ библиотеки.
- Следующие сообщения:
- FRAME_POS (value 12000)
Поле wParam содержит номер текущего фрейма. Это сообщение посылается после каждых 16 фреймов.
- APPLY_POS (value 12001)
Это сообщение посылается, когда seek process was done.
- PLAY_STOP (value 12002)
Это сообщение посылается, когда процесс проигрывания был остановлен. Поле IParam содержит информацию, почему этот процесс был остановлен:

Значение Причина
0 Конец трека
1 Ошибка при проигрывании (например: ЗВУКОВОЙ поток занят)
2 Прерывание от пользователя


Если что-то плохо перевел, вот английский оригинал
Description of MP3.DLL (version 1.0.0.x)

0. Preface
Table of contents:

Methods Definitions
Structure PlayRecord
Description of methods
Messages handle
MP3 library let You playing MPEG Layer III files in Windows 95 and Windows NT (in NT it should be work, but I don't check it). I hope so this description will help you to learn about using this library.

Together with MP3 library pack was delivered simple program in Delphi 3 which demonstrate how to use this library.

If after all you had any questions, mail me to address robin@arrakis.cs.put.poznan.pl, I try answer.



1. Methods definitions
In library was declared following methods (because you might have problems with pass the parameters, I show you how this methods was declared):

Play function:
extern "C" {
void WINAPI _export mp3play(PlayRecord far *DATA);
}

Stop function:
extern "C" {
void WINAPI _export mp3stop(void);
}

Seek function:
extern "C" {
void WINAPI _export mp3seek(int32 position);
}

Function which let you get time info about specified file:
extern "C" {
void WINAPI _export mp3gettime(PlayRecord far *DATA, double far *total, double far *perframe);
}

2. Structure PlayRecord
Method, which play .MP3 file get information about track from PlayRecord structure, which is a method parameter. Declaration of this structure:

typedef struct {

char *FileName;
DWORD SeekAtStart;
HWND Owner;
DWORD Result;

} PlayRecord;

Fields description:
- Filename — pointer to null-character string witch full name of file.

- SeekAtStart — start position (in frames).

- Owner — handle of window, which will be handle messages from library.

- Result — after return from mp3play method this field contain exit code (zero if no error occurs)

3. Description of methods
3.1 Get time information
mp3gettime(PlayRecord far *DATA, double far *total, double far *perframe)

Fields description:
- DATA — structure described in point 2.

- total — track length in milliseconds

- perframe — number of milliseconds per frame

Description:
This method return in fields total and perframe information need to define time parameter of playing track. You have to fill only DATA->FileName field.

If file is not exist or file haven't got MP3 header, the field DATA->Result will be equal 1.

3.2 Play file
mp3play(PlayRecord far *DATA)

Fields description:
- DATA — structure described in point 2.

Description:
This method play the MP3 file specified in DATA structure. You may start play from specified in field DATA->SeekAtStart position.

ATENTION! This method doesn't create thread, which allow return from method before stop playing track. So, you have to create thread from this method if you want to have control of play process.

If file is not exist or file haven't got MP3 header, the field DATA->Result will be equal 1. If any error was occurred while executing play method this filed will be Equal 2. But the best way to detect error is recognize why play method was stopped (see Messages handle).

3.3 Seeking
mp3seek(int32 position)

Fields description:
- position — contain number of frame which will be played

Description:
No description

3.4 Stop playing
mp3stop(void)

Opis:
This method stops the play process.

ATENTION! Return from this method doesn't mean stop play process and free audio channel. So, you might have problems if you write sequence like this:

{

CreateThread(nil,0,&mp3play,&FirstTrack,0,dwThreadId);
mp3stop();
CreateThread(nil,0,&mp3play,&SecondTrack,0,dwThreadId);

}

Play process was stopped finally when you get message PLAY_STOP (see Message handle).

4. Messages handle
Structure PlayRecord contain field-specifying handle of window, which will be service messages from MP3 library.

There are following messages:

- FRAME_POS (value 12000)

Field wParam contain number of current frame. This message is sending after every 16 frames.

- APPLY_POS (value 12001)

This message is sending when seek process was done.

- PLAY_STOP (value 12002)

This message is sending when play process was stopped. Field lParam contain information why this process was stopped:

value Cause
0 End of track
1 Error while playing (for example: AUDIO stream is in use)
2 User break