LibZPlay wrapper (updated)

Share your advanced PureBasic knowledge/code with the community.
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: LibZPlay wrapper (updated)

Post by Poshu »

Dirty but working... Well, I'll use that.
thanks :D
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: LibZPlay wrapper (updated)

Post by Poshu »

And, I also get an IMA when using zplay_LoadFileID3ex

Code: Select all

EnableExplicit

XIncludeFile "libzplay.pbi"

Define hZPlay, File.s, Text.s
Define ID3.TID3infoexW

File = OpenFileRequester("Please select a ogg-file", "*.mp3", "mp3|*.mp3", 0)
If File
 hZPlay = CreateZPlay()
 If hZPlay
  If zplay_OpenFile(hZPlay, File, #sfAutodetect)
   If zplay_LoadFileID3exW(hZPlay, File,#sfAutodetect, #id3Version2, @ID3,#False)
		zplay_Play(hZPlay)
          
     Text = "Title: " + id3\Title + #LF$
    Text + "from album: " + id3\Album + #LF$
    Text + "from year: " + id3\Year + #LF$ + #LF$
    Text + "Press okay to stop music"
    MessageRequester("Test libzplay", Text)
   EndIf
  EndIf
  zplay_Close(hZPlay)
  zplay_DestroyZPlay(hZPlay)
 EndIf
EndIf
erion
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Jan 24, 2010 11:12 pm

Re: LibZPlay wrapper (updated)

Post by erion »

Hi,
You got me on that one.

First, we have a small bug in the actual pbi file:
Change

Code: Select all

zplay_LoadFileID3ExW(hZPlay,pchFileName.p-Unicode, nFormat, nId3Version, *pId3Info.TID3InfoW, fDecodeEmbededPicture)
to

Code: Select all

zplay_LoadFileID3ExW(hZPlay,pchFileName.p-Unicode, nFormat, nId3Version, *pId3Info.TID3InfoExW, fDecodeEmbededPicture)
.

But Istill receive an IMA write error. I tried allocating with SizeOf(TID3InfoExW), but sadly the result is the same.

Maybe there is something wrong with the structure, but everything seems fine to me.

Code: Select all

typedef struct {
    wchar_t *Title;
    wchar_t *Artist;
    wchar_t *Album;
    wchar_t *Year;
    wchar_t *Comment;
    wchar_t *TrackNum; 
    wchar_t *Genre;
    wchar_t *AlbumArtist;
    wchar_t *Composer;
    wchar_t *OriginalArtist;
    wchar_t *Copyright;
    wchar_t *URL;
    wchar_t *Encoder;
    wchar_t *Publisher;
    unsigned int BPM;
    TID3PictureW Picture;
    char reserved[128];
} TID3InfoExW;
As opposed to the PB code:

Code: Select all

Structure TID3InfoExW
 Title.s
 Artist.s
 Album.s
 Year.s
 Comment.s
 TrackNum.s
 Genre.s
 AlbumArtist.s
 Composer.s
 OriginalArtist.s
 Copyright.s
 URL.s
 Encoder.s
 Publisher.s
 BPM.l
 Picture.TID3PictureW
 reserved.u[128]
EndStructure
In unicode mode, this should work fine...

The help file mentions that this structure needs to be allocated, but I assume that PB allocates nested structures as well. If not, the picture field might be the culprit.

Hats off to anyone who can explain what's going on here :)

Erion
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.

- W. B.

Visit my site, also for PureBasic goodies http://erion.tdrealms.com
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: LibZPlay wrapper (updated)

Post by Poshu »

I've tried to mess up with the structure as much as my knowledge allowed me and could not fix it.
Any advanced user to help here?
Post Reply