zonyitoo / doubanfm-qt

A DoubanFM client
Other
511 stars 99 forks source link

暂停时或继续播放时有滋滋声 #16

Closed coiby closed 9 years ago

coiby commented 10 years ago

点击暂停或继续时,音箱会冒出大概1~2秒的滋滋声噪音。

zonyitoo commented 10 years ago

这是Ubuntu下的Bug,其它系统都没有的,未知如何解决。

可能升级一下pulseaudio能解

zonyitoo commented 10 years ago

临时解决办法,在libs/doubanplayer.cpp中按如下修改

void DoubanPlayer::play() {
/*
    QPropertyAnimation *fadein = new QPropertyAnimation(&player, "volume");
    fadein->setDuration(1000);
    fadein->setStartValue(player.volume());
*/
    player.play();
/*
    fadein->setEndValue(_volume);
    fadein->start(QPropertyAnimation::DeleteWhenStopped);
*/
    emit playing();

    int elapsed = time(nullptr) - this->lastPausedTime;
    if (elapsed >= 30 * 60) {
        doubanfm.getPlayingList(_channel, this->currentSong().sid, _kbps);
        QTime pt(0, 0, 0, 0);
        pt.addSecs(elapsed);
        this->setCanControl(false);
        qDebug() << "Have paused " << pt <<  ", getting a new playlist";
    }
}

void DoubanPlayer::pause() {
    emit paused();
    this->lastPausedTime = time(nullptr);
/*
    QPropertyAnimation *fadeout = new QPropertyAnimation(&player, "volume");
    fadeout->setDuration(1000);
    fadeout->setStartValue(player.volume());
    _volume = player.volume();
    fadeout->setEndValue(0);
    connect(fadeout, &QPropertyAnimation::finished, [this] () {
        player.pause();
    });
    fadeout->start(QPropertyAnimation::DeleteWhenStopped);
*/
    player.pause(); // 加上这句
}
coiby commented 10 years ago

试过有效,谢谢!