Click here to Skip to main content
15,885,435 members
Articles / Desktop Programming / MFC

An Update To the Wrapper Class for the libid3tag Library

Rate me:
Please Sign up or sign in to vote.
4.07/5 (6 votes)
19 Apr 20064 min read 44.6K   862   35  
An updated wrapper class to retrieve and modify id3 tag information for a given MP3 file.
/*
** MP3ID3.h 
**
** Author: Yubo Dong (yubodong@gmail.com
**
** Copyright (C) 2006 Yubo Dong
** 
** This is a wrapper class for libid3tag-0.15.1b.
*/
#pragma once
#include "id3tag.h"
#include "MP3Info.h"

class CMP3ID3
{
private:
	struct id3_file*	m_pID3File;
	struct id3_tag*		m_pID3Tag;
	ustring				m_strMP3File;
public:
	CMP3ID3(void);
	CMP3ID3(string strgile, bool bReadOnly=true);
	~CMP3ID3(void);
public:
	bool		prepareMP3(string strFile, bool bReadOnly=true);
	ustring		getTitle();		//Return title
	ustring		getArtist();	//Return artist
	ustring		getAlbum();		//Return album
	ustring		getYear();		//Return recording time
	ustring		getTrack();		//Return original CD track 
	ustring		getGenre();		//Return genre
	ustring		getComment();	//Return comment

	bool		setTitle(ustring,bool bUpdateImmediately = false);	//Set title
	bool		setArtist(ustring,bool bUpdateImmediately = false);	//Set artist
	bool		setAlbum(ustring,bool bUpdateImmediately = false);	//Set album
	bool		setYear(ustring,bool bUpdateImmediately = false);	//Set recording time
	bool		setTrack(ustring,bool bUpdateImmediately = false);	//Set original CD track 
	bool		setGenre(ustring,bool bUpdateImmediately = false);	//Set genre
	bool		setComment(ustring,bool bUpdateImmediately = false);//Set comment
	bool		update();

	CMP3Info	getMP3Info();	//Return all ID3 tag information in a class CMP3Info
	CMP3Info	getMP3Info(string strFile, bool bReadOnly=true);
	static		long	getTagLength(string strFile);	//get length of id3 tag

private:
	ustring		getFrame(const char *frameID);
	bool setFrame(const char *frameID, ustring strText,bool bUpdateImmediately = false);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Software Developer and SQL Server DBA

Comments and Discussions