Commits

Tomasen  committed 85253ee

ads no more then 5 sec for each

  • Participants
  • Parent commits aadb727

Comments (0)

Files changed (3)

File src/apps/mplayerc/Controller/AdController.cc

 , m_nCurAd(-1)
 , m_nCurX(0)
 , m_nCurY(0)
+, m_lastAdTime(0)
 , m_bTryNextLoopWhenFail(false)
 {
   m_szCurAd.SetSize(0, 0);
 // operations
 void AdController::SetVisible(bool bVisible)
 {
+  if (bVisible && m_bVisible != bVisible)
+    m_lastAdTime = time(NULL);
   m_bVisible = bVisible;
 }
 
 
   m_nCurX = m_rc.left;
   m_nCurY = m_rc.top;
+
 }
 
 bool AdController::IsCurAdShownDone()
   if ((m_nCurAd < 0) || (m_nCurAd > m_vtAds.size() - 1))
     return true;
 
+  if ((time(NULL) - m_lastAdTime) > 5)
+    return true;
+
   if (m_nCurX + m_szCurAd.cx <= m_rc.right)
     return true;
   else

File src/apps/mplayerc/Controller/AdController.h

   bool m_bAllowAnimate;
 
   bool m_bTryNextLoopWhenFail;       // should try next loop when download ad failure?
+  time_t m_lastAdTime;
 };

File src/apps/mplayerc/PlayerToolBar.cpp

       {
         // If no ads exists, then didn't show ads, otherwise show ads
         if (m_adctrl.IsAdsEmpty())
-        {
           break;
-        }
 
         m_adctrl.AllowAnimate(true);
-
         Invalidate();
         break;
       }
     case TIMER_ADPLAYSWITCH:
       {
-        // If no ads exists, then didn't show ads, otherwise show ads
+        // If no ads exists, then don't show ads
         if (m_adctrl.IsAdsEmpty())
         {
+          m_adctrl.SetVisible(false);
           break;
         }
         KillTimer(TIMER_ADPLAYSWITCH);
+        // otherwise show ads
         // 查看广告是否显示完,如果还在显示则等待下一次2秒
         if (m_btnplaytime->GetString().IsEmpty() && m_adctrl.IsCurAdShownDone())
         {