Exemple #1
0
BOOL ovd_get_comment_from_file(LPCTSTR pszFile, ovd_comment* comment)
{
	if (!ovd_test_file(pszFile))
		return FALSE;

	FILE* fp = _tfopen(pszFile, _T("rb"));
	if (!fp)
		return FALSE;

	OggVorbis_File	vf;
	if (ov_open(fp, &vf, NULL, 0) < 0)
	{
		fclose(fp);
		return FALSE;
	}

	memset(comment, 0, sizeof(ovd_comment));
	vorbis_comment* p = ov_comment(&vf, -1);
	for (int i = 0; i < p->comments; i++)
	{
		LPTSTR psz = NULL;
		char* s = strchr(p->user_comments[i], '=');
		if (s)
		{
			*s = NULL;
			ovd_strupr(p->user_comments[i]);
			if (strcmp(p->user_comments[i], OVD_COMMENT_DATE) == 0)
				psz = comment->szDate;
			else if (strcmp(p->user_comments[i], OVD_COMMENT_TRACKNUM) == 0)
				psz = comment->szTrackNum;
			else if (strcmp(p->user_comments[i], OVD_COMMENT_TITLE) == 0)
				psz = comment->szTitle;
			else if (strcmp(p->user_comments[i], OVD_COMMENT_ARTIST) == 0)
				psz = comment->szArtist;
			else if (strcmp(p->user_comments[i], OVD_COMMENT_ALBUM) == 0)
				psz = comment->szAlbum;
			else if (strcmp(p->user_comments[i], OVD_COMMENT_GENRE) == 0)
				psz = comment->szGenre;
			else if (strcmp(p->user_comments[i], OVD_COMMENT_COMMENT) == 0)
				psz = comment->szComment;

			if (psz)
			{
#ifdef _UNICODE
				UTF8toUCS2(s + 1, psz, OVD_COMMENT_LEN);
#else
				WCHAR sz[OVD_COMMENT_LEN];
				UTF8toUCS2(s + 1, sz, OVD_COMMENT_LEN);
				WideCharToMultiByte(CP_ACP, 0, sz, -1, psz, OVD_COMMENT_LEN, 0, 0);
#endif	
			}
		}
	}
	fclose(fp);
	return TRUE;
}
Exemple #2
0
BOOL CPlayer::OvIsValidFile(LPCTSTR pszFile)
{
	return ovd_test_file(pszFile);
}