Example of use WmsCreateMediaItemTags and TWmsScriptFileTags

Post Reply
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Example of use WmsCreateMediaItemTags and TWmsScriptFileTags

Post by Eugene »

Required version 1.51

These function and the class may be useful for reading tags of files, that the program does not handle by default (for example in the event "After reading of properties of a media resource").

Example simply display the tags of current media-resource in the List [Movies, Music, Photo]

Settings - Processing - Add
Name: Display Tags
Check "Button on the main form"
Script:

Code: Select all

var
  FileTags: TWmsScriptFileTags;
  TextTags: TStringList;  
  i: Integer;  
  sProviderName, sValue: string;    
begin
  if InputQuery('Provider Name', 'Exif, FFmpeg, MediaInfo, Shell, Wms, Xmp', sProviderName) then begin
    FileTags := WmsCreateMediaItemTags(sProviderName, WmsCurrentMediaListItem);
    if FileTags <> nil then try
      TextTags := TStringList.Create;
      try           
        for i := 0 to FileTags.GetTagCount - 1 do begin
          sValue := VarToStr(FileTags.GetTagValue(FileTags.GetTagID(i)));
          if (sValue <> '') and (Length(sValue) < 100) then  
            TextTags.Add(Format('%s (%s): %s', [FileTags.GetTagName(i), FileTags.GetTagID(i), sValue]));
        end;      
        ShowMessage(TextTags.Text)
      finally
        TextTags.Free
      end                  
    finally  
      FileTags.Free
    end
  end     
end.
Ok - Ok
Select a media-resource - click "Display Tags" - specify a provider name - Ok
Eugene
Posts: 2940
Joined: Tue Nov 17, 2009 8:05 pm

Re: Example of use WmsCreateMediaItemTags and TWmsScriptFile

Post by Eugene »

Example of use WmsMediaInfoCreate, for a video track (Stream_Video), the possible values ​​in description of the type TMIStreamKind

Code: Select all

var
  i, iCount: Integer;  
  sValue: string;
  TextTags: TStringList;      
begin
  if WmsCurrentMediaListItem <> nil then begin
    if WmsMediaInfoCreate('', WmsCurrentMediaListItem.ItemID) then begin
      TextTags := TStringList.Create;
      try
        iCount := WmsMediaInfoGetCount(Stream_Video);
        for i := 0 to iCount - 1 do begin  
          sValue := VarToStr(WmsMediaInfoGetI(Stream_Video, 0, i));
          if (sValue <> '') and (Length(sValue) < 100) then  
            TextTags.Add(Format('%s (%s): %s', [
               WmsMediaInfoGetI(Stream_Video, 0, i, Info_Name_Text),
               WmsMediaInfoGetI(Stream_Video, 0, i, Info_Name), sValue]));
        end;    
        ShowMessage(TextTags.Text)
      finally
        TextTags.Free
      end                  
    end
  end     
end.
Post Reply