libpictureplayer.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #include "libpictureplayer.h"
  2. #include "CPicturePlayer.h"
  3. #include "SpBase.h"
  4. void __dbg(const char* fmt, ...)
  5. {
  6. Dbg(fmt);
  7. }
  8. class libpictureplayer_impl
  9. {
  10. private:
  11. CPicPlayConfig m_stPlayConfig;
  12. CPicHostApi* m_pHostApi;
  13. CPicturePlayer* m_Player;
  14. bool m_bIsPlay;
  15. public:
  16. libpictureplayer_impl(CPicHostApi* pHostApi) {
  17. m_bIsPlay = false;
  18. m_pHostApi = pHostApi;
  19. memset(&m_stPlayConfig, 0, sizeof(m_stPlayConfig));
  20. m_Player = new CPicturePlayer();
  21. if (NULL != m_Player) {
  22. pHostApi->PicDebug(" new PicturePlayer success!");
  23. }
  24. else {
  25. pHostApi->PicDebug(" new PicturePlayer failed!");
  26. }
  27. }
  28. ~libpictureplayer_impl()
  29. {
  30. m_pHostApi = NULL;
  31. delete m_Player;
  32. m_Player = NULL;
  33. m_bIsPlay = false;
  34. }
  35. bool isStop()
  36. {
  37. return !m_bIsPlay;
  38. }
  39. bool CheckIsPlay(void* pthreadid)
  40. {
  41. bool bret = false;
  42. int64_t iThreadId = m_Player->GetPicPlayingThreadId();
  43. if (0 != iThreadId)
  44. {
  45. bret = true;
  46. pthreadid = &iThreadId;
  47. }
  48. }
  49. bool StartPlayMedia(CPicPlayConfig& config)
  50. {
  51. if (m_bIsPlay)
  52. {
  53. return true;
  54. }
  55. memcpy(&m_stPlayConfig, &config, sizeof(CPicPlayConfig));
  56. rvc_picture_player_param_t tplayer_param;
  57. tplayer_param.icx = m_stPlayConfig.nWndX;
  58. tplayer_param.icy = m_stPlayConfig.nWndY;
  59. tplayer_param.uwindow_width = m_stPlayConfig.nWndWidth;
  60. tplayer_param.uwindow_height = m_stPlayConfig.nWndHeight;
  61. tplayer_param.stricon_path = "D:/run/version/0.0.2.0/bin/rvc_media_player_64px.bmp";
  62. tplayer_param.rvc_log = __dbg;
  63. if (0 == m_Player->Init(&tplayer_param))
  64. {
  65. m_pHostApi->PicDebug("Init Picture Player Success.");
  66. if (m_Player->StartPicPlay())
  67. {
  68. m_bIsPlay = true;
  69. m_pHostApi->PicDebug("Start Picture Play Success.");
  70. }
  71. }
  72. return true;
  73. }
  74. bool StartPlay(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
  75. {
  76. m_stPlayConfig.nWndX = nWndX;
  77. m_stPlayConfig.nWndY = nWndY;
  78. m_stPlayConfig.nWndWidth = nWndWidth;
  79. m_stPlayConfig.nWndHeight = nWndHeight;
  80. int iRet = m_pHostApi->LoadPlayConfig(m_stPlayConfig, nCfgInx);
  81. if (0 != iRet)
  82. {
  83. m_pHostApi->PicDebug("Load ImgConfiguration failed!");
  84. return false;
  85. }
  86. else
  87. {
  88. m_pHostApi->PicDebug("Load ImgConfiguration succeeded while play local image!");
  89. m_pHostApi->PicDebug("m_stPlayConfig.strRootPath: %s", m_stPlayConfig.strRootPath);
  90. }
  91. rvc_picture_player_param_t tplayer_param;
  92. tplayer_param.icx = nWndX;
  93. tplayer_param.icy = nWndY;
  94. tplayer_param.uwindow_width = nWndWidth;
  95. tplayer_param.uwindow_height = nWndHeight;
  96. tplayer_param.stricon_path = "D:/run/version/0.0.2.0/bin/rvc_media_player_64px.bmp";
  97. tplayer_param.rvc_log = __dbg;
  98. if (0 == m_Player->Init(&tplayer_param))
  99. {
  100. m_pHostApi->PicDebug("Init Picture Player Success.");
  101. if (m_Player->StartPicPlay())
  102. {
  103. m_bIsPlay = true;
  104. m_pHostApi->PicDebug("Start Picture Play Success.");
  105. }
  106. }
  107. return true;
  108. }
  109. bool StopPlay()
  110. {
  111. if (NULL != m_Player)
  112. {
  113. if (m_Player->GetPicPlayingFlag())
  114. {
  115. m_Player->StopPicPlay();
  116. m_bIsPlay = false;
  117. }
  118. }
  119. return true;
  120. }
  121. };
  122. Clibpictureplayer::Clibpictureplayer(CPicHostApi* pHostApi)
  123. {
  124. m_pImpl = new libpictureplayer_impl(pHostApi);
  125. }
  126. Clibpictureplayer::~Clibpictureplayer()
  127. {
  128. delete m_pImpl;
  129. m_pImpl = NULL;
  130. }
  131. void Clibpictureplayer::Play(int nCfgInx, int nWndX, int nWndY, int nWndWidth, int nWndHeight)
  132. {
  133. m_pImpl->StartPlay(nCfgInx, nWndX, nWndY, nWndWidth, nWndHeight);
  134. }
  135. void Clibpictureplayer::PlayMedia(CPicPlayConfig& config)
  136. {
  137. m_pImpl->StartPlayMedia(config);
  138. }
  139. bool Clibpictureplayer::checkIsStop() {
  140. return m_pImpl->isStop();
  141. }
  142. bool Clibpictureplayer::checkIsPlay(void* pthreadid)
  143. {
  144. return m_pImpl->CheckIsPlay(pthreadid);
  145. }
  146. void Clibpictureplayer::Close()
  147. {
  148. m_pImpl->StopPlay();
  149. }