예제 #1
0
void PlaylistModel::setPlaybackMode(PlaybackMode mode)
{
    m_playbackMode = mode;

    emit playbackModeChanged(mode);
    emit modified();
}
예제 #2
0
void tst_QMediaPlaylistNavigator::testPlaybackModeChangedSignal()
{
    QMediaNetworkPlaylistProvider playlist;
    QMediaPlaylistNavigator navigator(&playlist);
    navigator.setPlaybackMode(QMediaPlaylist::Random);
    QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
    QCOMPARE(navigator.currentIndex(), -1);

    //Creating a QSignalSpy object for currentIndexChanged() signal
    QSignalSpy spy(&navigator,SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
    QVERIFY(spy.count() == 0);

    //Adding the media to the playlist
    playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));

    //set the play back mode to sequential
    navigator.setPlaybackMode(QMediaPlaylist::Sequential);
    QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Sequential);
    QVERIFY(spy.count() == 1);

    //set the play back mode to loop
    navigator.setPlaybackMode(QMediaPlaylist::Loop);
    QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Loop);
    QVERIFY(spy.count() == 2);
}
예제 #3
0
/*!
  \internal
  If \a mediaObject is null or doesn't have an intrinsic playlist,
  internal local memory playlist source will be created.
*/
bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject)
{
    Q_D(QMediaPlaylist);

    if (mediaObject && mediaObject == d->mediaObject)
        return true;

    QMediaService *service = mediaObject
            ? mediaObject->service() : 0;

    QMediaPlaylistControl *newControl = 0;

    if (service)
        newControl = qobject_cast<QMediaPlaylistControl*>(service->requestControl(QMediaPlaylistControl_iid));

    if (!newControl)
        newControl = d->networkPlaylistControl;

    if (d->control != newControl) {
        int oldSize = 0;
        if (d->control) {
            QMediaPlaylistProvider *playlist = d->control->playlistProvider();
            oldSize = playlist->mediaCount();
            disconnect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)),
                    this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString)));

            disconnect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int)));
            disconnect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int)));
            disconnect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int)));
            disconnect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int)));
            disconnect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int)));

            disconnect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded()));

            disconnect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)),
                    this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
            disconnect(d->control, SIGNAL(currentIndexChanged(int)),
                    this, SIGNAL(currentIndexChanged(int)));
            disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)),
                    this, SIGNAL(currentMediaChanged(QMediaContent)));

            if (d->mediaObject)
                d->mediaObject->service()->releaseControl(d->control);
        }
void MediaPlayer :: setPlaybackMode(playMode mode)
{
    switch(mode)
    {
        case AutoQueue:
            autoQueue = true;
            playlist->setPlaybackMode(QMediaPlaylist::Sequential);
            checkPlaylist(playlist->currentIndex());
        break;

        case Repeat:
            autoQueue = false;
            playlist->setPlaybackMode(QMediaPlaylist::Loop);
        break;

        case Shuffle:
            autoQueue = false;
            playlist->setPlaybackMode(QMediaPlaylist::Random);
        break;
    }

    iPlaybackMode = mode;
    emit playbackModeChanged(iPlaybackMode);
}
예제 #5
0
        }

        d->control = newControl;
        QMediaPlaylistProvider *playlist = d->control->playlistProvider();
        connect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)),
                this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString)));

        connect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int)));
        connect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int)));
        connect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int)));
        connect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int)));
        connect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int)));

        connect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded()));

        connect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)),
                this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
        connect(d->control, SIGNAL(currentIndexChanged(int)),
                this, SIGNAL(currentIndexChanged(int)));
        connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)),
                this, SIGNAL(currentMediaChanged(QMediaContent)));

        if (oldSize)
            emit mediaRemoved(0, oldSize-1);

        if (playlist->mediaCount()) {
            emit mediaAboutToBeInserted(0,playlist->mediaCount()-1);
            emit mediaInserted(0,playlist->mediaCount()-1);
        }
    }
예제 #6
0
	void PlaybackModeMenu::handleMenuRepeat ()
	{
		setProperty ("ActionIcon", "media-playlist-repeat");
		emit playbackModeChanged (PlaybackModeRepeat);
	}