コード例 #1
0
ファイル: player.cpp プロジェクト: jck/MellowPlayer
//---------------------------------------------------------
void PlayerInterface::checkSongChange(SongInfo &song)
{
    if(song.songName != m_currentSong.songName)
    {
        qDebug() << "Song changed: " << song.songName;
        emit songChanged(song);
        m_currentSong = song;

        if(song.isValid())
            downloadSongArt(song.artUrl);

        if(playbackStatus() == Playing && song.isValid())
        {
            m_startedSong = song;
            emit songStarted(song);
        }
        else
            m_startedSong = SongInfo(); // invalid song
    }
    else if(song.isValid() && !m_startedSong.isValid() && playbackStatus() == Playing)
    {
        // sometimes (depends on the player) a new song is active but not playing,
        // we only emit song started when a song is valid and the player is playing.s
        m_startedSong = song;
        emit songStarted(song);
    }
}
コード例 #2
0
TitlePlayDialog::TitlePlayDialog(QWidget *parent, AudioPlayerBridge *apb, API *api, Song *song) :
    QDialog(parent),
    ui(new Ui::TitlePlayDialog)
{
    this->setAttribute(Qt::WA_QuitOnClose, false);
    this->setAttribute(Qt::WA_DeleteOnClose);
    posChanging = false;
    posTimer = new QTimer(this);
    posTimer->setInterval(200);
    posTimer->setSingleShot(false);
    connect(posTimer, SIGNAL(timeout()), this , SLOT(timerTick()));
    posTimer->start();
    this->apb = new AudioPlayerBridge(this, false);
    this->apb->setVolume(apb->getVolume());
    this->api = api;
    this->song = song;
    ui->setupUi(this);
    this->setWindowFlags(this->windowFlags() & ~(Qt::WindowFullscreenButtonHint));
    QRect geometry = QApplication::desktop()->screenGeometry();
    this->setGeometry((geometry.width() - this->width()) / 2, (geometry.height() - this->height()) / 2, this->width(), this->height());
    this->setFixedSize(this->size());
    this->setWindowTitle(QString::fromStdString(song->getSongName() + " - " + song->getArtistName()));
    ui->lblSong->setText(QString::fromStdString(song->getSongName() + " - " + song->getArtistName()));
    ui->sldVolume->setValue(this->apb->getVolume());
    ui->sldVolume->setStyle(new MyVolumeStyle);
    ui->sldPosition->setStyle(new MyVolumeStyle);
    connect(api, SIGNAL(streamKeyReady(StreamInformation*)), this, SLOT(gotSongInformation(StreamInformation*)));
    connect(this->apb, SIGNAL(startedPlaying()), this, SLOT(songStarted()));
    connect(this->apb, SIGNAL(songFinished()), this, SLOT(songFinished()));
    connect(api, SIGNAL(songError(int)), this, SLOT(songFailed(int)));
    play();
}