Browse Source

Z991239-4806 #comment 本地媒体播放代码同步

80274480 2 năm trước cách đây
mục cha
commit
e6d87a4c67

+ 28 - 0
Module/mod_localmediaplay/mod_localmediaplay.cpp

@@ -2369,7 +2369,11 @@ ErrorCodeEnum CLocalMediaPlayEntity::StartFFPlayerNotice(int nCfgInx, int nWndX,
 		if (0 != m_uMediaPlayThreadId) {
 			m_pMediaAudioPlayer->Close();
 			m_uMediaPlayThreadId = 0;
+#ifdef RVC_OS_WIN
 			Sleep(500);
+#else
+			usleep(500*1000);
+#endif // RVC_OS_WI
 		}
 	}
 
@@ -2378,7 +2382,11 @@ ErrorCodeEnum CLocalMediaPlayEntity::StartFFPlayerNotice(int nCfgInx, int nWndX,
 		if (NULL != m_uNoticePlayThreadId) {
 			m_pMediaPlayer[nCfgInx]->Close();
 			m_uNoticePlayThreadId = 0;
+#ifdef RVC_OS_WIN
 			Sleep(500);
+#else
+			usleep(500 * 1000);
+#endif // RVC_OS_WI
 		}
 	}
 
@@ -2427,14 +2435,22 @@ ErrorCodeEnum CLocalMediaPlayEntity::StartFFPlayerNotice(int nCfgInx, int nWndX,
 			else{
 				Error = Error_InvalidState;
 				char strerrmsg[MAX_PATH] = { 0 };
+#ifdef RVC_OS_WIN
 				_snprintf(strerrmsg, MAX_PATH, "play notice failed for %s is not valid!", strNoticeFileName.GetData());
+#else
+				snprintf(strerrmsg, MAX_PATH, "play notice failed for %s is not valid!", strNoticeFileName.GetData());
+#endif // RVC_OS_WIN
 				LogWarn(Severity_Low, Error_Debug, LOG_EVT_NOTICE_FILE_NOT_VALID, strerrmsg);
 			}
 		}
 		else {
 			Error = Error_InvalidState;
 			char strmsg[MAX_PATH] = { 0 };
+#ifdef RVC_OS_WIN
 			_snprintf(strmsg, MAX_PATH, "play notice failed for %s not exist!", strNoticeFileName.GetData());
+#else
+			snprintf(strmsg, MAX_PATH, "play notice failed for %s not exist!", strNoticeFileName.GetData());
+#endif
 			LogWarn(Severity_Low, Error_Debug, LOG_EVT_NOTICE_FILE_NOT_EXIST, strmsg);
 		}
 	}
@@ -2501,7 +2517,19 @@ ErrorCodeEnum CLocalMediaPlayEntity::StopNotice(int nCfgInx)
 			}
 		}
 #else
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_pPlayer = 0x%08x while play!", m_pMediaPlayer[nCfgInx]);
+		m_pMediaPlayer[nCfgInx]->Close();
 
+		if (m_uNoticePlayThreadId > 0) {
+			if (0 == pthread_join(m_uNoticePlayThreadId, NULL)) {
+				if (m_lastPlayVideo.length() > 0) {
+					char strmsg[MAX_PATH] = { 0 };
+					snprintf(strmsg, MAX_PATH, "%s%s", "success to stop play notice ", m_lastPlayVideo.c_str());
+					LogWarn(Severity_Low, Error_Debug, LOG_EVT_STOP_NOTICE_PLAY, strmsg);
+				}
+			}
+			m_uNoticePlayThreadId = 0;
+		}
 #endif
 	}
 

+ 6 - 7
Other/libmediaplayer/libmediaplayer.cpp

@@ -501,8 +501,6 @@ CMediaHostApi* libmediaplayer_impl::GetHostApi()
 	return m_pHostApi; 
 }
 
-
-
 Clibmediaplayer::Clibmediaplayer(CMediaHostApi* pHostApi)
 {
 	m_pImpl = new libmediaplayer_impl(pHostApi);
@@ -515,10 +513,6 @@ Clibmediaplayer::~Clibmediaplayer()
 	m_pImpl = NULL;
 }
 
-
-
-
-
 int Clibmediaplayer::PlayVideo(const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
 {
 	return m_pImpl->StartPlayVideo(pVideoDir, pNamePrefix, nVideoCount);
@@ -570,9 +564,14 @@ void Clibmediaplayer::PlayVideoNotice(int nWndX, int nWndY, int nWndWidth, int n
 	m_pImpl->StartPlayVideoNotice(nWndX, nWndY, nWndWidth, nWndHeight, pFileName);
 }
 
+
+bool Clibmediaplayer::IsFileValid(const char* pVideoName)
+{
+	return m_pImpl->IsFileValid(pVideoName);
+}
+
 int mediaplayer_init()
 {
-	//avcodec_register_all();
 	return 0;
 }