chxavplayerstate.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:3k
源码类别:

Symbian

开发平台:

C/C++

  1. /************************************************************************
  2.  * chxavplayerstate.h
  3.  * ------------------
  4.  *
  5.  * Synopsis:
  6.  * CHXAvPlayerState is helper class for CHXAvPlayer. It maintains player 
  7.  * state info and dispatches event notifications to observers. Observers
  8.  * can use this to query for current player state info.
  9.  *
  10.  *
  11.  * Target:
  12.  * Symbian OS
  13.  *
  14.  *
  15.  * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
  16.  *
  17.  ************************************************************************/
  18. #ifndef CHXAVPLAYERSTATE_H__
  19. #define CHXAVPLAYERSTATE_H__
  20. #include "unkimp.h"
  21. #include "hxstring.h"
  22. #include "ihxpckts.h"
  23. #include "hxurl.h"
  24. #include "hxfiles.h"
  25. //#include "chxavcallback.h"
  26. #include "chxavplayerstatedispatch.h"
  27.   
  28. // class CHXAvPlayerState
  29. class CHXAvPlayerState
  30. {
  31. public:
  32.     // main player states
  33.     enum State
  34.     {
  35. Stopped,
  36.         Initiating,
  37. Connecting,
  38. Playing,
  39.         Seeking,
  40. Paused
  41.     };
  42.     // buffering sub-state applies while playing, seeking, paused
  43.     enum BufferState
  44.     {
  45.         NotBuffering,
  46.         BufferLoad,
  47.         BufferSeek,
  48.         BufferPlain
  49.     };
  50. public:
  51.     CHXAvPlayerState();
  52.     virtual ~CHXAvPlayerState();
  53.     void ConstructL();
  54. public:
  55.     State GetState() const;
  56.     BufferState GetBufferingState() const;
  57.     UINT16 GetLastBufferPercent() const;
  58.     void RemoveObserver(IHXSymPlayerStateObserver *observer);
  59.     void AddObserver(IHXSymPlayerStateObserver *observer);
  60. private:
  61.     friend class CHXAvPlayer;
  62.     // called by CHXAvPlayer
  63.     void OnPlayInitiate(const char *url); 
  64.     void OnNetConnect();
  65.     void OnLoadSession(IHXRequest *request); 
  66.     void OnResume();  
  67.     void OnStop();
  68.     void OnPause();
  69.     void OnBuffering(ULONG32 type, UINT16 percent);
  70.     void OnBeginSeek();
  71.     void OnNewPos(ULONG32 time);
  72.     void OnVolume(unsigned int percentVol);
  73.     void OnMute(bool bMute);
  74.     void OnError(HX_RESULT code);
  75.     void OnAdvancePlaylist();
  76. private:
  77.     // implementation
  78.     void ChangeState(State destState);
  79.     void ChangeBufferState(BufferState destState);
  80.     CHXAvPlayerStateDispatch* m_pDispatch;
  81.     State  m_state; 
  82.     BufferState m_bufferState;
  83.     UINT16 m_lastBufferPercent;
  84.     ULONG32 m_lastTime;
  85.     //CHXAvCallback m_cbConnectStateTransition;
  86. };
  87. inline
  88. CHXAvPlayerState::State CHXAvPlayerState::GetState() const { return m_state; }
  89. inline
  90. CHXAvPlayerState::BufferState CHXAvPlayerState::GetBufferingState() const { return m_bufferState; }
  91. inline
  92. UINT16 CHXAvPlayerState::GetLastBufferPercent() const { return m_lastBufferPercent; }
  93. #endif // CHXAVPLAYERSTATE_H__