123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- #include "libmediaplayer.h"
- #include "SpBase.h"
- #include "player.h"
- void __dbg(const char* fmt, ...)
- {
- Dbg(fmt);
- }
- class libmediaplayer_impl
- {
- private:
- CMediaHostApi* m_pHostApi;
- CMediaPlayer* m_Player;
- public:
- libmediaplayer_impl(CMediaHostApi* pHostApi) {
- m_pHostApi = pHostApi;
- m_Player = new CMediaPlayer();
- }
- ~libmediaplayer_impl()
- {
- m_pHostApi = NULL;
- delete m_Player;
- m_Player = NULL;
- }
- bool isStop() { return false; }
- static void __cb_play_finished(void* user_data)
- {
- Dbg("callback play finished.");
- libmediaplayer_impl* pthis = static_cast<libmediaplayer_impl*>(user_data);
- if (NULL != pthis)
- {
- pthis->PlayMediaFinished();
- }
- }
- void StartPlayVideo(const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1)
- {
- LOG_FUNCTION();
- play_media_callback_t cb;
- cb.cb_play_media_finished = &__cb_play_finished;
- cb.user_data = this;
- rvc_media_player_param_t t_param;
- t_param.p_input_file = (char*)pNamePrefix;
- t_param.cb = &cb;
- t_param.picon_path = "D:/run/version/0.0.2.0/bin/rvc_media_player_64px.bmp";
- t_param.eType = eVideo_Type;
- t_param.playlog = __dbg;
- //player_start_play_media(&t_param);
- if (0 == m_Player->Init(&t_param))
- {
- m_Player->StartMediaPlay();
- }
- }
- void StartPlayLocalAudio(const char* pAudioNames)
- {
- LOG_FUNCTION();
- play_media_callback_t cb;
- cb.cb_play_media_finished = &__cb_play_finished;
- cb.user_data = this;
- rvc_media_player_param_t t_param;
- t_param.p_input_file = (char*)pAudioNames;
- t_param.cb = &cb;
- t_param.picon_path = "D:/run/version/0.0.2.0/bin/rvc_media_player_64px.bmp";
- t_param.eType = eVideo_Type;
- t_param.playlog = __dbg;
- //player_start_play_media(&t_param);
- if (0 == m_Player->Init(&t_param))
- {
- m_Player->StartMediaPlay();
- }
- }
- void StartPlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
- {
- }
- void Close()
- {
-
- }
- bool checkIsPlay(void* curThreadId)
- {
- bool bret = false;
- int64_t iThreadId = m_Player->GetMediaPlayingThreadId();
- if (0 != iThreadId)
- {
- bret = true;
- curThreadId = &iThreadId;
- }
- return bret;
- }
- bool checkIsStop()
- {
- return true;
- }
- //VOID PlayMedia(CWmpPlayConfig& config);
- bool StopPlay()
- {
- m_Player->StopMediaPlay();
- return true;
- }
- void SetVolume(int nVolume)
- {
- if (m_Player->GetPlayingFlag())
- {
- m_Player->SetVolume(nVolume);
- }
- }
- void StartPlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix = NULL, int nVideoCount = 1)
- {
- }
- void PlayMediaFinished()
- {
- m_pHostApi->Debug("PlayMediaFinished!");
- }
- };
- Clibmediaplayer::Clibmediaplayer(CMediaHostApi* pHostApi)
- {
- m_pImpl = new libmediaplayer_impl(pHostApi);
- return;
- }
- Clibmediaplayer::~Clibmediaplayer()
- {
- delete m_pImpl;
- m_pImpl = NULL;
- }
- void Clibmediaplayer::PlayVideo(const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
- {
- m_pImpl->StartPlayVideo(pVideoDir, pNamePrefix, nVideoCount);
- }
- void Clibmediaplayer::PlayLocalAudio(const char* pAudioNames)
- {
- m_pImpl->StartPlayLocalAudio(pAudioNames);
- }
- void Clibmediaplayer::PlayLocalVideo(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
- {
- m_pImpl->StartPlayLocalVideo(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
- }
- bool Clibmediaplayer::checkIsPlay(void* curThreadId)
- {
- return m_pImpl->checkIsPlay(curThreadId);
- }
- bool Clibmediaplayer::checkIsStop()
- {
- return m_pImpl->isStop();
- }
- VOID Clibmediaplayer::PlayMedia(CMediaPlayConfig& config)
- {
- //m_pImpl->StartPlayMedia(config);
- }
- void Clibmediaplayer::Close()
- {
- m_pImpl->StopPlay();
- }
- void Clibmediaplayer::SetVolume(int nVolume)
- {
- m_pImpl->SetVolume(nVolume);
- }
- void Clibmediaplayer::PlaySalesRecordVideo(int nWndX, int nWndY, int nWndWidth, int nWndHeight, const char* pVideoDir, const char* pNamePrefix, int nVideoCount)
- {
- m_pImpl->StartPlaySalesRecordVideo(nWndX, nWndY, nWndWidth, nWndHeight, pVideoDir, pNamePrefix, nVideoCount);
- }
|