Exemplo n.º 1
0
void Document::setLoadState( Document::LoadState state )
{
    if( state != loadState() )
    {
        m_loadState = state;
        emit( loadStateChanged( this, state ) );
        if( state == Document::Complete ) {
            emit( loadingComplete( this ) );
        }
    }
}
void MediaPlayerPrivateAVFoundation::dispatchNotification()
{
    ASSERT(isMainThread());

    Notification notification = Notification();
    {
        MutexLocker lock(m_queueMutex);
        
        if (m_queuedNotifications.isEmpty())
            return;
        
        if (!m_delayCallbacks) {
            // Only dispatch one notification callback per invocation because they can cause recursion.
            notification = m_queuedNotifications.first();
            m_queuedNotifications.remove(0);
        }
        
        if (!m_queuedNotifications.isEmpty() && !m_mainThreadCallPending)
            callOnMainThread(mainThreadCallback, this);
        
        if (!notification.isValid())
            return;
    }

    LOG(Media, "MediaPlayerPrivateAVFoundation::dispatchNotification(%p) - dispatching %d", this, static_cast<int>(notification.type()));

    switch (notification.type()) {
    case Notification::ItemDidPlayToEndTime:
        didEnd();
        break;
    case Notification::ItemTracksChanged:
        tracksChanged();
        break;
    case Notification::ItemStatusChanged:
        loadStateChanged();
        break;
    case Notification::ItemSeekableTimeRangesChanged:
        seekableTimeRangesChanged();
        loadStateChanged();
        break;
    case Notification::ItemLoadedTimeRangesChanged:
        loadedTimeRangesChanged();
        loadStateChanged();
        break;
    case Notification::ItemPresentationSizeChanged:
        sizeChanged();
        break;
    case Notification::ItemIsPlaybackLikelyToKeepUpChanged:
        loadStateChanged();
        break;
    case Notification::ItemIsPlaybackBufferEmptyChanged:
        loadStateChanged();
        break;
    case Notification::ItemIsPlaybackBufferFullChanged:
        loadStateChanged();
        break;
    case Notification::PlayerRateChanged:
        rateChanged();
        break;
    case Notification::PlayerTimeChanged:
        timeChanged(notification.time());
        break;
    case Notification::AssetMetadataLoaded:
        metadataLoaded();
        break;
    case Notification::AssetPlayabilityKnown:
        playabilityKnown();
        break;
    case Notification::None:
        ASSERT_NOT_REACHED();
        break;
    }
}