예제 #1
0
void PlaylistModel::processedTracks(const KUrl::List &tracks, int position, PlayerReaction reaction)
{
    for (int i = (tracks.count() - 1); i >= 0; --i)
    {
        m_tracks.insert(position, tracks.at(i));
    }

    if (reaction == PlayReaction)
    {
        setCurrentTrack(position, reaction);
    }
    else if (position <= m_currentTrack)
    {
        if (m_tracks.count() == tracks.count())
        {
            setCurrentTrack(0, reaction);
        }
        else
        {
            setCurrentTrack(qMin((m_currentTrack + tracks.count()), (m_tracks.count() - 1)), reaction);
        }
    }

    MetaDataManager::resolveTracks(tracks);

    emit tracksChanged();
    emit modified();
}
예제 #2
0
void PlaylistModel::previous(PlayerReaction reaction)
{
    if (m_tracks.count() < 2)
    {
        setCurrentTrack(0, reaction);
    }
    else if (m_playbackMode == RandomMode)
    {
        setCurrentTrack(randomTrack(), reaction);
    }
    else
    {
        setCurrentTrack(((m_currentTrack == 0)?(m_tracks.count() - 1):(m_currentTrack - 1)), reaction);
    }
}
예제 #3
0
void PlaylistModel::next(PlayerReaction reaction)
{
    if (m_tracks.count() < 2)
    {
        setCurrentTrack(0, reaction);
    }
    else if (m_playbackMode == RandomMode)
    {
        setCurrentTrack(randomTrack(), reaction);
    }
    else
    {
        setCurrentTrack(((m_currentTrack >= (m_tracks.count() - 1))?0:(m_currentTrack + 1)), reaction);
    }
}
예제 #4
0
void PlaylistModel::sort(int column, Qt::SortOrder order)
{
    if (m_tracks.count() < 2)
    {
        return;
    }

    QMultiMap<QString, KUrl> keyMap;
    QMultiMap<qint64, KUrl> durationMap;
    KUrl::List tracks;
    const KUrl url = m_tracks.value(m_currentTrack);

    if (column == DurationColumn)
    {
        for (int i = 0; i < m_tracks.count(); ++i)
        {
            durationMap.insert(MetaDataManager::duration(m_tracks.at(i)), m_tracks.at(i));
        }

        tracks = durationMap.values();
    }
    else if (column > FileNameColumn && column < DurationColumn)
    {
        const MetaDataKey key = translateColumn(column);

        for (int i = 0; i < m_tracks.count(); ++i)
        {
            keyMap.insert(MetaDataManager::metaData(m_tracks.at(i), key), m_tracks.at(i));
        }

        tracks = keyMap.values();
    }
    else
    {
        for (int i = 0; i < m_tracks.count(); ++i)
        {
            keyMap.insert(m_tracks.at(i).pathOrUrl(), m_tracks.at(i));
        }

        tracks = keyMap.values();
    }

    if (order == Qt::AscendingOrder)
    {
        KUrl::List items;

        for (int i = (tracks.count() - 1); i >= 0; --i)
        {
            items.append(tracks.at(i));
        }

        tracks = items;
    }

    m_tracks = tracks;

    setCurrentTrack(findTrack(url));

    emit tracksChanged();
}
예제 #5
0
void TimelineDock::trimClipAtPlayhead(TrimLocation location, bool ripple)
{
    int trackIndex = currentTrack(), clipIndex = -1;
    chooseClipAtPosition(m_position, trackIndex, clipIndex);
    if (trackIndex < 0 || clipIndex < 0)
        return;
    setCurrentTrack(trackIndex);

    int i = m_model.trackList().at(trackIndex).mlt_index;
    QScopedPointer<Mlt::Producer> track(m_model.tractor()->track(i));
    if (!track)
        return;

    QScopedPointer<Mlt::ClipInfo> info(getClipInfo(trackIndex, clipIndex));
    if (!info)
        return;

    if (location == TrimInPoint) {
        MAIN.undoStack()->push(
            new Timeline::TrimClipInCommand(m_model, trackIndex, clipIndex, m_position - info->start, ripple));
        if (ripple)
            setPosition(info->start);
        if (m_updateCommand && m_updateCommand->trackIndex() == trackIndex && m_updateCommand->clipIndex() == clipIndex)
            m_updateCommand->setPosition(trackIndex, clipIndex, m_updateCommand->position() + m_position - info->start);
    } else {
        MAIN.undoStack()->push(
            new Timeline::TrimClipOutCommand(m_model, trackIndex, clipIndex, info->start + info->frame_count - m_position, ripple));
        if (m_updateCommand && m_updateCommand->trackIndex() == trackIndex && m_updateCommand->clipIndex() == clipIndex)
            m_updateCommand->setPosition(trackIndex, clipIndex,-1);
    }
}
예제 #6
0
void TimelineDock::selectTrack(int by)
{
    int newTrack = currentTrack();
    if (by < 0)
        newTrack = qMax(0, newTrack + by);
    else
        newTrack = qMin(m_model.trackList().size() - 1, newTrack + by);
    setCurrentTrack(newTrack);
}
예제 #7
0
void TimelineDock::removeTrack()
{
    if (m_model.trackList().size() > 0) {
        int trackIndex = currentTrack();
        MAIN.undoStack()->push(
                new Timeline::RemoveTrackCommand(m_model, trackIndex));
        if (trackIndex >= m_model.trackList().count())
            setCurrentTrack(m_model.trackList().count() - 1);
    }
}
예제 #8
0
void PlaylistModel::removeTrack(int position)
{
    if (position < 0 || position >= m_tracks.count())
    {
        return;
    }

    m_manager->removeTracks(KUrl::List(m_tracks.at(position)));

    m_tracks.removeAt(position);

    if (position <= m_currentTrack)
    {
        setCurrentTrack((m_currentTrack - 1), ((position == m_currentTrack && (m_manager->state() != StoppedState && isCurrent()))?StopReaction:NoReaction));
    }
    else
    {
        setCurrentTrack(m_currentTrack);
    }

    emit trackRemoved(position);
    emit modified();
}
예제 #9
0
	void PlayerInterface::skipTo(int playlistIndex)
	{
		if(playlistIndex != -1)
		{
			const TrackData track = d->m_playlist->tracks().at(playlistIndex);
			setCurrentTrack(track);
			d->m_playlist->setCurrentTrack(playlistIndex);
		}
		else
		{
			stop();
			d->m_playlist->setCurrentTrack(-1);
		}
	}
예제 #10
0
void PlaylistModel::shuffle()
{
    if (m_tracks.count() < 2)
    {
        return;
    }

    const KUrl url = m_tracks.value(m_currentTrack);

    KRandomSequence().randomize(m_tracks);

    setCurrentTrack(findTrack(url));

    emit tracksChanged();
    emit modified();
}
void MediaPlayerPrivateAVFoundation::configureInbandTracks()
{
    RefPtr<InbandTextTrackPrivateAVF> trackToEnable;

    // AVFoundation can only emit cues for one track at a time, so enable the first track that is showing, or the first that
    // is hidden if none are showing. Otherwise disable all tracks.
    for (unsigned i = 0; i < m_textTracks.size(); ++i) {
        RefPtr<InbandTextTrackPrivateAVF> track = m_textTracks[i];
        if (track->mode() == InbandTextTrackPrivate::Showing) {
            trackToEnable = track;
            break;
        }
        if (track->mode() == InbandTextTrackPrivate::Hidden)
            trackToEnable = track;
    }

    setCurrentTrack(trackToEnable.get());
}
예제 #12
0
void TimelineDock::selectClipUnderPlayhead()
{
    int track = -1, clip = -1;
    chooseClipAtPosition(m_position, &track, &clip);
    if (clip == -1) {
        if (isTrackLocked(currentTrack())) {
            pulseLockButtonOnTrack(currentTrack());
            return;
        }
        int idx = clipIndexAtPlayhead(-1);
        if (idx == -1)
            setSelection(QList<int>());
        else
            setSelection(QList<int>() << idx);
        return;
    }

    setCurrentTrack(track);
    setSelection(QList<int>() << clip);
}
예제 #13
0
void TimelineDock::splitClip(int trackIndex, int clipIndex)
{
    if (trackIndex < 0 || clipIndex < 0)
        chooseClipAtPosition(m_position, &trackIndex, &clipIndex);
    if (trackIndex < 0 || clipIndex < 0)
        return;
    setCurrentTrack(trackIndex);
    if (clipIndex >= 0 && trackIndex >= 0) {
        int i = m_model.trackList().at(trackIndex).mlt_index;
        QScopedPointer<Mlt::Producer> track(m_model.tractor()->track(i));
        if (track) {
            Mlt::Playlist playlist(*track);
            if (!m_model.isTransition(playlist, clipIndex)) {
                QScopedPointer<Mlt::ClipInfo> info(getClipInfo(trackIndex, clipIndex));
                if (info && m_position >= info->start && m_position < info->start + info->frame_count - 1) {
                    MAIN.undoStack()->push(
                        new Timeline::SplitCommand(m_model, trackIndex, clipIndex, m_position));
                }
            } else {
                MAIN.showStatusMessage(tr("You cannot split a transition."));
            }
        }
    }
}