/*!
  Use \a playlist as the source of images to be displayed in the viewer.
*/
void QMediaImageViewer::setPlaylist(QMediaPlaylist *playlist)
{
    Q_D(QMediaImageViewer);

    if (d->playlist) {
        disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
                   this, SLOT(_q_playlistMediaChanged(QMediaContent)));
        disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed()));

        QMediaObject::unbind(d->playlist);
    }

    d->playlist = playlist;

    if (d->playlist) {
        connect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
                this, SLOT(_q_playlistMediaChanged(QMediaContent)));
        connect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed()));

        QMediaObject::bind(d->playlist);

        setMedia(d->playlist->currentMedia());
    } else {
        setMedia(QMediaContent());
    }
}
void QMediaImageViewer::setMedia(const QMediaContent &media)
{
    Q_D(QMediaImageViewer);

    if (d->playlist && d->playlist->currentMedia() != media) {
        disconnect(d->playlist, SIGNAL(currentMediaChanged(QMediaContent)),
                   this, SLOT(_q_playlistMediaChanged(QMediaContent)));
        disconnect(d->playlist, SIGNAL(destroyed()), this, SLOT(_q_playlistDestroyed()));

        d->playlist = 0;
    }

    d->media = media;

    if (d->timer.isActive()) {
        d->pauseTime = 0;
        d->timer.stop();
        removePropertyWatch("elapsedTime");
        emit elapsedTimeChanged(0);
    }

    if (d->state != QMediaImageViewer::StoppedState)
        emit stateChanged(d->state = QMediaImageViewer::StoppedState);

    d->viewerControl->showMedia(d->media);

    emit mediaChanged(d->media);
}
void QMediaPlayerPrivate::connectPlaylist()
{
    Q_Q(QMediaPlayer);
    if (playlist) {
        QObject::connect(playlist, SIGNAL(currentMediaChanged(QMediaContent)),
                         q, SLOT(_q_updateMedia(QMediaContent)));
        QObject::connect(playlist, SIGNAL(destroyed()), q, SLOT(_q_playlistDestroyed()));
    }
}