Jump to content

ID3.au3 UDF - Problem writing Tag


gobsor
 Share

Recommended Posts

Hello once again!

I've experianced another problem with

I'm using the latest UDF version: http://www.autoitscript.com/forum/index.php?app=core&module=attach&section=attach&attach_id=31144

Here is my example code:

#include <GUIConstantsEx.au3>
#include "ID3.au3"

GUICreate("test", 100, 100)
$b = GUICtrlCreateButton("a", 40, 40, 20, 20)
GUISetState(@SW_SHOW)

While(1)
    $msg = GUIGetMsg()
    If $msg == $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf
    If $msg == $b Then
        _ID3SetTagField("TIT2", "title")
        _ID3SetTagField("TPE1", "artist")
        _ID3WriteTag("a.mp3")
    EndIf
WEnd

When pressing button 'a' the file actually gets tagged, artist is set to 'artist', title is set to 'title', just somehow this messes up the length (playtime) shown in WinAMP. What am I doing wrong? Using the ID3_Example_GUI.au3 provided with the UDF it just works fine, apparently. Though, when I tag the

'a.mp3' using my example code (I tried different *.MP3 files though) one file that has usually 3:45 playtime is after tagging, shown as 00:00. Another that should be 4:17 was after tagging showing '23:27' in WinAMP.

Thanks in advance,

gob

Link to comment
Share on other sites

That's weird, because when I use this code on any *.MP3 file it screws the length ('playtime') of the file. When i add the file to my winamp playlist BEFORE tagging, it shows 3:14 length. When I tag it and re-drag&drop it into my playlist it suddently shows some wrong mm:ss length. Some MP3 files with ie. 3:25 length suddently show 23:46 or 22:16 or just 00:00.

Any suggestions?

Link to comment
Share on other sites

Ah, thanks. When reading tags, it gives you a NULL terminated string. Fields ('TPE1', 'TIT2') are apparently 30 chars in length, if artist name is less than 30 chars rest is filled with 0's.

I guess I have to fill up my AutoIT strings with 0's then to get it working properly.

I'll try when I find a few spare minutes and let you know the result.

rgrds

EDIT:

Found some spare time right now.. :x

Made this test code and 'null-terminate' my strings with it before using them on _ID3SetTag() provided by ID3 UDF. Works for me now.

Not sure though if all fields have same length, but that's basically what to do to avoid the tag function screwing up MP3 length (playtime).

Apparently the length of a track is the total size of headers or summat, too lazy to look it up right now but I'm sure one can find it on the

official ID3vX website in the RFC.

#include <File.au3>

_strAddNULLTerm("yo this is test aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")

Func _strAddNULLTerm($sString)
    $sStr = ""
    $aAsc = StringToASCIIArray($sString)
    $size = UBound($aAsc)-1
    If $size > 29 Then
        For $i = 0 To 29
            $sStr &= Chr($aAsc[$i])
        Next
        Return $sStr
    Else
        $left = 29 - $size
        For $i = 0 To $size
            $sStr &= Chr($aAsc[$i])
        Next
        For $i = 0 To $left-1
            $sStr &= Chr(0)
        Next
        Return $sStr    
    EndIf
EndFunc ;==> _strAddNULLTerm($sString)
Edited by gobsor
Link to comment
Share on other sites

I lied.. It was pretty late yesterday and the example-test-code provided in my last code doesn't work.

I commented out the old code when writing it and accidently set a comment for _ID3WrtieTag(), too, I

didn't check if the tags were written I just checked for the length of the MP3-file displayed in WinAMP...

I added _ID3WriteTag() and used NULL-termination when I noticed I accidently commented it out.. and guess

what.. failed again!

Though, even adding a NULL-termination to the strings doesn't work. Still screws the shown playtime.

If anyone has further ideas.. I'm open for any suggestions. I'll keep on trying to get this working and keep

you pasted if i find some workaround or any solution to this matter.

Link to comment
Share on other sites

The pattern I notice is that mp3s with v1 tags work fine. The v2 tags do not. The one on the left is a v.2 and the one on the right is v1.

Posted Image

Short of diving into the UDF and fixing it, I think the only thing you could do is a recursive search of an array return to find the various fields.

#include <ByteMe.au3>

Link to comment
Share on other sites

If you open the song in the example gui from the ID3.udf thread does it display a length? Also, does it still show all of the other tags, the ones you didn't overwrite? Or, have you opened the file in an MP3 tag reader/writer program to see what's there or what's missing?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Opened it in WinAMP and viewed the fields there.

Yeh, I came across other forum posts on that UDF. Seems its pretty glitched.

If one who knows AU3 better than me could fix the UDF - *thumbs up*.

If not, probably gonna use some DLL (found AudioGenie3.dll on Google which

apparently supports most functions that I need). Though I thought without some

external file (*.dll/*.exe/*.w/e) it would be sexier.

@sleepy:

If you're going to do the job keep us pasted please :-)

regards

Edited by gobsor
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...