2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <video-player-impl.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/public-api/object/type-registry.h>
25 #include <dali/public-api/object/any.h>
28 #include <native-image-source.h>
39 namespace // unnamed namespace
41 const char* VIDEO_PLUGIN_SO( "libdali-video-player-plugin.so" );
43 Dali::BaseHandle Create()
45 return Dali::VideoPlayer::New();
48 Dali::TypeRegistration type( typeid( Dali::VideoPlayer ), typeid( Dali::BaseHandle ), Create );
50 } // unnamed namespace
52 VideoPlayerPtr VideoPlayer::New()
54 VideoPlayerPtr player = new VideoPlayer();
58 VideoPlayer::VideoPlayer()
61 mCreateVideoPlayerPtr( NULL ),
62 mDestroyVideoPlayerPtr( NULL )
66 VideoPlayer::~VideoPlayer()
70 if( mDestroyVideoPlayerPtr != NULL )
72 mDestroyVideoPlayerPtr( mPlugin );
79 void VideoPlayer::Initialize()
83 mHandle = dlopen( VIDEO_PLUGIN_SO, RTLD_LAZY );
86 if( mHandle == NULL || error != NULL )
88 DALI_LOG_ERROR( "VideoPlayer::Initialize(), dlopen error: %s\n", error );
92 mCreateVideoPlayerPtr = reinterpret_cast< CreateVideoPlayerFunction >( dlsym( mHandle, "CreateVideoPlayerPlugin" ) );
93 if( mCreateVideoPlayerPtr == NULL )
95 DALI_LOG_ERROR( "Can't load symbol CreateVideoPlayerPlugin(), error: %s\n", error );
99 mPlugin = mCreateVideoPlayerPtr();
101 if( mPlugin == NULL )
103 DALI_LOG_ERROR( "Can't create the VideoPlayerPlugin object\n" );
107 mDestroyVideoPlayerPtr = reinterpret_cast< DestroyVideoPlayerFunction >( dlsym( mHandle, "DestroyVideoPlayerPlugin" ) );
108 if( mDestroyVideoPlayerPtr == NULL )
110 DALI_LOG_ERROR( "Can't load symbol DestroyVideoPlayerPlugin(), error: %s\n", error );
116 void VideoPlayer::SetUrl( const std::string& url )
118 if( mPlugin != NULL )
120 mPlugin->SetUrl( url );
124 std::string VideoPlayer::GetUrl()
126 if( mPlugin != NULL )
128 return mPlugin->GetUrl();
131 return std::string( NULL );
134 void VideoPlayer::SetLooping(bool looping)
136 if( mPlugin != NULL )
138 mPlugin->SetLooping( looping );
142 bool VideoPlayer::IsLooping()
144 if( mPlugin != NULL )
146 return mPlugin->IsLooping();
152 void VideoPlayer::Play()
154 if( mPlugin != NULL )
160 void VideoPlayer::Pause()
162 if( mPlugin != NULL )
168 void VideoPlayer::Stop()
170 if( mPlugin != NULL )
176 void VideoPlayer::SetMute( bool mute )
178 if( mPlugin != NULL )
180 mPlugin->SetMute( mute );
184 bool VideoPlayer::IsMuted()
186 if( mPlugin != NULL )
188 return mPlugin->IsMuted();
194 void VideoPlayer::SetVolume( float left, float right )
196 if( mPlugin != NULL )
198 mPlugin->SetVolume( left, right );
202 void VideoPlayer::GetVolume( float& left, float& right )
204 if( mPlugin != NULL )
206 mPlugin->GetVolume( left, right );
210 void VideoPlayer::SetRenderingTarget( Dali::Any target )
212 if( mPlugin != NULL )
214 mPlugin->SetRenderingTarget( target );
218 void VideoPlayer::SetPlayPosition( int millisecond )
220 if( mPlugin != NULL )
222 mPlugin->SetPlayPosition( millisecond );
226 int VideoPlayer::GetPlayPosition()
228 if( mPlugin != NULL )
230 return mPlugin->GetPlayPosition();
235 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
237 if( mPlugin != NULL )
239 mPlugin->SetDisplayRotation( rotation );
243 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
245 if( mPlugin != NULL )
247 return mPlugin->GetDisplayRotation();
250 return Dali::VideoPlayerPlugin::ROTATION_NONE;
253 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
255 if( mPlugin != NULL )
257 return mPlugin->FinishedSignal();
260 return mFinishedSignal;
263 } // namespace Adaptor;
264 } // namespace Internal;