Seite 1 von 1

MP3 TAGs

Verfasst: 25.12.2005 20:41
von R4z0r1989
kann ich wenn ich den code

Code: Alles auswählen

; PureBasic Visual Designer v3.80 build 1249


Structure ID3v2 
  Title.s 
  Artist.s 
  Album.s 
  Comment.s 
  Year.s 
  Genre.s 
  Composer.s 
  URL.s 
  OrgArtist.s 
  Copyright.s 
  EncodedBy.s 
  Encoder.s 
  Track.s 
EndStructure 
Global TagID3v2.ID3v2 

Declare.l GetID3v2Tag(FileName.s) 


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Gadget_0
  #Gadget_1
  #Gadget_2
  #Gadget_3
  #Gadget_9
  #Gadget_10
  #Gadget_11
  #Gadget_12
  #Gadget_17
  #Gadget_18
  #Gadget_19
  #Gadget_20
  #Gadget_21
  #Gadget_22
  #Gadget_23
  #Gadget_24
  #Gadget_25
  #Gadget_26
  #Gadget_27
  #Gadget_28
  #Gadget_29
  #Gadget_30
  #Gadget_31
  #Gadget_32
  #Gadget_33
  #Gadget_34
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 216, 0, 600, 455,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
    If CreateGadgetList(WindowID())
      StringGadget(#Gadget_0, 10, 130, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_1, 10, 110, 270, 20, "Album:")
      TextGadget(#Gadget_2, 320, 110, 270, 20, "Artist:")
      StringGadget(#Gadget_3, 320, 130, 270, 20, "", #PB_String_ReadOnly)
      StringGadget(#Gadget_9, 10, 180, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_10, 10, 160, 270, 20, "Comment:")
      TextGadget(#Gadget_11, 320, 160, 270, 20, "Composer:")
      StringGadget(#Gadget_12, 320, 180, 270, 20, "", #PB_String_ReadOnly)
      StringGadget(#Gadget_17, 10, 230, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_18, 10, 210, 270, 20, "Copyright:")
      TextGadget(#Gadget_19, 320, 210, 270, 20, "Encodet by:")
      StringGadget(#Gadget_20, 320, 230, 270, 20, "", #PB_String_ReadOnly)
      StringGadget(#Gadget_21, 10, 280, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_22, 10, 260, 270, 20, "Encoder:")
      TextGadget(#Gadget_23, 320, 260, 270, 20, "Genre:")
      StringGadget(#Gadget_24, 320, 280, 270, 20, "", #PB_String_ReadOnly)
      StringGadget(#Gadget_25, 10, 330, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_26, 10, 310, 270, 20, "Original Artist:")
      TextGadget(#Gadget_27, 320, 310, 270, 20, "Title:")
      StringGadget(#Gadget_28, 320, 330, 270, 20, "", #PB_String_ReadOnly)
      StringGadget(#Gadget_29, 10, 380, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_30, 10, 360, 270, 20, "Track:")
      TextGadget(#Gadget_31, 320, 360, 270, 20, "URL:")
      StringGadget(#Gadget_32, 320, 380, 270, 20, "", #PB_String_ReadOnly)
      StringGadget(#Gadget_33, 160, 430, 270, 20, "", #PB_String_ReadOnly)
      TextGadget(#Gadget_34, 160, 410, 270, 20, "Year:")
      
    EndIf
  EndIf
EndProcedure

Open_Window_0()

Repeat
 



MP3File.s = OpenFileRequester("Select MP3 File", "", "MP3 Files (*.mp3)|*.mp3", 0) 
  If GetID3v2Tag(MP3File) 
    ; display tag contents 
    SetGadgetText(#Gadget_0, TagID3v2\Album)
    SetGadgetText(#Gadget_3, TagID3v2\Artist)
    SetGadgetText(#Gadget_9, TagID3v2\Comment)
    SetGadgetText(#Gadget_12,  TagID3v2\Composer)
    SetGadgetText(#Gadget_17,  TagID3v2\Copyright)
    SetGadgetText(#Gadget_20,  TagID3v2\EncodedBy)
    SetGadgetText(#Gadget_21,  TagID3v2\Encoder)
    SetGadgetText(#Gadget_24,  TagID3v2\Genre)
    SetGadgetText(#Gadget_25,  TagID3v2\OrgArtist)
    SetGadgetText(#Gadget_28,  TagID3v2\Title)
    SetGadgetText(#Gadget_29,  TagID3v2\Track)
    SetGadgetText(#Gadget_32,  TagID3v2\URL)
    SetGadgetText(#Gadget_33,  TagID3v2\Year) 
  EndIf

EventID.l = WindowEvent()
    If EventID = #PB_Event_CloseWindow 
      Quit = 1 
    EndIf 

  Until Quit = 1   
End


;- read ID3v2.3.x tag fields from MP3 file 
Procedure.l GetID3v2Tag(FileName.s) 
  If FileName = "" 
    ProcedureReturn #False 
  EndIf 
  
  ReadFile(1, FileName) 
  
  ID3.s = Space(3) 
  ReadData(@ID3, 3) 
  ; must be ID3v2.3.x 
  If ID3 = "ID3" And ReadByte() = $03 
    ID3Exists = #True 
    ; skip revision and flag bytes 
    ReadWord() 
    ; get tag size 
    ID3Size.l = 0 
    For Byte.l = 3 To 0 Step -1 
      ID3Size + (ReadByte() << (7*Byte)) 
    Next 
  Else 
    ; no ID3v2.3.x tag present 
    CloseFile(1) 
    ProcedureReturn #False 
  EndIf 
  
  ; clear tag contents 
  TagID3v2\Album = "" 
  TagID3v2\Artist = "" 
  TagID3v2\Comment = "" 
  TagID3v2\Composer = "" 
  TagID3v2\Copyright = "" 
  TagID3v2\EncodedBy = "" 
  TagID3v2\Encoder = "" 
  TagID3v2\Genre = "" 
  TagID3v2\OrgArtist = "" 
  TagID3v2\Title = "" 
  TagID3v2\Track = "" 
  TagID3v2\URL = "" 
  TagID3v2\Year = "" 
  
  Size.l = 0 
  Repeat 
    ; get frames until no more 
    FrameID.s = Space(4) 
    ReadData(@FrameID, 4) 
    If Asc(Left(FrameID, 1)) = 0 
      ; no more frames 
      CloseFile(1) 
      ProcedureReturn #True 
    EndIf 
    
    ; get frame size 
    FrameSize.l = 0 
    For Byte.l = 3 To 0 Step -1 
      FrameSize + (ReadByte() << (7*Byte)) 
    Next 
    ; add frame size to total size 
    Size + FrameSize 
    
    ; skip flag and language bytes 
    ReadWord() 
    ReadByte() 
    
    ; get frame contents 
    ; subtract one for language byte 
    FrameSize - 1 
    Contents.s = Space(FrameSize) 
    ReadData(@Contents, FrameSize) 
    
    ; put frame contents into structure 
    Select FrameID 
      Case "TALB" 
        TagID3v2\Album = Contents 
      Case "TCOM" 
        TagID3v2\Composer = Contents 
      Case "TCON" 
        TagID3v2\Genre = Contents 
      Case "TCOP" 
        TagID3v2\Copyright = Contents 
      Case "TENC" 
        TagID3v2\EncodedBy = Contents 
      Case "TIT2" 
        TagID3v2\Title = Contents 
      Case "TOPE" 
        TagID3v2\OrgArtist = Contents 
      Case "TPE1" 
        TagID3v2\Artist = Contents 
      Case "TRCK" 
        TagID3v2\Track = Contents 
      Case "TSSE" 
        TagID3v2\Encoder = Contents 
      Case "TYER" 
        TagID3v2\Year = Contents 
      Case "COMM" 
        TagID3v2\Comment = Contents 
      Case "WXXX" 
        TagID3v2\URL = Contents 
    EndSelect 
  ; stop if tag size reached/exceeded  
  Until Size >= ID3Size 

  CloseFile(1) 
  ProcedureReturn #True 
EndProcedure

verändere,
etwa so:

Code: Alles auswählen

"Staatsfeind"  = TagID3v2\Album
"Bulli"  = TagID3v2\Artist
"wos woas i"  = TagID3v2\Comment 
"Drecksog"  = TagID3v2\Composer
"gmbH"  = TagID3v2\Copyright
"sfdsd"  = TagID3v2\EncodedBy
"dsfds"  = TagID3v2\Encoder
"fsdaf"  = TagID3v2\Genre
"sasd"  = TagID3v2\OrgArtist
"dsfasd"  = TagID3v2\Title
"dsaf"  = TagID3v2\Track
"sdfa"  = TagID3v2\URL
"asdf"  = TagID3v2\Year
Die TAGs verändern oder geht das nicht
Danke für jede antwort

Verfasst: 25.12.2005 20:59
von roherter
Auf den ersten Blick würde sagen ,nein das geht nicht!
Sorry habe nur kurz Zeit deswegen ist mein Beitrag dazu so kurz.

Verfasst: 26.12.2005 01:35
von benpicco