chxavplayer.h
来自「symbian 下的helix player源代码」· C头文件 代码 · 共 376 行
H
376 行
/************************************************************************
* chxavplayer.h
* -------------
*
* Synopsis:
* CHXPlayer manages and directs an underlying HXPlayer player object. The
* underlying HXPlayer is hidden from the UI, which interacts with CHXPlayer
* only. CHXPlayer exposes and implements all playback control and query
* methods for the UI.
*
* Target:
* Symbian OS
*
*
* (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
*
*****************************************************************************/
#ifndef CHXAVPLAYER_H__
#define CHXAVPLAYER_H__
// includes
#include "unkimp.h"
#include "hxstring.h"
#include "hxausvc.h"
#include "hxerror.h"
#include "hxgroup.h"
#include "ihxaccesspoint.h"
#include "comptr.h"
#include "chxavnetconnectui.h"
#include "chxavplayerstate.h"
#include "chxavplaylist.h"
#include "chxavplayerui.h"
#include "chxavsitesupplier.h"
#include "chxavcallback.h"
#include "chxsymclipinfo.h"
#include "chxavaccesspointdb.h"
// forward declarations
class CHXAvNetConnectUI;
_INTERFACE IHXClientAdviseSink;
// class CHXAvPlayer
class CHXAvPlayer
: public CUnknownIMP
, public IHXClientAdviseSink
, public IHXErrorSink
, public IHXGroupSink
, public IHXAccessPointSelector
{
public:
friend class CHXAvSiteSupplier;
public:
DECLARE_UNKNOWN(CHXAvPlayer)
private:
HX_RESULT QueryInterfaceDelegates(REFIID riid, void** ppvObj);
public:
enum
{
kVolumeMin = 0,
kVolumeMax = 100
};
// ctor and dtor
CHXAvPlayer();
virtual ~CHXAvPlayer();
void ConstructL(const CHXClientEngineManagerPtr& spEngine,
const CHXAvNetConnectUIPtr& pAccessPointSelector);
// init and shutdown
void InitPlayerL(CCoeControl* pRenderWindow);
void ShutDown();
bool IsShutDown() const;
// play control
void Play(const char *url);
void Play(const TDesC& url);
void PlayCurrent();
void Stop();
void Pause();
void Resume();
// volume
void SetVolume(TUint level);
TUint GetVolume() const;
void StepVolume(TInt factor);
void Mute(bool bToMute);
bool IsMuted() const;
// time and duration
ULONG32 GetClipTime() const;
ULONG32 GetClipDuration() const;
// clip headers, bitrates, urls, server info, is live, is video pres, etc.
const CHXSymClipInfo& GetClipInfo() const;
// url
CHXString GetMainURL() const;
CHXString GetPlayURL() const;
// playlist
enum AdvanceFlag
{
advanceNext = 0x01,
advancePrev = 0x02,
advanceLoop = 0x04
};
bool IsPlaylistLoaded() const;
bool IsRemotePlayback() const;
bool HasPresLoaded() const;
bool HasPresStarted() const;
TInt GetPlaylistCurrentIndex() const;
TInt GetPlaylistItemCount() const;
void AdvancePlaylist(TUint flag);
// seek
void SetSeekPoint(ULONG32 time);
void StartSeek();
void EndSeek();
// draw
void RedrawPresentation();
// player state
CHXAvPlayerState& GetPlayerState();
bool IsPlaying() const;
bool IsBuffering() const;
bool IsPaused() const;
bool IsStopped() const;
bool IsSeeking() const;
bool IsConnecting() const;
bool IsInitiating() const;
bool CanSeek() const;
bool CanPause() const;
bool CanResume() const;
private:
// IHXClientAdviseSink
STDMETHOD(OnPosLength) (THIS_ UINT32 ulPosition, UINT32 ulLength);
STDMETHOD(OnPresentationOpened) (THIS);
STDMETHOD(OnPresentationClosed) (THIS);
STDMETHOD(OnStatisticsChanged) (THIS);
STDMETHOD(OnPreSeek) (THIS_ ULONG32 ulOldTime, ULONG32 ulNewTime);
STDMETHOD(OnPostSeek) (THIS_ ULONG32 ulOldTime, ULONG32 ulNewTime);
STDMETHOD(OnStop) (THIS);
STDMETHOD(OnPause) (THIS_ ULONG32 ulTime);
STDMETHOD(OnBegin) (THIS_ ULONG32 ulTime);
STDMETHOD(OnBuffering) (THIS_ ULONG32 ulFlags, UINT16 unPercentComplete);
STDMETHOD(OnContacting) (THIS_ const char* pHostName);
// IHXErrorSink
STDMETHOD(ErrorOccurred) (THIS_
const UINT8 unSeverity,
const ULONG32 ulHXCode,
const ULONG32 ulUserCode,
const char* pUserString,
const char* pMoreInfoURL);
// IHXAccessPointSelector
STDMETHOD(SelectAccessPoint)(THIS_
IHXAccessPointSelectorResponse* pResponse);
// IHXGroupSink
STDMETHOD(GroupAdded) (THIS_
UINT16 /*IN*/ uGroupIndex,
IHXGroup* /*IN*/ pGroup);
STDMETHOD(GroupRemoved) (THIS_
UINT16 /*IN*/ uGroupIndex,
IHXGroup* /*IN*/ pGroup);
STDMETHOD(AllGroupsRemoved) (THIS);
STDMETHOD(TrackAdded) (THIS_
UINT16 /*IN*/ uGroupIndex,
UINT16 /*IN*/ uTrackIndex,
IHXValues* /*IN*/ pTrack);
STDMETHOD(TrackRemoved) (THIS_
UINT16 /*IN*/ uGroupIndex,
UINT16 /*IN*/ uTrackIndex,
IHXValues* /*IN*/ pTrack);
STDMETHOD(TrackStarted) (THIS_
UINT16 /*IN*/ uGroupIndex,
UINT16 /*IN*/ uTrackIndex,
IHXValues* /*IN*/ pTrack);
STDMETHOD(TrackStopped) (THIS_
UINT16 /*IN*/ uGroupIndex,
UINT16 /*IN*/ uTrackIndex,
IHXValues* /*IN*/ pTrack);
STDMETHOD(CurrentGroupSet) (THIS_
UINT16 /*IN*/ uGroupIndex,
IHXGroup* /*IN*/ pGroup);
private:
// implementation helpers
void ResetUnloadedClipState();
void DoPlaylistInit(const char* pURL);
bool HandlePlaylistAdvance(TUint flag);
void DoPlayImp(const char* url);
void DoStopImp();
void OnNetConnect();
private:
//TUint m_minVolume;
//TUint m_maxVolume;
TUint m_volumeStep;
ULONG32 m_clipDuration;
ULONG32 m_clipPos;
CHXString m_playUrl;
CHXString m_mainUrl;
CHXAvPlayerState m_playerState;
CHXClientEngineManagerPtr m_spEngine;
comptr<IHXPlayer> m_hxPlayer;
comptr<IHXAudioPlayer> m_audioPlayer;
comptr<CHXAvSiteSupplier> m_siteSupplier;
comptr<CHXLitePrefs> m_prefs;
comptr<IHXCommonClassFactory> m_factory;
comptr<IHXAccessPointManager> m_apManager;
CHXAvNetConnectUIPtr m_apSelector;
CHXAvPlaylistPtr m_pPlaylist;
CHXAvPlaylistItrPtr m_pPlayItr;
bool m_bEnableAutoPlayNext;
bool m_bIsTruePlaylistLoaded;
bool m_bResumeOnEndSeek;
CHXAvCallback m_cbPlay;
enum StartupStage
{
ssStopped,
ssPastInitiate,
ssPastOpenPres,
ssPastFirstBuffer,
ssPastTimerStarted
} m_startupStage;
bool m_bIsRemotePlayback;
bool m_bAccessPointSetupFailed;
CHXSymClipInfo m_clipInfo;
};
inline
const CHXSymClipInfo& CHXAvPlayer::GetClipInfo() const
{
return m_clipInfo;
}
inline
bool CHXAvPlayer::IsShutDown() const
{
return (!m_hxPlayer);
}
//
// return TRUE if:
//
// a) non-file url, e.g.:
//
// sdp
// rtsp
// http
//
// or
//
// b) remote link (one of above) in a smil file
//
// in case (b) we can't know until after the presentation opens
//
inline
bool CHXAvPlayer::IsRemotePlayback() const
{
return m_bIsRemotePlayback;
}
inline
bool CHXAvPlayer::HasPresLoaded() const
{
return m_startupStage >= ssPastOpenPres;
}
inline
bool CHXAvPlayer::HasPresStarted() const
{
return m_startupStage >= ssPastFirstBuffer;
}
inline
bool CHXAvPlayer::IsBuffering() const
{
return (CHXAvPlayerState::NotBuffering != m_playerState.GetBufferingState());
}
inline
bool CHXAvPlayer::IsPlaying() const
{
return CHXAvPlayerState::Playing == m_playerState.GetState();
}
inline
bool CHXAvPlayer::IsPaused() const
{
return CHXAvPlayerState::Paused == m_playerState.GetState();
}
inline
bool CHXAvPlayer::IsStopped() const
{
return CHXAvPlayerState::Stopped == m_playerState.GetState();
}
inline
bool CHXAvPlayer::IsSeeking() const
{
return CHXAvPlayerState::Seeking == m_playerState.GetState();
}
inline
bool CHXAvPlayer::IsConnecting() const
{
return CHXAvPlayerState::Connecting == m_playerState.GetState();
}
inline
bool CHXAvPlayer::IsInitiating() const
{
return CHXAvPlayerState::Initiating == m_playerState.GetState();
}
inline
ULONG32 CHXAvPlayer::GetClipDuration() const
{
return m_clipDuration;
}
inline
CHXString CHXAvPlayer::GetMainURL() const
{ return m_mainUrl; }
inline
CHXString CHXAvPlayer::GetPlayURL() const
{ return m_playUrl; }
inline
bool CHXAvPlayer::IsPlaylistLoaded() const
{ return m_pPlaylist; }
inline
CHXAvPlayerState& CHXAvPlayer::GetPlayerState()
{ return m_playerState; }
inline
void CHXAvPlayer::RedrawPresentation()
{ m_siteSupplier->RedrawAllSites(); }
#endif // CHXAVPLAYER_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?