05e66d8182fcd30243cc0e8e7afb7a11491a9bf7
[platform/core/uifw/dali-toolkit.git] / toolkit-video-player.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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 // CLASS HEADER
19 #include "toolkit-video-player.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/any.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 namespace Adaptor
31 {
32
33 class VideoPlayer: public Dali::BaseObject
34 {
35 public:
36
37   VideoPlayer()
38   {
39     mMuted = false;
40     mLooping = false;
41   }
42
43   void SetMuted( bool muted )
44   {
45     mMuted = muted;
46   }
47
48   bool IsMuted()
49   {
50     return mMuted;
51   }
52
53   void SetLooping( bool looping )
54   {
55     mLooping = looping;
56   }
57
58   bool IsLooping()
59   {
60     return mLooping;
61   }
62
63 public:
64
65   std::string mUrl;
66   float mVolumeLeft;
67   float mVolumeRight;
68   Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
69
70 private:
71
72   bool mMuted;
73   bool mLooping;
74 };
75
76 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
77 {
78   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
79   BaseObject& handle = player.GetBaseObject();
80   return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
81 }
82
83 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
84 {
85   DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
86   const BaseObject& handle = player.GetBaseObject();
87   return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
88 }
89
90 } // namespace Adaptor
91
92 } // namespace Internal
93
94
95 /********************************************************************************/
96 /*********************************  PUBLIC CLASS  *******************************/
97 /********************************************************************************/
98
99 VideoPlayer::VideoPlayer()
100 {
101 }
102
103 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
104 : BaseHandle( internal )
105 {
106 }
107
108 VideoPlayer::~VideoPlayer()
109 {
110 }
111
112 VideoPlayer VideoPlayer::New()
113 {
114   Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
115
116   return VideoPlayer( player );
117 }
118
119 VideoPlayer::VideoPlayer( const VideoPlayer& player )
120 : BaseHandle( player )
121 {
122 }
123
124 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
125 {
126   BaseHandle::operator=( player );
127   return *this;
128 }
129
130 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
131 {
132   VideoPlayer videoPlayer;
133   return videoPlayer;
134 }
135
136 void VideoPlayer::SetUrl( const std::string& url )
137 {
138   Internal::Adaptor::GetImplementation( *this ).mUrl = url;
139 }
140
141 std::string VideoPlayer::GetUrl()
142 {
143   return Internal::Adaptor::GetImplementation( *this ).mUrl;
144 }
145
146 void VideoPlayer::SetLooping(bool looping)
147 {
148   Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
149 }
150
151 bool VideoPlayer::IsLooping()
152 {
153   return Internal::Adaptor::GetImplementation( *this ).IsLooping();
154 }
155
156 void VideoPlayer::Play()
157 {
158 }
159
160 void VideoPlayer::Pause()
161 {
162 }
163
164 void VideoPlayer::Stop()
165 {
166 }
167
168 void VideoPlayer::SetMute( bool mute )
169 {
170   Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
171 }
172
173 bool VideoPlayer::IsMuted()
174 {
175   return Internal::Adaptor::GetImplementation( *this ).IsMuted();
176 }
177
178 void VideoPlayer::SetVolume( float left, float right )
179 {
180   Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
181   Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
182 }
183
184 void VideoPlayer::GetVolume( float& left, float& right )
185 {
186   left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
187   right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
188 }
189
190 void VideoPlayer::SetRenderingTarget( Any target )
191 {
192 }
193
194 void VideoPlayer::SetPlayPosition( int millisecond )
195 {
196 }
197
198 int VideoPlayer::GetPlayPosition()
199 {
200   return 0;
201 }
202
203 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
204 {
205 }
206
207 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
208 {
209   return Dali::VideoPlayerPlugin::ROTATION_NONE;
210 }
211
212 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
213 {
214   return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
215 }
216
217 } // namespace Dali;
218