66e37d3e5e8764df40fb2b60eb72e1a07851bc8e
[apps/osp/VideoPlayer.git] / inc / VpVideoPlayerPresentationModel.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                VpVideoPlayerPresentationModel.h
19  * @brief               This is the header file for PresentationModel class.
20  */
21
22 #ifndef _VP_VIDEO_PLAYER_PRESENTATION_MODEL_H_
23 #define _VP_VIDEO_PLAYER_PRESENTATION_MODEL_H_
24
25 #include <FApp.h>
26 #include <FContent.h>
27 #include <FGraphics.h>
28 #include <FMedia.h>
29 #include <FUi.h>
30 #include "VpIVideoPlayerEventListener.h"
31
32 class VideoPlayerPresentationModel
33         : public Tizen::Base::Runtime::ITimerEventListener
34         , public Tizen::Media::IPlayerEventListener
35 {
36 public:
37         static VideoPlayerPresentationModel* GetInstance(void);
38
39 public:
40         result StartPlay(void);
41         result StopPlay(void);
42         result PausePlay(void);
43         result ClosePlay(void);
44
45         void Forward(void);
46         void Rewind(void);
47         void FastForward(bool playAfterSeek);
48         void FastRewind(bool playAfterSeek);
49         void StopFastForwardRewind(void);
50
51         Tizen::Graphics::Rectangle GetVideoInfoN(const Tizen::Base::String& mediaLocalPath);
52         Tizen::Media::PlayerState GetState(void) const;
53         long GetDuration(void) const;
54         long GetPosition(void) const;
55         result SeekTo(long msTime);
56
57         void SetVideoPlayerEventListener(IVideoPlayerEventListener* pPlayerListener);
58         void SetOverlayRegion(Tizen::Ui::Controls::OverlayRegion* pOverlay);
59         void SetPlayerBuffer(const Tizen::Graphics::BufferInfo& bufferInfo);
60         Tizen::Base::String GetMediaPathName(void) const;
61         int GetMediaCount(void) const;
62         int GetCurrentMediaIndex(void) const;
63         int GetPreviousMediaIndex(void) const;
64
65         result InitializePlayer(void);
66         result ConstructPlayerInstanceWithBufferInfo(void);
67         void SetRenderingBuffer(void);
68
69         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
70
71         virtual void OnPlayerAudioFocusChanged(void);
72         virtual void OnPlayerOpened(result r);
73         virtual void OnPlayerEndOfClip(void);
74         virtual void OnPlayerBuffering(int percent);
75         virtual void OnPlayerErrorOccurred(Tizen::Media::PlayerErrorReason r);
76         virtual void OnPlayerInterrupted(void);
77         virtual void OnPlayerReleased(void);
78         virtual void OnPlayerSeekCompleted(result r);
79
80 private:
81         VideoPlayerPresentationModel(void);
82         virtual ~VideoPlayerPresentationModel(void);
83         VideoPlayerPresentationModel(const VideoPlayerPresentationModel&);
84         VideoPlayerPresentationModel& operator = (const VideoPlayerPresentationModel&);
85
86         result Construct(void);
87         static void CreateInstance(void);
88         static void DestroyInstance(void);
89
90         void InitTimer(void);
91         void DeleteTimer(void);
92
93         void CallOnPlayContentChanged(const Tizen::Base::String& fileName);
94         void CallOnPlayTimeChanged(int currentProgressPos, Tizen::Base::String& currentPlayTime);
95         void CallOnPlayStateChanged(Tizen::Media::PlayerState playState);
96
97         friend void DestroyPresentationModelInstance(void);
98
99 private:
100         static VideoPlayerPresentationModel* __pVideoPlayerPresentationModel;
101         Tizen::Media::Player* __pPlayer;
102         IVideoPlayerEventListener* __pVideoPlayerEventListener;
103         Tizen::Ui::Controls::OverlayRegion* __pOverlayRegion;
104         Tizen::Base::Collection::ArrayList* __pMediaPathArrayList;
105         Tizen::Base::Runtime::Timer* __pTimer;
106         Tizen::Base::Runtime::Timer* __pFastForwardTimer;
107         Tizen::Base::Runtime::Timer* __pFastRewindTimer;
108         Tizen::Base::String __mediaPathName;
109         bool __playerSeekCompleted;
110         bool __playerLastSeekCompleted;
111         bool __playAfterSeek;
112         int __mediaWidth;
113         int __mediaHeight;
114         int __currentMediaIndex;
115         int __nextMediaIndex;
116         int __previousMediaIndex;
117 };
118
119 #endif // _VP_VIDEO_PLAYER_PRESENTATION_MODEL_H_