|
|
@@ -306,7 +306,19 @@ QString PlayerController::playingFile() const
|
|
|
|
|
|
bool PlayerController::isPlaying() const
|
|
|
{
|
|
|
- return m_state == PlayerState::Playing;
|
|
|
+ // 不仅检查状态标志,还检查线程是否实际运行
|
|
|
+ if (m_state != PlayerState::Playing) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果状态是Playing但所有线程都已停止,则实际上不是在播放状态
|
|
|
+ if (areAllThreadsStopped()) {
|
|
|
+ qCDebug(playerControllerLog) << "[isPlaying] State is Playing but all threads stopped";
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
bool PlayerController::playingHasVideo()
|
|
|
@@ -354,6 +366,17 @@ void PlayerController::playStarted(bool success)
|
|
|
|
|
|
void PlayerController::playFailed(const QString& file)
|
|
|
{
|
|
|
+ qCWarning(playerControllerLog) << "Playback failed for file:" << toNativePath(file);
|
|
|
+
|
|
|
+ // 确保状态一致性
|
|
|
+ if (m_state != PlayerState::Idle) {
|
|
|
+ // 检查线程状态并重置
|
|
|
+ if (!areAllThreadsStopped()) {
|
|
|
+ qCDebug(playerControllerLog) << "Some threads still running, stopping them first";
|
|
|
+ stopAndResetThreads();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
emit showMessage(QString("Playback failed: %1").arg(toNativePath(file)), "Warning", "");
|
|
|
}
|
|
|
|
|
|
@@ -363,30 +386,34 @@ void PlayerController::readPacketStopped()
|
|
|
qCDebug(playerControllerLog) << "************* Read packets thread stopped signal received.";
|
|
|
//m_packetReadThread.reset();
|
|
|
|
|
|
- // stopPlay();
|
|
|
if (m_videoState) {
|
|
|
m_videoState->delete_video_state();
|
|
|
}
|
|
|
|
|
|
emit audioStopped();
|
|
|
}
|
|
|
+
|
|
|
void PlayerController::decodeVideoStopped()
|
|
|
{
|
|
|
qCDebug(playerControllerLog) << "************* Video decode thread stopped.";
|
|
|
}
|
|
|
+
|
|
|
void PlayerController::decodeAudioStopped()
|
|
|
{
|
|
|
qCDebug(playerControllerLog) << "************* Audio decode thread stopped.";
|
|
|
}
|
|
|
+
|
|
|
void PlayerController::decodeSubtitleStopped()
|
|
|
{
|
|
|
qCDebug(playerControllerLog) << "************* Subtitle decode thread stopped.";
|
|
|
}
|
|
|
+
|
|
|
void PlayerController::audioPlayStopped()
|
|
|
{
|
|
|
qCDebug(playerControllerLog) << "************* Audio play thread stopped.";
|
|
|
emit audioStopped();
|
|
|
}
|
|
|
+
|
|
|
void PlayerController::videoPlayStopped()
|
|
|
{
|
|
|
qCDebug(playerControllerLog) << "************* Video play thread stopped.";
|