fix(player): play current track on dbus play after restart#695
Conversation
After restart the restored track has a Stopped backend state, so playRequested skipped to playNextMeta. Guard with a localPath and hash check to play the current track. 重启后恢复的当前曲目后端为 Stopped 状态,playRequested 误调 playNextMeta 跳到下一首。增加 localPath 与 hash 校验,播放当前曲目。 Log: 修复重启后dbus播放跳到下一首的问题 PMS: BUG-367253 Influence: 重启后dbus触发播放时播放当前恢复曲目而非下一首。
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前修复代码已足够完善,无需额外修改,此处展示当前最佳实践
void PlayerEngine::setMprisPlayer(const QString &serviceName, const QString &des)
{
// ... 前置逻辑 ...
} else {
if (playbackStatus() != DmGlobal::Playing) {
// After restart setMediaMeta restores the current track while the
// backend state stays Stopped; play the current track instead of the next
if (!getMediaMeta().localPath.isEmpty() && !getMediaMeta().hash.isEmpty()) {
play();
} else {
// Empty playlist must also be handled, otherwise dbus calls are no-ops
playNextMeta(false);
}
} else {
pauseNow();
}
}
// ... 后置逻辑 ...
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, wyu71 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
After restart the restored track has a Stopped backend state, so playRequested skipped to playNextMeta. Guard with a localPath and hash check to play the current track.
重启后恢复的当前曲目后端为 Stopped 状态,playRequested 误调 playNextMeta 跳到下一首。增加 localPath 与 hash 校验,播放当前曲目。
Log: 修复重启后dbus播放跳到下一首的问题
PMS: BUG-367253
Influence: 重启后dbus触发播放时播放当前恢复曲目而非下一首。