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>
23 #include "view_player.h"
26 #define WIN_TITLE "Video Player"
27 #define PARAM_URI "uri"
28 #define PARAM_PLAYLIST_ID "playlist_id"
36 class CVideoPlayerApp : public CBaseApp {
41 static Evas_Object *sm_AddWin(const char *name);
44 CVideoPlayerApp(void);
45 virtual ~CVideoPlayerApp(void);
46 virtual bool OnCreate(void);
47 virtual void OnPause(void);
48 virtual void OnResume(void);
49 virtual void OnTerminate(void);
50 virtual void OnService(service_h service);
51 virtual int Run(int argc, char **argv);
54 CVideoPlayerApp::CVideoPlayerApp(void)
56 m_pApp = new SAppData;
59 CVideoPlayerApp::~CVideoPlayerApp(void)
65 Evas_Object *CVideoPlayerApp::sm_AddWin(const char *name)
74 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
78 elm_win_title_set(win, WIN_TITLE);
80 evas_object_show(win);
82 evas = evas_object_evas_get(win);
83 obj = evas_object_rectangle_add(evas);
84 evas_object_color_set(obj, 0, 0, 0, 0);
85 evas_object_render_op_set(obj, EVAS_RENDER_COPY);
86 elm_win_resize_object_add(win, obj);
87 evas_object_show(obj);
92 bool CVideoPlayerApp::OnCreate(void)
98 elm_theme_overlay_add(NULL, THEMEFILE);
99 elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
101 win = sm_AddWin(m_pApp->name);
103 _ERR("failed to add window");
107 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
108 elm_win_focus_highlight_style_set(win, STYLE_INVISIBLE);
115 void CVideoPlayerApp::OnTerminate(void)
120 view_player_fini(m_pApp->vdata);
123 evas_object_del(m_pApp->win);
126 void CVideoPlayerApp::OnPause(void)
133 view_player_pause(m_pApp->vdata);
136 void CVideoPlayerApp::OnResume(void)
143 view_player_resume(m_pApp->vdata);
146 void CVideoPlayerApp::OnService(service_h service)
155 r = service_get_extra_data(service, PARAM_URI, &uri);
156 if (r != SERVICE_ERROR_NONE)
159 r = service_get_extra_data(service, PARAM_PLAYLIST_ID, &playlist_id);
160 if (r != SERVICE_ERROR_NONE)
163 vdata = view_player_init(m_pApp->win, uri, playlist_id);
171 if (view_player_create(vdata) == -1)
174 m_pApp->vdata = vdata;
177 int CVideoPlayerApp::Run(int argc, char **argv)
181 m_pApp->name = PACKAGE;
183 return CBaseApp::Run(argc, argv);
186 int main(int argc, char **argv)