SOL9 Sample: WMPLocalLibraryStringCollection

SOL9 2.0 Samples

1 Screenshot





2 Source code

/*
 * WMPLocalLibraryStringCollection.cpp 
 * Copyright (c) 2012 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2011/12/28

#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/wmp/WMPStringCollection.h>
#include <sol/FileWriter.h>


int _tmain(int argc, _TCHAR* argv[])
 
{
    if (argc != 4) {
        _tprintf(_T("Usage:%s attribute mediaType xmlFileName\n"), argv[0]);
        _tprintf(_T(" attribute: Name|Artist|...\n"));
        _tprintf(_T(" mediaType: audio|video|photo|playlist|other\n"));

        return 0;
    }
    _bstr_t attribute = argv[1];
    _bstr_t mediaType = argv[2];

    COMInitializer initializer;

    Locale locale;
    const TCHAR* xmlFile = argv[3];

    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.getLocalLibraryCount();
            
        writer.writeln(L"<Library MediaType=\"%s\" Count=\"%d\">", (const wchar_t*)mediaType, lcount);

        for (long n = 0; n<lcount; n++) {
            WMPLibrary library =services.getLocalLibrary(n);

            WMPMediaCollection mediaCollection = library.getMediaCollection();
            WMPStringCollection stringCollection = mediaCollection.getAttributeStringCollection(attribute, mediaType);
            stringCollection.write(attribute, mediaType, writer);
        }
        writer.writeln(L"</Library>");
        writer.writeln(L"</%s>", argv[0]);

    } catch (...) {
        printf("Exception\n");
    }


}

Last modified: 1 Feb 2012

Copyright (c) 2012 Antillia.com ALL RIGHTS RESERVED.