Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Media";
Текущий архив: 2007.08.05;
Скачать: [xml.tar.bz2];

Вниз

WMA редактирование   Найти похожие ветки 

 
spz ©   (2006-10-30 11:16) [0]

подскажите пжл как читать/редактировать информацию из WMA-файла (артист,альбом и т.д.)


 
Stexen ©   (2006-10-31 14:39) [1]

По моему WMA не документирован толко так что ковыряй, ничего сложного :)


 
firemen   (2006-11-06 09:49) [2]

Держи простенькую библиотеку.

unit WMAfile;

interface

uses
 Classes, SysUtils;

const
 { Channel modes }
 WMA_CM_UNKNOWN = 0;                                               { Unknown }
 WMA_CM_MONO = 1;                                                     { Mono }
 WMA_CM_STEREO = 2;                                                 { Stereo }

 { Channel mode names }
 WMA_MODE: array [0..2] of string = ("Unknown", "Mono", "Stereo");

type
 { Class TWMAfile }
 TWMAfile = class(TObject)
   private
     { Private declarations }
     FValid: Boolean;
     FFileSize: Integer;
     FChannelModeID: Byte;
     FSampleRate: Integer;
     FDuration: Double;
     FBitRate: Integer;
     FTitle: WideString;
     FArtist: WideString;
     FAlbum: WideString;
     FTrack: Integer;
     FYear: WideString;
     FGenre: WideString;
     FComment: WideString;
     procedure FResetData;
     function FGetChannelMode: string;
   public
     { Public declarations }
     constructor Create;                                     { Create object }
     function ReadFromFile(const FileName: string): Boolean;     { Load data }
     property Valid: Boolean read FValid;               { True if valid data }
     property FileSize: Integer read FFileSize;          { File size (bytes) }
     property ChannelModeID: Byte read FChannelModeID;   { Channel mode code }
     property ChannelMode: string read FGetChannelMode;  { Channel mode name }
     property SampleRate: Integer read FSampleRate;       { Sample rate (hz) }
     property Duration: Double read FDuration;          { Duration (seconds) }
     property BitRate: Integer read FBitRate;              { Bit rate (kbit) }
     property Title: WideString read FTitle;                    { Song title }
     property Artist: WideString read FArtist;                 { Artist name }
     property Album: WideString read FAlbum;                    { Album name }
     property Track: Integer read FTrack;                     { Track number }
     property Year: WideString read FYear;                            { Year }
     property Genre: WideString read FGenre;                    { Genre name }
     property Comment: WideString read FComment;                   { Comment }
 end;

implementation

const
 { Object IDs }
 WMA_HEADER_ID =
   #48#38#178#117#142#102#207#17#166#217#0#170#0#98#206#108;
 WMA_FILE_PROPERTIES_ID =
   #161#220#171#140#71#169#207#17#142#228#0#192#12#32#83#101;
 WMA_STREAM_PROPERTIES_ID =
   #145#7#220#183#183#169#207#17#142#230#0#192#12#32#83#101;
 WMA_CONTENT_DESCRIPTION_ID =
   #51#38#178#117#142#102#207#17#166#217#0#170#0#98#206#108;
 WMA_EXTENDED_CONTENT_DESCRIPTION_ID =
   #64#164#208#210#7#227#210#17#151#240#0#160#201#94#168#80;

 { Max. number of supported comment fields }
 WMA_FIELD_COUNT = 7;

 { Names of supported comment fields }
 WMA_FIELD_NAME: array [1..WMA_FIELD_COUNT] of WideString =
   ("WM/TITLE", "WM/AUTHOR", "WM/ALBUMTITLE", "WM/TRACK", "WM/YEAR",
    "WM/GENRE", "WM/DESCRIPTION");

 { Max. number of characters in tag field }
 WMA_MAX_STRING_SIZE = 250;

type
 { Object ID }
 ObjectID = array [1..16] of Char;

 { Tag data }
 TagData = array [1..WMA_FIELD_COUNT] of WideString;

 { File data - for internal use }
 FileData = record
   FileSize: Integer;                                    { File size (bytes) }
   MaxBitRate: Integer;                                { Max. bit rate (bps) }
   Channels: Word;                                      { Number of channels }
   SampleRate: Integer;                                   { Sample rate (hz) }
   ByteRate: Integer;                                            { Byte rate }
   Tag: TagData;                                       { WMA tag information }
 end;

function ReadFieldString(const Source: TStream; DataSize: Word): WideString;
var
 Iterator, StringSize: Integer;
 FieldData: array [1..WMA_MAX_STRING_SIZE * 2] of Byte;
begin
 { Read field data and convert to Unicode string }
 Result := "";
 StringSize := DataSize div 2;
 if StringSize > WMA_MAX_STRING_SIZE then StringSize := WMA_MAX_STRING_SIZE;
 Source.ReadBuffer(FieldData, StringSize * 2);
 Source.Seek(DataSize - StringSize * 2, soFromCurrent);
 for Iterator := 1 to StringSize do
   Result := Result +
     WideChar(FieldData[Iterator * 2 - 1] + (FieldData[Iterator * 2] shl 8));
end;

Извиняюсь, весь текст по размерам не входит.
Пиши на firemen01@ukr.net вышлю.



Страницы: 1 вся ветка

Форум: "Media";
Текущий архив: 2007.08.05;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.045 c
2-1183895720
_user
2007-07-08 15:55
2007.08.05
Изменить пароль на Access


8-1162766860
Горгер
2006-11-06 01:47
2007.08.05
Как отрисовывать линию по таймеру в OPENGL ?


15-1184036630
Искатель
2007-07-10 07:03
2007.08.05
Есть ли альтернативы TColorDialog ?


2-1183851195
RWolf
2007-07-08 03:33
2007.08.05
TListView, OwnerDraw, артефакты при ресайзе колонок


2-1183707430
_Asph
2007-07-06 11:37
2007.08.05
Не срабатывает try





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский