-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
计时器在歌曲播放结束后未停止,播放进度条和时间标签交互不正常 #17
Comments
行,算是临时修改吧。 有个问题,这里不需要判断 如果这里不需要,其他地方对其的判断是多余吗? |
我写的时候也有稍微想到这一点,应该也算是比较懒,直接认为如果定时器已经停止,再调用一次不会做任何动作。 不过你这么一问我倒是仔细注意了这个问题,不知道对已经停止的定时器调用stop会是什么结果? |
另外有一个问题。运行 de490e3 版本,歌曲播放结束时会输出:
测试了下, 收到 audioFinish 信号后执行的匿名函数是在 PlayThread 线程中执行的,所以会有这个警告。尽管 m_positionUpdateTimer 的确是停止了,但这或许会有隐患? 不过换用 connect(playThread, SIGNAL(audioFinish(bool)), this, SLOT(theSlot(bool)));
void MusicPlayer::theSlot(bool isEndByForce) {
m_positionUpdateTimer.stop();
} |
我在网上找了,没看到相关的说法,可以猜测定时器会继续保持停止状态。 另外, |
这是一直存在的问题:
歌曲播放结束后, labelTimeCurrent 不归零, sliderSong 回到初始位置,拖动 sliderSong 会使在其初始位置和拖动位置之间闪动。
重现:
git checkout 354e203e63fb05764e4c7280cdc14fafd516fbe2
回到 #16 版本;播放一首歌曲(我使用的歌曲长度为 137012 ms ),当其播放结束,日志输出:
labelTimeCurrent 保持 02:17.012 , sliderSong 不断被设置到初始位置。
查看代码:
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/BottomWidgets/BottomWidget.cpp#L273-L286
注意到 sliderSong 在播放结束后被置为 0 (
musicPlayer->duration() == 0
成立), labelTimeCurrent 被置为 position (由showPosition(int)
处理)。查找调用:
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/StackFrame/MainWidget.cpp#L249-L253
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/StackFrame/MainWidget.cpp#L117
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/Entities/MusicPlayer/musicPlayer.cpp#L1004-L1008
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/Entities/MusicPlayer/musicPlayer.cpp#L796
这表明,在歌曲播放结束后 m_positionUpdateTimer 仍在工作,
BottomWidget::positionChanged(int position)
被反复调用。能找到停止 m_positionUpdateTimer 并发送 0 位置的代码:
https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/Entities/MusicPlayer/musicPlayer.cpp#L907-L917
但是目前
void MusicPlayer::stop()
方法只在制作歌词时被触发:https://github.com/Beslyric-for-X/Beslyric-for-X/blob/354e203e63fb05764e4c7280cdc14fafd516fbe2/StackFrame/MainWidget.cpp#L97-L98
注意,该 connect 写在了 MainWidget 类里。
修复本问题需要整理 PlayThread 和 MusicPlayer 等类的逻辑;
因为从用户体验来说这并不是致命的,所以不需要太优先。
The text was updated successfully, but these errors were encountered: