예제 #1
0
void TimelineDock::onVisibilityChanged(bool visible)
{
    if (visible) {
        QDir sourcePath = QmlUtilities::qmlDir();
        sourcePath.cd("timeline");
        m_quickView.setSource(QUrl::fromLocalFile(sourcePath.filePath("timeline.qml")));
        disconnect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool)));
        connect(m_quickView.rootObject(), SIGNAL(currentTrackChanged()),
                this, SIGNAL(currentTrackChanged()));
        connect(m_quickView.rootObject(), SIGNAL(selectionChanged()),
                this, SIGNAL(selectionChanged()));
        connect(m_quickView.rootObject(), SIGNAL(selectionChanged()),
                this, SLOT(emitClipSelectedFromSelection()));
        connect(m_quickView.rootObject(), SIGNAL(clipClicked()),
                this, SIGNAL(clipClicked()));
    }
}
InfoWidget::Implementation::Implementation(Jerboa::PlayerInterface* player, QWidget* parent) :
	QWidget(parent),
	m_coverArtPath(Jerboa::Utilities::dataLocation() + "/coverImages"),
	m_lyricsPath(Jerboa::Utilities::dataLocation() + "/lyrics"),
	m_awsKey("1JRV0F20598Z9ZAPF7R2"), // Please don't copy this to other programs; these keys are free from aws.amazon.com
	m_coverArtDownloader(new QNetworkAccessManager(this)),
	m_lyricsDownloader(new QNetworkAccessManager(this))
{
	// Connect the player
	connect(
		player,
		SIGNAL(currentTrackChanged(Jerboa::TrackData)),
		this,
		SLOT(showTrackInformation(Jerboa::TrackData))
	);

	// Make sure the directories exist
	QDir dir;
	dir.mkpath(m_coverArtPath);
	dir.mkpath(m_lyricsPath);

	// Connect the downloader
	connect(m_lyricsDownloader, SIGNAL(finished(QNetworkReply*)), this, SLOT(gotLyrics(QNetworkReply*)));

	// Setup UI
	ui.setupUi(this);
	const int coverArtLength = 160 + (2 * ui.coverArtLabel->frameWidth());
	ui.coverArtLabel->setMaximumSize(coverArtLength, coverArtLength);
	ui.coverArtLabel->setMinimumSize(coverArtLength, coverArtLength);

	connect(
		ui.coverArtLabel, SIGNAL(customContextMenuRequested(const QPoint&)),
		this, SLOT(coverArtContextMenu(const QPoint&))
	);

	ui.creditsLabel->setText(tr("Cover art from <a href='http://%1'>%1</a>, lyrics from <a href='http://%2.org'>%2</a>.").arg("Amazon.com").arg("LyricWiki"));

	clear();

	m_coverArtMenu = new QMenu(this);
	QAction* a;
	a = new QAction(
		QApplication::style()->standardIcon(QStyle::SP_BrowserReload),
		tr("Refetch"),
		this
	);
	connect(a, SIGNAL(triggered()), this, SLOT(refetchCoverArt()));
	m_coverArtMenu->addAction(a);
	a = new QAction(
		QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon),
		tr("Choose file.."),
		this
	);
	connect(a, SIGNAL(triggered()), this, SLOT(chooseCoverArt()));
	m_coverArtMenu->addAction(a);
}
예제 #3
0
void QSpotifySession::play(std::shared_ptr<QSpotifyTrack> track, bool restart)
{
    qDebug() << "QSpotifySession::play";
    if (track->error() != QSpotifyTrack::Ok || !track->isAvailable() || (m_currentTrack == track && !restart))
        return;

    if (m_currentTrack) {
        if (m_trackChangedAutomatically) {
            // We're done decoding the track, but we might not be done playing it
            m_previousTrackRemaining = m_currentTrack->duration() - m_currentTrackPosition;
        } else {
            m_previousTrackRemaining = 0;
        }
        sp_session_player_unload(m_sp_session);
        m_isPlaying = false;
        m_currentTrack.reset();
        m_currentTrackPosition = 0;
        m_currentTrackPlayedDuration = 0;
        // Only discard buffers if the track change was initialized manually
        // since we will otherwise potentially discard the end of the just played track
        if (!m_trackChangedAutomatically) {
            QCoreApplication::postEvent(g_audioWorker, new QEvent(QEvent::Type(ResetBufferEventType)));
        }
    } else {
        m_previousTrackRemaining = 0;
    }

    m_trackChangedAutomatically = false;

    if (!track->seen())
        track->setSeen(true);

    sp_error error = sp_session_player_load(m_sp_session, track->m_sp_track);
    if (error != SP_ERROR_OK) {
        fprintf(stderr, "failed to load track: %s\n",
                sp_error_message(error));
        return;
    }
    m_currentTrack = track;
    m_currentTrackPosition = 0;
    m_currentTrackPlayedDuration = 0;
    emit currentTrackChanged();
    emit currentTrackPositionChanged();

    beginPlayBack();
}
예제 #4
0
void PlaylistModel::setCurrentTrack(int track, PlayerReaction reaction)
{
    if (track > (m_tracks.count() - 1))
    {
        track = 0;
    }

    m_currentTrack = track;

    if (m_currentTrack == -1 && m_playbackMode == SequentialMode)
    {
        reaction = StopReaction;
        m_currentTrack = 0;
    }

    emit currentTrackChanged(m_currentTrack, reaction);
    emit modified();
    emit layoutChanged();
}
예제 #5
0
void QSpotifySession::stop(bool dontEmitSignals)
{
    qDebug() << "QSpotifySession::stop";
    if (!m_isPlaying && !m_currentTrack)
        return;

    sp_session_player_unload(m_sp_session);
    m_isPlaying = false;
    m_currentTrack.reset();
    m_currentTrackPosition = 0;
    m_currentTrackPlayedDuration = 0;

    if (!dontEmitSignals) {
        emit isPlayingChanged();
        emit currentTrackChanged();
        emit currentTrackPositionChanged();
    }

    QCoreApplication::postEvent(g_audioWorker, new QEvent(QEvent::Type(AudioStopEventType)));
}