コード例 #1
0
CStdString CWmp_scrobbler::GetCurrentSongFileName()
{
	USES_CONVERSION;
	CStdString strSong;
	IWMPMedia* pMedia = NULL;
	BSTR bstrSong;

	if(m_spCore)
	{
		m_spCore->get_currentMedia(&pMedia);
		
		if(pMedia != NULL)
		{
			pMedia->get_sourceURL(&bstrSong);

            char buf[1000];
            EncodingUtils::UnicodeToUtf8(
                bstrSong, -1,
                buf, 999);
            
            strSong = buf;
        }
	}

	return strSong;
}
コード例 #2
0
void CWmp2mirc::OnPlay()
{
  // if we are locked (property page could be doing stuff, or the timer proc), then just ignore the request.
  if(!m_cs.TryEnter())
  {
    LibCC::g_pLog->Message(_T("WMircP is busy; ignoring the play event."));
    return;
  }

  IWMPMedia* pMedia = 0;
  m_spCore->get_currentMedia(&pMedia);

  if(!pMedia)
  {
    LibCC::g_pLog->Message(_T("WMircP could not get a pointer to the current media."));
  }
  else
  {
    CComBSTR url;
    pMedia->get_sourceURL(&url);

		LibCC::LogScopeMessage lsm(LibCC::Format("OnPlay %").qs((BSTR)url).Str());
    m.OnPlay(pMedia, (PCWSTR)url);
    pMedia->Release();
  }

  m_cs.Leave();
}
コード例 #3
0
qint64 QWmpPlayerControl::duration() const
{
    double duration = 0.;

    IWMPMedia *media = 0;
    if (m_controls && m_controls->get_currentItem(&media) == S_OK) {
        media->get_duration(&duration);
        media->Release();
    }

    return duration * 1000;
}
コード例 #4
0
bool QWmpPlaylist::removeMedia(int pos)
{
    IWMPMedia *media = 0;
    if (m_playlist->get_item(pos, &media) == S_OK) {
        bool removed = m_playlist->removeItem(media) == S_OK;

        media->Release();

        return removed;
    } else {
        return false;
    }
}
コード例 #5
0
int QWmpPlaylistControl::currentIndex() const
{
    int position = 0;

    IWMPMedia *media = 0;
    if (m_controls && m_player->get_currentMedia(&media) == S_OK) {
        position = QWmpMetaData::value(media, QAutoBStr(L"PlaylistIndex")).toInt();

        media->Release();
    }

    return position;
}
コード例 #6
0
QMediaContent QWmpPlaylist::media(int pos) const
{
    QMediaContent content;

    IWMPMedia *media = 0;
    if (m_playlist && m_playlist->get_item(pos, &media) == S_OK) {
        content = QWmpMetaData::resources(media);

        media->Release();
    }

    return content;
}
コード例 #7
0
QVariant QWmpPlaylist::value(int index, const QString &key) const
{
    QVariant v;
    
    IWMPMedia *media = 0;
    if (m_playlist && m_playlist->get_item(index, &media) == S_OK) {
        v = QWmpMetaData::value(media, QAutoBStr(key));

        media->Release();
    }

    return v;
}
コード例 #8
0
QStringList QWmpPlaylist::keys(int index) const
{
    QStringList keys;

    IWMPMedia *media = 0;
    if (m_playlist && m_playlist->get_item(index, &media) == S_OK) {
        keys = QWmpMetaData::keys(media);

        media->Release();
    }

    return keys;
}
コード例 #9
0
bool QWmpPlaylist::addMedia(const QMediaContent &content)
{
    bool appended = false;

    IWMPMedia *media = 0;
    if (!content.isNull() && m_playlist && m_player && m_player->newMedia(
            QAutoBStr(content.canonicalUrl()), &media) == S_OK) {
        appended = m_playlist->appendItem(media) == S_OK;

        media->Release();
    }

    return appended;
}
コード例 #10
0
void QWmpPlaylistControl::setCurrentIndex(int position)
{

    IWMPPlaylist *playlist = 0;
    if (m_player->get_currentPlaylist(&playlist) == S_OK) {
        IWMPMedia *media = 0;
        if (playlist->get_item(position, &media) == S_OK) {
            m_player->put_currentMedia(media);

            media->Release();
        }
        playlist->Release();
    }
}
コード例 #11
0
bool QWmpPlaylist::insertMedia(int pos, const QMediaContent &content)
{
    bool inserted = false;

    IWMPMedia *media = 0;
    if (m_playlist && m_player && m_player->newMedia(
            QAutoBStr(content.canonicalUrl()), &media) == S_OK) {
        inserted = m_playlist->insertItem(pos, media) == S_OK;

        media->Release();
    }

    return inserted;
}
コード例 #12
0
QMediaTimeRange QWmpPlayerControl::availablePlaybackRanges() const
{
    QMediaTimeRange ranges;

    IWMPMedia *media = 0;
    if (m_controls && m_controls->get_currentItem(&media) == S_OK) {
        double duration = 0;
        media->get_duration(&duration);
        media->Release();

        if(duration > 0)
            ranges.addInterval(0, duration * 1000);
    }

    return ranges;
}
コード例 #13
0
void QWmpPlayerControl::mediaChangeEvent(IDispatch *dispatch)
{
    IWMPMedia *media = 0;
    if (dispatch &&  dispatch->QueryInterface(
            __uuidof(IWMPMedia), reinterpret_cast<void **>(&media)) == S_OK) {
        IWMPMedia *currentMedia = 0;
        if (m_controls && m_controls->get_currentItem(&currentMedia) == S_OK) {
            VARIANT_BOOL isEqual = VARIANT_FALSE;
            if (media->get_isIdentical(currentMedia, &isEqual) == S_OK && isEqual)
                scheduleUpdate(DurationChanged);

            currentMedia->Release();
        }
        media->Release();
    }
}
コード例 #14
0
void QWmpPlaylist::mediaChangeEvent(IDispatch *dispatch)
{

    IWMPMedia *media = 0;
    if (dispatch &&  dispatch->QueryInterface(
            __uuidof(IWMPMedia), reinterpret_cast<void **>(&media)) == S_OK) {
        VARIANT_BOOL isMember = VARIANT_FALSE;

        if (media->isMemberOf(m_playlist, &isMember) == S_OK && isMember) {
            int index = QWmpMetaData::value(media, QAutoBStr(L"PlaylistIndex")).toInt();

            if (index >= 0)
                emit mediaChanged(index, index);
        }
        media->Release();
    }
}
コード例 #15
0
int CWmp_scrobbler::GetTrackLength()
{
	double dDuration = -1;

	IWMPMedia* pMedia = NULL;
	
	if(m_spCore)
	{
		m_spCore->get_currentMedia(&pMedia);
		
		if(pMedia != NULL)
		{
			pMedia->get_duration(&dDuration);
		}
	}

	return (int)dDuration;
}
コード例 #16
0
bool QWmpPlaylist::removeMedia(int start, int end)
{
    if (!m_playlist)
        return false;

    for (int i = start; i <= end; ++i) {
        IWMPMedia *media = 0;
        if (m_playlist->get_item(start, &media) == S_OK) {
            bool removed = m_playlist->removeItem(media) == S_OK;

            media->Release();

            if (!removed)
                return false;
        }
    }
    return true;
}
コード例 #17
0
BOOL CWmp_scrobbler::GetCurrentSong(SONG_INFO* pSong)
{
	USES_CONVERSION;
	IWMPMedia* pMedia = NULL;
	BSTR bstrValue;
	//BSTR bstrName;
	BOOL bRet = FALSE;
	long lCount = 0;
	
	if(	(m_spCore) &&
		(pSong != NULL))
	{
		m_spCore->get_currentMedia(&pMedia);
		
		if(pMedia != NULL)
		{
			pMedia->get_attributeCount(&lCount);

/*
			for(long i = 0; i <= lCount; i++)
			{
				pMedia->getAttributeName(i, &bstrName);
				pMedia->getItemInfo(bstrName, &bstrValue);
				PRINTF(DEBUG_INFO, "WMPMEDIA", "Attribute %s - value %s", W2A(bstrName), W2A(bstrValue));
			}
            // Better check for local/streaming for the future
    		pMedia->getItemInfo(L"type", &bstrValue);
*/    		

			pMedia->getItemInfo(L"Author", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strArtist, SONG_INFO_FIELD_SIZE);
            pMedia->getItemInfo(L"Title", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strTrack, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Album", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strAlbum, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Genre", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strGenre, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Comment", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strComment, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"SourceURL", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strFileName, SONG_INFO_FIELD_SIZE);
			
			pMedia->getItemInfo(L"Duration", &bstrValue);
			pSong->m_nLength = atoi(W2A(bstrValue));
			pMedia->getItemInfo(L"Track", &bstrValue);
			pSong->m_nTrackNo = atoi(W2A(bstrValue));
			pMedia->getItemInfo(L"Year", &bstrValue);
			pSong->m_nYear = atoi(W2A(bstrValue));
			
			bRet = TRUE;
		}	
	}

	return bRet;
}