2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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.
18 #include <Elementary.h>
20 #include <AppCommon.h>
25 #include "view_player.h"
28 #define WIN_TITLE "Video Player"
29 #define PARAM_URI "uri"
30 #define PARAM_PLAYLIST_ID "playlist_id"
37 class CVideoPlayerApp : public CBaseApp {
41 CPlayerView *m_pPlayerView;
44 static Evas_Object *sm_AddWin(const char *name);
47 CVideoPlayerApp(void);
48 virtual ~CVideoPlayerApp(void);
50 virtual bool OnCreate(void);
51 virtual void OnPause(void);
52 virtual void OnResume(void);
53 virtual void OnTerminate(void);
54 virtual void OnService(service_h service);
56 virtual int Run(int argc, char **argv);
59 CVideoPlayerApp::CVideoPlayerApp(void)
61 m_pApp = new SAppData;
64 CVideoPlayerApp::~CVideoPlayerApp(void)
70 Evas_Object *CVideoPlayerApp::sm_AddWin(const char *name)
79 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
83 elm_win_title_set(win, WIN_TITLE);
85 evas_object_show(win);
87 evas = evas_object_evas_get(win);
88 obj = evas_object_rectangle_add(evas);
89 evas_object_color_set(obj, 0, 0, 0, 0);
90 evas_object_render_op_set(obj, EVAS_RENDER_COPY);
91 elm_win_resize_object_add(win, obj);
92 evas_object_show(obj);
97 bool CVideoPlayerApp::OnCreate(void)
103 elm_theme_overlay_add(NULL, THEMEFILE);
104 elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
106 win = sm_AddWin(m_pApp->name);
108 _ERR("failed to add window");
112 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
113 elm_win_focus_highlight_style_set(win, STYLE_INVISIBLE);
115 CViewMgr::Initialize(win, NULL);
116 m_pVmgr = CViewMgr::GetInstance();
118 _ERR("failed init view manager");
127 void CVideoPlayerApp::OnTerminate(void)
131 CViewMgr::Finalize();
134 evas_object_del(m_pApp->win);
137 void CVideoPlayerApp::OnPause(void)
144 void CVideoPlayerApp::OnResume(void)
151 void CVideoPlayerApp::OnService(service_h service)
160 r = service_get_extra_data(service, PARAM_URI, &uri);
161 if (r != SERVICE_ERROR_NONE)
164 r = service_get_extra_data(service, PARAM_PLAYLIST_ID, &playlist);
165 if (r != SERVICE_ERROR_NONE)
168 param.id = VIEW_ID_PLAYER;
169 param.filepath = uri;
170 param.playlist = playlist;
172 m_pPlayerView = new CPlayerView(VIEW_ID_PLAYER);
173 m_pVmgr->AddView(m_pPlayerView);
175 if (!m_pVmgr->PushView(VIEW_ID_PLAYER, ¶m)) {
176 _ERR("View push failed");
177 CViewMgr::Finalize();
188 int CVideoPlayerApp::Run(int argc, char **argv)
192 m_pApp->name = PACKAGE;
194 return CBaseApp::Run(argc, argv);
197 int main(int argc, char **argv)