Esempio n. 1
0
bool
ITunesTrack::podcast()
{
    VARIANT_BOOL podcast = FALSE;
    IITFileOrCDTrack* fileTrack = 0;
    HRESULT res = m_comTrack->QueryInterface( IID_IITFileOrCDTrack, (void**)&fileTrack );
    if ( res != S_OK || fileTrack == 0 )
    {
        ITunesComWrapper::logComError( res, L"Casting IITrack to IITFileOrCDTrack failed" );
    }
    else
    {
        res = fileTrack->get_Podcast( &podcast );
        if ( res != S_OK )
        {
            BSTR a;
            BSTR n;
            fileTrack->get_Artist( &a );
            fileTrack->get_Name( &n );
            wstring artist = ITunesComWrapper::bstrToWString( a );
            wstring track = ITunesComWrapper::bstrToWString( n );
            wostringstream os;
            os << L"COM couldn't get podcast for " << artist << L" - " << track;
            ITunesComWrapper::logComError( res, os.str() );
        }

        fileTrack->Release();
    }

    return podcast != FALSE;
}
Esempio n. 2
0
wstring
ITunesTrack::pathForTrack( IITTrack* track )
{
    wstring path;
    IITFileOrCDTrack* fileTrack = 0;
    HRESULT res = track->QueryInterface( IID_IITFileOrCDTrack, (void**)&fileTrack );
    if ( res != S_OK || fileTrack == 0 )
    {
        // Not ideal, but logging this makes the iPodScrobbler log
        // really messy for mostly iTunes Match track libraries
        //ITunesComWrapper::logComError( res, L"Casting IITrack to IITFileOrCDTrack failed" );
    }
    else
    {
        BSTR bstrLocation = 0; // BSTR = WCHAR*
        res = fileTrack->get_Location( &bstrLocation );
        if ( res == S_OK )
        {
            path = ITunesComWrapper::bstrToWString( bstrLocation );
        }
        else
        {
            BSTR a;
            BSTR n;
            fileTrack->get_Artist( &a );
            fileTrack->get_Name( &n );
            wstring artist = ITunesComWrapper::bstrToWString( a );
            wstring track = ITunesComWrapper::bstrToWString( n );
            wostringstream os;
            os << L"COM couldn't get file path for " << artist << L" - " << track;
            ITunesComWrapper::logComError( res, os.str() );
        }

        fileTrack->Release();
    }

    return path;
}
Esempio n. 3
0
bool
ITunesTrack::video()
{
    bool video = false;
    IITFileOrCDTrack* fileTrack = 0;
    HRESULT res = m_comTrack->QueryInterface( IID_IITFileOrCDTrack, (void**)&fileTrack );
    if ( res != S_OK || fileTrack == 0 )
    {
        ITunesComWrapper::logComError( res, L"Casting IITrack to IITFileOrCDTrack failed" );
    }
    else
    {
        ITVideoKind videoKind = ITVideoKindNone;
        res = fileTrack->get_VideoKind( &videoKind );
        if ( res == S_OK )
        {
            video = videoKind != ITVideoKindNone && videoKind != ITVideoKindMusicVideo;
        }
        else
        {
            BSTR a;
            BSTR n;
            fileTrack->get_Artist( &a );
            fileTrack->get_Name( &n );
            wstring artist = ITunesComWrapper::bstrToWString( a );
            wstring track = ITunesComWrapper::bstrToWString( n );
            wostringstream os;
            os << L"COM couldn't get video kind for " << artist << L" - " << track;
            ITunesComWrapper::logComError( res, os.str() );
        }

        fileTrack->Release();
    }

    return video;
}