SOL9 Sample: WMPAllLibrary
|
1 Screenshot
2 Source code
/*
* WMPAllLibrary.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2011/12/07
#include <sol/COMInitializer.h>
#include <sol/Locale.h>
#include <sol/wmp/WMPPlayer.h>
#include <sol/wmp/WMPLibrary.h>
#include <sol/wmp/WMPLibraryServices.h>
#include <sol/wmp/WMPMediaCollection.h>
#include <sol/wmp/WMPPlaylist.h>
#include <sol/wmp/WMPMedia.h>
#include <sol/FileWriter.h>
int _tmain(int argc, _TCHAR* argv[])
{
if (argc != 3) {
_tprintf(_T("Usage:%s mediaType xmlFileName\n"), argv[0]);
_tprintf(_T(" mediaType: audio|video|photo|playlist|other\n"));
return 0;
}
_bstr_t mediaType(argv[1]);
const TCHAR* xmlFile = argv[2];
COMInitializer initializer;
Locale locale;
try {
FileWriter writer = xmlFile;
writer.writeln(L"<?xml version=\"1.0\" encoding=\"UTF-16\" ?>");
writer.writeln(L"<%s>", argv[0]);
WMPPlayer player;
WMPLibraryServices services = player.getLibraryServices();
long lcount = services.getAllLibraryCount();
writer.writeln(L"<Library MediaType=\"%s\" Count=\"%d\">", (const wchar_t*)mediaType, lcount);
for (long n = 0; n<lcount; n++) {
WMPLibrary library =services.getAllLibrary(n);
WMPMediaCollection mediaCollection = library.getMediaCollection();
IWMPQueryPtr query =mediaCollection.createQuery();
_bstr_t attribute = "Name";
WMPPlaylist playlist = mediaCollection.getPlaylistByQuery(query, mediaType,
attribute, VARIANT_TRUE);
long count = playlist.getCount();
writer.writeln(L"<Playlist Count=\"%d\">", count);
for (long i = 0; i<count; i++) {
WMPMedia media = playlist.getItem(i);
media.writeProperties(writer);
}
writer.writeln(L"</Playlist>");
}
writer.writeln(L"</Library>");
writer.writeln(L"</%s>", argv[0]);
} catch (...) {
printf("Exception\n");
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.