Merge with master
[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 VideoPlayerPresentationModel 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 SetOverlayPanel(Tizen::Ui::Controls::OverlayPanel* pOverlay);
59
60         void SetPlayerBuffer(const Tizen::Graphics::BufferInfo& bufferInfo);
61         Tizen::Base::String GetMediaPathName(void) const;
62         int GetMediaCount(void) const;
63         int GetCurrentMediaIndex(void) const;
64         int GetPreviousMediaIndex(void) const;
65
66         result InitializePlayer(void);
67         result ConstructPlayerInstanceWithBufferInfo(void);
68         void SetRenderingBuffer(void);
69
70         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
71
72         virtual void OnPlayerAudioFocusChanged(void);
73         virtual void OnPlayerOpened(result r);
74         virtual void OnPlayerEndOfClip(void);
75         virtual void OnPlayerBuffering(int percent);
76         virtual void OnPlayerErrorOccurred(Tizen::Media::PlayerErrorReason r);
77         virtual void OnPlayerInterrupted(void);
78         virtual void OnPlayerReleased(void);
79         virtual void OnPlayerSeekCompleted(result r);
80
81 private:
82         VideoPlayerPresentationModel(void);
83         virtual ~VideoPlayerPresentationModel(void);
84         VideoPlayerPresentationModel(const VideoPlayerPresentationModel&);
85         VideoPlayerPresentationModel& operator = (const VideoPlayerPresentationModel&);
86
87         result Construct(void);
88         static void CreateInstance(void);
89         static void DestroyInstance(void);
90
91         void InitTimer(void);
92         void DeleteTimer(void);
93
94         void CallOnPlayContentChanged(const Tizen::Base::String& fileName);
95         void CallOnPlayTimeChanged(int currentProgressPos, Tizen::Base::String& currentPlayTime);
96         void CallOnPlayStateChanged(Tizen::Media::PlayerState playState);
97
98         friend void DestroyPresentationModelInstance(void);
99
100 private:
101         static VideoPlayerPresentationModel* __pVideoPlayerPresentationModel;
102         Tizen::Media::Player* __pPlayer;
103         IVideoPlayerEventListener* __pVideoPlayerEventListener;
104         Tizen::Ui::Controls::OverlayPanel* __pOverlayPanel;
105
106         Tizen::Base::Collection::ArrayList* __pMediaPathArrayList;
107         Tizen::Base::Runtime::Timer* __pTimer;
108         Tizen::Base::Runtime::Timer* __pFastForwardTimer;
109         Tizen::Base::Runtime::Timer* __pFastRewindTimer;
110         Tizen::Base::String __mediaPathName;
111         bool __playerSeekCompleted;
112         bool __playerLastSeekCompleted;
113         bool __playAfterSeek;
114         int __mediaWidth;
115         int __mediaHeight;
116         int __currentMediaIndex;
117         int __nextMediaIndex;
118         int __previousMediaIndex;
119 };
120
121 #endif // _VP_VIDEO_PLAYER_PRESENTATION_MODEL_H_