WMA question
-
I am having some problems with the editing of wma tags. I have a program that I created that will convert files from one format to another. I have implemented the WMA functionality using the WMF sdk and it is working well. But one problem that I have is when I try to use IWMHeaderInfo3 to add the title to the wma header (similar to ID3 tagging in MP3 files), I have found the title shows strange characters instead of the actual title. I am performing the necessary functions: open, QueryInterface, AddAttribute (and I tried SetAttribute), BeginWriting, and EndWriting. Per the MSDN documentation, I am doing everything in the correct manner. The conversion works but the actual tagging does not. Here is the actual AddAttribute call: pHdr->AddAttribute(0, L"Title", &wDummy, WMT_TYPE_STRING,0, (LPBYTE)&strValue, sizeof(WCHAR) * (strValue.Length() + 1)); Any ideas?
-
I am having some problems with the editing of wma tags. I have a program that I created that will convert files from one format to another. I have implemented the WMA functionality using the WMF sdk and it is working well. But one problem that I have is when I try to use IWMHeaderInfo3 to add the title to the wma header (similar to ID3 tagging in MP3 files), I have found the title shows strange characters instead of the actual title. I am performing the necessary functions: open, QueryInterface, AddAttribute (and I tried SetAttribute), BeginWriting, and EndWriting. Per the MSDN documentation, I am doing everything in the correct manner. The conversion works but the actual tagging does not. Here is the actual AddAttribute call: pHdr->AddAttribute(0, L"Title", &wDummy, WMT_TYPE_STRING,0, (LPBYTE)&strValue, sizeof(WCHAR) * (strValue.Length() + 1)); Any ideas?
Al_Pennyworth wrote:
when I try to use IWMHeaderInfo3 to add the title to the wma header (similar to ID3 tagging in MP3 files), I have found the title shows strange characters instead of the actual title.
Shows where? How are you looking at the resulting attribute? What strange characters?
"If you can dodge a wrench, you can dodge a ball."
-
I am having some problems with the editing of wma tags. I have a program that I created that will convert files from one format to another. I have implemented the WMA functionality using the WMF sdk and it is working well. But one problem that I have is when I try to use IWMHeaderInfo3 to add the title to the wma header (similar to ID3 tagging in MP3 files), I have found the title shows strange characters instead of the actual title. I am performing the necessary functions: open, QueryInterface, AddAttribute (and I tried SetAttribute), BeginWriting, and EndWriting. Per the MSDN documentation, I am doing everything in the correct manner. The conversion works but the actual tagging does not. Here is the actual AddAttribute call: pHdr->AddAttribute(0, L"Title", &wDummy, WMT_TYPE_STRING,0, (LPBYTE)&strValue, sizeof(WCHAR) * (strValue.Length() + 1)); Any ideas?
Wait...what type is strValue? Looking at it again, this cast looks really suspicious: (LPBYTE)&strValue If it's a CString, try (LPBYTE)(LPCTSTR)strValue
*edit* never mind. CString doesn't have a Length() method. Regardless, you'll need to pass a pointer to a NULL-terminated Unicode string.
Mark"If you can dodge a wrench, you can dodge a ball."
-
Wait...what type is strValue? Looking at it again, this cast looks really suspicious: (LPBYTE)&strValue If it's a CString, try (LPBYTE)(LPCTSTR)strValue
*edit* never mind. CString doesn't have a Length() method. Regardless, you'll need to pass a pointer to a NULL-terminated Unicode string.
Mark"If you can dodge a wrench, you can dodge a ball."
Mark Salsbery wrote:
CString doesn't have a Length() method
CString::GetLength()[^] maybe ?
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Mark Salsbery wrote:
CString doesn't have a Length() method
CString::GetLength()[^] maybe ?
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Heh right. I'm trying to decipher what the type is without the OP :) (S)he uses Length() so maybe it's a CComBSTR ? Basically I'm talking to myself :laugh: Just to see how much time I can spend on one post without getting anywhere! :beer:
"If you can dodge a wrench, you can dodge a ball."
-
I am having some problems with the editing of wma tags. I have a program that I created that will convert files from one format to another. I have implemented the WMA functionality using the WMF sdk and it is working well. But one problem that I have is when I try to use IWMHeaderInfo3 to add the title to the wma header (similar to ID3 tagging in MP3 files), I have found the title shows strange characters instead of the actual title. I am performing the necessary functions: open, QueryInterface, AddAttribute (and I tried SetAttribute), BeginWriting, and EndWriting. Per the MSDN documentation, I am doing everything in the correct manner. The conversion works but the actual tagging does not. Here is the actual AddAttribute call: pHdr->AddAttribute(0, L"Title", &wDummy, WMT_TYPE_STRING,0, (LPBYTE)&strValue, sizeof(WCHAR) * (strValue.Length() + 1)); Any ideas?
The other posts are right - you need to pass a real Unicode string, not a pointer to a string wrapper object.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
The other posts are right - you need to pass a real Unicode string, not a pointer to a string wrapper object.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
I have been offline for a bit so I wasn't able to answer any questions. The strValue that is being used is CComBSTR so it is not a CString. Where I am seeing the awkward values is in WMP, WinAmp, other media players, and in Explorer. It is displaying the box character for the length of the title.
-
I have been offline for a bit so I wasn't able to answer any questions. The strValue that is being used is CComBSTR so it is not a CString. Where I am seeing the awkward values is in WMP, WinAmp, other media players, and in Explorer. It is displaying the box character for the length of the title.
Try LPCWSTR pUnicodeStrValue = OLE2CW(strValue); pHdr->AddAttribute(0, L"Title", &wDummy, WMT_TYPE_STRING,0, (LPBYTE)pUnicodeStrValue, sizeof(WCHAR) * (wcslen(pUnicodeStrValue) + 1));
"If you can dodge a wrench, you can dodge a ball."
-
I have been offline for a bit so I wasn't able to answer any questions. The strValue that is being used is CComBSTR so it is not a CString. Where I am seeing the awkward values is in WMP, WinAmp, other media players, and in Explorer. It is displaying the box character for the length of the title.
CComBSTR
has anoperator BSTR
which gets you a pointer to the wrappedBSTR
, so use that. Instead of(LPBYTE)&strValue
use(LPBYTE)(BSTR)strValue
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
CComBSTR
has anoperator BSTR
which gets you a pointer to the wrappedBSTR
, so use that. Instead of(LPBYTE)&strValue
use(LPBYTE)(BSTR)strValue
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
I want to thank everyone for the replies, works like a charm now!