Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.08.05;
Скачать: CL | DM;

Вниз

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 вся ветка

Текущий архив: 2007.08.05;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.026 c
15-1184139827
pasha_golub
2007-07-11 11:43
2007.08.05
Статья по принципам работы многопользовательских СУБД


15-1184145951
zdm77
2007-07-11 13:25
2007.08.05
Прокси


2-1183879448
sl8er
2007-07-08 11:24
2007.08.05
Не вижу изменения


15-1183578644
P
2007-07-04 23:50
2007.08.05
"Большой бум" и фундаментальная наука.


15-1183841855
Vlad Oshin
2007-07-08 00:57
2007.08.05
что-то раньше не замечал. а действительно. Платят за таку ерунду