Exemplo n.º 1
0
void QWmpPlayerService::releaseControl(QMediaControl *control)
{
    if (!control) {
        qWarning("QMediaService::releaseControl():"
                " Attempted release of null control");
#ifdef QWMP_EVR
    } else if (control == m_evrVideoOverlay) {

        IWMPVideoRenderConfig *config = 0;
        if (m_player->QueryInterface(
                __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) {
            config->put_presenterActivate(0);
            config->Release();
        }

        delete m_evrVideoOverlay;

        m_evrVideoOverlay = 0;
        m_activeVideoOverlay = 0;
#endif
    } else if (control == m_oleVideoOverlay) {
        m_player->put_uiMode(QAutoBStr(L"invisible"));
        m_oleVideoOverlay->setWinId(0);

        m_activeVideoOverlay = 0;
    }
}
void QWmpPlaylistControl::currentItemChangeEvent(IDispatch *dispatch)
{
    IWMPMedia *media = 0;
    if (dispatch && dispatch->QueryInterface(
            __uuidof(IWMPMedia), reinterpret_cast<void **>(&media)) == S_OK) {
        int index = QWmpMetaData::value(media, QAutoBStr(L"PlaylistIndex")).toInt();

        emit currentIndexChanged(index);
        emit currentMediaChanged(m_playlist->media(index));
    }
}
Exemplo n.º 3
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;
}
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;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
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();
    }
}
Exemplo n.º 8
0
QMediaControl *QWmpPlayerService::requestControl(const char *name)
{
    if (qstrcmp(name, QMediaPlayerControl_iid) == 0) {
        return m_control;
    } else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) {
        return m_metaData;
    } else if (qstrcmp(name, QMediaPlaylistControl_iid) == 0) {
        return m_playlist;
    } else if (qstrcmp(name, QVideoWindowControl_iid) == 0
            && m_embedMode == LocalEmbed
            && m_player
            && !m_activeVideoOverlay) {
#ifdef QWMP_EVR
        IWMPVideoRenderConfig *config = 0;
        if (m_player->QueryInterface(
                __uuidof(IWMPVideoRenderConfig), reinterpret_cast<void **>(&config)) == S_OK) {
            if (HINSTANCE evrHwnd = LoadLibrary(L"evr")) {
                m_evrVideoOverlay = new QEvrVideoOverlay(evrHwnd);

                if (SUCCEEDED(config->put_presenterActivate(
                        static_cast<IMFActivate *>(m_evrVideoOverlay)))) {
                    connect(m_events, SIGNAL(OpenStateChange(long)),
                            m_evrVideoOverlay, SLOT(openStateChanged(long)));
                } else {
                    delete m_evrVideoOverlay;

                    m_evrVideoOverlay = 0;
                }
            }
            config->Release();
        }

        if (m_evrVideoOverlay) {
            m_activeVideoOverlay = m_evrVideoOverlay;

            return m_evrVideoOverlay;
        } else
#endif
        if (SUCCEEDED(m_player->put_uiMode(QAutoBStr(L"none")))) {
            m_activeVideoOverlay = m_oleVideoOverlay;

            return m_oleVideoOverlay;
        }
    }
    return 0;
}