1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
|
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <app.h>
#include <system_settings.h>
#include "vp-main.h"
#include "vp-service-parser.h"
#include "vp-play-log.h"
#include "vp-play-view.h"
static void __appResume(void *pUserData);
/**
*
* @param pUserData
*/
static void __vp_main_realize_cb(void *pUserData)
{
if (!pUserData) {
VideoLogError("pUserData is NULL");
return;
}
}
/**
*
* @param pUserData
*/
static void __vp_main_destroy_cb(void *pUserData)
{
if (!pUserData) {
VideoLogError("pUserData is NULL");
return;
}
}
/**
*
* @param pUserData
* @return
*/
static bool __appCreate(void *pUserData)
{
VideoLogWarning("== APP CREATE ==");
if (pUserData == NULL) {
VideoLogError("[ERR] No exist pUserData.");
return FALSE;
}
char locale_path[1024] = { 0 };
char *path = app_get_resource_path();
if (path == NULL) {
return FALSE;
}
snprintf(locale_path, 1024, "%s%s", path, "locale");
VideoLogDebug("Locale Path is: %s", locale_path);
bindtextdomain("video-player", locale_path);
free(path);
VpAppData *pAppData = (VpAppData *) pUserData;
pAppData->bPause = FALSE;
pAppData->bIsRelaunch = FALSE;
return TRUE;
}
/**
*
* @param data
* @return
*/
static Eina_Bool __appControl_idler_cb(void *data)
{
VpAppData *pAppData = (VpAppData *) data;
VideoLogPerfS
("============================== RESET =============================");
video_play_launching_type_t nLaunchingType = VIDEO_PLAY_TYPE_OTHER;
video_play_mode_t nMode = VIDEO_PLAY_MODE_NORMAL_VIEW;
bool bRelaunchCaller = FALSE;
VideoLogError("LaunchType = %d", pAppData->pServiceData->eLaunchType);
switch (pAppData->pServiceData->eLaunchType) {
case VP_LAUNCH_TYPE_STORE:
nLaunchingType = VIDEO_PLAY_TYPE_STORE;
bRelaunchCaller = TRUE;
VideoLogWarning("== VIDEO_PLAY_TYPE_STORE ==");
break;
case VP_LAUNCH_TYPE_LIST:
nLaunchingType = VIDEO_PLAY_TYPE_LIST;
VideoLogWarning("== VIDEO_PLAY_TYPE_LIST ==");
break;
case VP_LAUNCH_TYPE_NONE:
case VP_LAUNCH_TYPE_MAX:
nLaunchingType = VIDEO_PLAY_TYPE_OTHER;
VideoLogWarning("== VIDEO_PLAY_TYPE_OTHER ==");
break;
case VP_LAUNCH_TYPE_EMAIL:
nLaunchingType = VIDEO_PLAY_TYPE_EMAIL;
VideoLogWarning("== VIDEO_PLAY_TYPE_EMAIL ==");
break;
case VP_LAUNCH_TYPE_MMS:
nLaunchingType = VIDEO_PLAY_TYPE_MESSAGE;
VideoLogWarning("== VIDEO_PLAY_TYPE_MESSAGE ==");
break;
case VP_LAUNCH_TYPE_MYFILE:
nLaunchingType = VIDEO_PLAY_TYPE_MYFILE;
VideoLogWarning("== VP_LAUNCH_TYPE_MYFILE ==");
break;
case VP_LAUNCH_TYPE_GALLERY:
nLaunchingType = VIDEO_PLAY_TYPE_GALLERY;
VideoLogWarning("== VIDEO_PLAY_TYPE_GALLERY ==");
break;
case VP_LAUNCH_TYPE_IMAGE_VIEWER:
nLaunchingType = VIDEO_PLAY_TYPE_GALLERY;
VideoLogWarning("== VIDEO_PLAY_TYPE_GALLERY ==");
break;
case VP_LAUNCH_TYPE_IMAGE_VIEWER_TRIM:
nLaunchingType = VIDEO_PLAY_TYPE_GALLERY;
VideoLogWarning("== VP_LAUNCH_TYPE_IMAGE_VIEWER_TRIM ==");
break;
case VP_LAUNCH_TYPE_MULTI_PATH:
nLaunchingType = VIDEO_PLAY_TYPE_MULTI_PATH;
break;
case VP_LAUNCH_TYPE_SIMPLE:
nLaunchingType = VIDEO_PLAY_TYPE_PREVIEW;
VideoLogWarning("== VIDEO_PLAY_TYPE_PREVIEW ==");
break;
}
if (pAppData->pServiceData->bStreaming) {
nLaunchingType = VIDEO_PLAY_TYPE_WEB;
}
bool bPopupMode = FALSE;
vp_play_view_get_popup_mode(pAppData->pPlayView, &bPopupMode);
bool bIsRealize = FALSE;
if (vp_play_view_is_realize(pAppData->pPlayView, &bIsRealize)) {
if (bPopupMode == FALSE && bIsRealize == FALSE
&& pAppData->bPause == FALSE) {
VideoLogError("[ERR] Not Yet reailze");
return ECORE_CALLBACK_DONE;
}
}
if ((bPopupMode == TRUE && pAppData->pServiceData->szDMRID == NULL)
|| (g_strcmp0(pAppData->pValStartup, "2") == 0 && bIsRealize)) { // pAppData->values[0] == 2 for multi window; change video url only, don't destroy the player window.
char *szCurURL = NULL;
bool bVisible = FALSE;
if (!vp_play_view_get_url(pAppData->pPlayView, &szCurURL)) {
VideoLogError("vp_play_view_set_url is fail");
}
if (!vp_play_view_get_visible_status
(pAppData->pPlayView, &bVisible)) {
VideoLogError("vp_play_view_get_visible_status is fail");
}
if (szCurURL && bVisible) {
char *req_uri = NULL;
if (pAppData->pServiceData->pMediaUri) {
req_uri = strdup(pAppData->pServiceData->pMediaUri);
} else if (nLaunchingType == VIDEO_PLAY_TYPE_MULTI_PATH) {
if (pAppData->pServiceData->szMultiPath[0] != NULL) {
char *multi_path =
strstr(pAppData->pServiceData->szMultiPath[0],
"file://");
if (multi_path != NULL) {
req_uri = strdup(multi_path);
}
}
}
if (req_uri) {
if (g_strcmp0(req_uri, szCurURL) == 0) {
VideoLogError("skip for same file");
free(szCurURL);
szCurURL = NULL;
free(req_uri);
req_uri = NULL;
Evas_Object *pWin =
vp_play_view_get_main_window(pAppData->pPlayView);
if (pWin) {
if (nLaunchingType == VIDEO_PLAY_TYPE_MESSAGE
|| nLaunchingType == VIDEO_PLAY_TYPE_EMAIL) {
//if current mini mode, change it to full mode
VideoLogWarning
("from Message type and Email type. change mini mode to full mode");
vp_play_view_change_style_minimode_to_fullmode
(pAppData->pPlayView, nLaunchingType);
}
elm_win_activate(pWin);
}
return ECORE_CALLBACK_DONE;
}
free(req_uri);
req_uri = NULL;
} else {
VideoLogError("skip for invalid input");
free(szCurURL);
szCurURL = NULL;
return ECORE_CALLBACK_DONE;
}
if (szCurURL) {
free(szCurURL);
}
szCurURL = NULL;
}
if (!vp_play_view_unrealize(pAppData->pPlayView)) {
VideoLogError("vp_play_view_unrealize is fail");
}
if (!vp_play_view_set_url
(pAppData->pPlayView, pAppData->pServiceData->pMediaUri)) {
VideoLogError("vp_play_view_set_url is fail");
}
vp_play_view_set_launching_mode(pAppData->pPlayView,
nLaunchingType);
if (szCurURL) {
free(szCurURL);
szCurURL = NULL;
}
} else {
if (pAppData->pPlayView) {
#ifdef _PERF_TEST_
vp_play_view_reset(pAppData->pPlayView, nMode);
#else
vp_play_view_reset_audio_only(pAppData->pPlayView);
vp_play_view_destroy(pAppData->pPlayView);
#endif
pAppData->pPlayView = NULL;
}
if (pAppData->pPlayView == NULL) {
pAppData->pPlayView =
vp_play_view_create(NULL,
pAppData->pServiceData->nParentXID,
nMode, nLaunchingType);
if (pAppData->pPlayView == NULL) {
VideoLogError("vp_play_view_create is fail");
elm_exit();
return ECORE_CALLBACK_DONE;
}
}
Evas_Object *pWin = NULL;
pWin = vp_play_view_get_main_window(pAppData->pPlayView);
evas_object_show(pWin);
elm_win_activate(pWin);
if (!vp_play_view_set_callback
(pAppData->pPlayView, VIDEO_PLAY_CB_TYPE_REALIZE,
__vp_main_realize_cb)) {
VideoLogError("vp_play_view_set_callback is fail");
return ECORE_CALLBACK_DONE;
}
if (!vp_play_view_set_callback
(pAppData->pPlayView, VIDEO_PLAY_CB_TYPE_DESTORY,
__vp_main_destroy_cb)) {
VideoLogError("vp_play_view_set_callback is fail");
return ECORE_CALLBACK_DONE;
}
if (!vp_play_view_set_user_data
(pAppData->pPlayView, (void *) pAppData)) {
VideoLogError("vp_play_view_set_user_data is fail");
return ECORE_CALLBACK_DONE;
}
}
if (nLaunchingType == VIDEO_PLAY_TYPE_WEB) {
if (!vp_play_view_set_cookie
(pAppData->pPlayView, pAppData->pServiceData->szCookie)) {
VideoLogError("vp_play_view_set_cookie is fail");
}
if (!vp_play_view_set_proxy
(pAppData->pPlayView, pAppData->pServiceData->szProxy)) {
VideoLogError("vp_play_view_set_proxy is fail");
}
}
if (pAppData->pServiceData->szDMRID) {
VideoLogWarning("DMR ID : %s", pAppData->pServiceData->szDMRID);
if (!vp_play_view_set_dmr_id
(pAppData->pPlayView, pAppData->pServiceData->szDMRID)) {
VideoLogError("vp_play_view_set_dmr_id is fail");
}
}
if (nLaunchingType == VIDEO_PLAY_TYPE_MULTI_PATH
&& pAppData->pServiceData->szMultiPath) {
int idx = 0;
if (!vp_play_view_set_stop_after_repeat_mode
(pAppData->pPlayView,
pAppData->pServiceData->bStopAfterRepeat)) {
VideoLogError
("vp_play_view_set_stop_after_repeat_mode is fail");
}
for (idx = 0; idx < pAppData->pServiceData->nMultiPath; idx++) {
if (pAppData->pServiceData->szMultiPath[idx] == NULL) {
continue;
}
if (pAppData->pServiceData->szMultiPath[idx]) {
char *szSubtitle = NULL;
char *szTitle = NULL;
int nPosition = 0;
int nDuration = 0;
if (idx == 0) {
if (!vp_play_view_set_url
(pAppData->pPlayView,
pAppData->pServiceData->szMultiPath[idx])) {
VideoLogError("vp_play_view_set_url is fail");
}
}
if (pAppData->pServiceData->szMultiTitle) {
if (pAppData->pServiceData->szMultiTitle[idx]) {
szTitle =
pAppData->pServiceData->szMultiTitle[idx];
}
}
if (pAppData->pServiceData->szMultiSubTitle) {
if (pAppData->pServiceData->szMultiSubTitle[idx]) {
szSubtitle =
pAppData->pServiceData->szMultiSubTitle[idx];
}
}
if (pAppData->pServiceData->szMultiPosition) {
if (pAppData->pServiceData->szMultiPosition[idx]) {
nPosition =
atoi(pAppData->pServiceData->
szMultiPosition[idx]);
}
}
if (pAppData->pServiceData->szMultiDuration) {
if (pAppData->pServiceData->szMultiDuration[idx]) {
nDuration =
atoi(pAppData->pServiceData->
szMultiDuration[idx]);
}
}
vp_play_view_add_multi_path(pAppData->pPlayView,
pAppData->pServiceData->
szMultiPath[idx], szTitle,
szSubtitle, nPosition,
nDuration, FALSE);
}
}
} else {
int nPosition = 0;
if (pAppData->pServiceData->bStoreDownload) {
nPosition = pAppData->pServiceData->nStorePlayedTime;
}
if (!vp_play_view_set_start_position
(pAppData->pPlayView, nPosition)) {
VideoLogError("vp_play_view_set_start_position is fail");
}
if (!vp_play_view_set_url
(pAppData->pPlayView, pAppData->pServiceData->pMediaUri)) {
VideoLogError("vp_play_view_set_url is fail");
}
if (!vp_play_view_set_store_download_mode
(pAppData->pPlayView,
pAppData->pServiceData->bStoreDownload)) {
VideoLogError("vp_play_view_set_store_download_mode is fail");
}
if (!vp_play_view_set_store_download_filesize
(pAppData->pPlayView,
pAppData->pServiceData->dStoreDL_FileSize)) {
VideoLogError
("vp_play_view_set_store_download_filesize is fail");
}
if (pAppData->pServiceData->bStoreDownload == EINA_TRUE
&& pAppData->pServiceData->pStoreOrderId != NULL) {
if (!vp_play_view_set_store_order_info
(pAppData->pPlayView,
pAppData->pServiceData->pStoreOrderId,
pAppData->pServiceData->pStoreServerId,
pAppData->pServiceData->pStoreAppId,
pAppData->pServiceData->pStoreMvId)) {
VideoLogError("vp_play_view_set_store_order_info is fail");
}
}
}
if (pAppData->pServiceData->eListType ==
VP_VIDEO_PLAY_LIST_TYPE_FOLDER) {
vp_play_view_set_list_mode(pAppData->pPlayView,
VIDEO_PLAY_LIST_TYPE_FOLDER);
} else {
vp_play_view_set_list_mode(pAppData->pPlayView,
VIDEO_PLAY_LIST_TYPE_ALL);
}
if (pAppData->pServiceData->szDeviceID) {
VideoLogWarning("Device ID : %s",
pAppData->pServiceData->szDeviceID);
if (!vp_play_view_set_device_id
(pAppData->pPlayView, pAppData->pServiceData->szDeviceID)) {
VideoLogError("vp_play_view_set_device_id is fail");
}
}
if (!vp_play_view_set_auto_play_setting
(pAppData->pPlayView, pAppData->pServiceData->szAutoPlay)) {
VideoLogError("vp_play_view_set_auto_play_setting is fail");
}
if (pAppData->pServiceData->szMediaTitle) {
VideoLogWarning("szMediaTitle : %s",
pAppData->pServiceData->szMediaTitle);
if (!vp_play_view_set_media_title
(pAppData->pPlayView, pAppData->pServiceData->szMediaTitle)) {
VideoLogError("vp_play_view_set_media_title is fail");
}
}
if (!vp_play_view_set_relaunch_caller
(pAppData->pPlayView, bRelaunchCaller)) {
VideoLogError("vp_play_view_set_user_data is fail");
return ECORE_CALLBACK_DONE;
}
VideoLogPerfE
("============================== RESET =============================");
if (pAppData->pAppSvcIdler) {
ecore_idler_del(pAppData->pAppSvcIdler);
pAppData->pAppSvcIdler = NULL;
}
return ECORE_CALLBACK_DONE;
}
/**
*
* @param pAppSvcHandle
* @param pUserData
*/
static void __appControl(app_control_h pAppSvcHandle, void *pUserData)
{
VideoLogWarning("== APP SERVICE ==");
if (pAppSvcHandle == NULL) {
VideoLogError("[ERR] No exist pAppSvcHandle.");
return;
}
if (pUserData == NULL) {
VideoLogError("[ERR] No exist pUserData.");
return;
}
VpAppData *pAppData = (VpAppData *) pUserData;
char *resume_check = NULL;
if (app_control_get_extra_data
(pAppSvcHandle, "startup_type",
&resume_check) != APP_CONTROL_ERROR_NONE) {
VideoLogInfo("No exist startup_type");
} else {
VideoLogInfo("temp_resume_check : %s", resume_check);
if (resume_check) {
if (strcmp(resume_check, "1") == 0) {
VideoLogInfo("do resume");
free(resume_check);
VpAppData *pAppData = (VpAppData *) pUserData;
Evas_Object *pWin = NULL;
pWin = vp_play_view_get_main_window(pAppData->pPlayView);
if (pWin) {
__appResume(pUserData);
return;
} else {
VideoLogError("No exist pWin");
}
}
}
}
if (pAppData->pServiceData != NULL) {
VpServiceParserDestroyServiceData(pAppData->pServiceData);
pAppData->pServiceData = NULL;
}
pAppData->pServiceData = calloc(1, sizeof(VpServiceData));
if (VpServiceParserGetServiceData
(pAppSvcHandle, pAppData->pServiceData) == EINA_FALSE) {
VideoLogError("[ERR] VpServiceParserGetServiceData fail!!!");
if (pAppData->pServiceData != NULL) {
VpServiceParserDestroyServiceData(pAppData->pServiceData);
pAppData->pServiceData = NULL;
}
return;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// for sidesync
//////////////////////////////////////////////////////////////////////////////////////////////////////
if (pAppData->pServiceData && pAppData->pServiceData->pMediaUri != NULL) {
VideoSecureLogInfo("ss-play: %s",
pAppData->pServiceData->pMediaUri);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
// for split window
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef _PERF_TEST_
pAppData->pAppSvcIdler =
ecore_idler_add(__appControl_idler_cb, (void *) pAppData);
#else
__appControl_idler_cb((void *) pAppData);
#endif
}
/**
*
* @param pUserData
*/
static void __appExit(void *pUserData)
{
if (pUserData == NULL) {
VideoLogError("[ERR] No exist pUserData.");
return;
}
VideoLogWarning("== APP EXIT ==");
VpAppData *pAppData = (VpAppData *) pUserData;
if (pAppData->pServiceData != NULL) {
VpServiceParserDestroyServiceData(pAppData->pServiceData);
pAppData->pServiceData = NULL;
}
if (pAppData->pPlayView) {
vp_play_view_destroy(pAppData->pPlayView);
pAppData->pPlayView = NULL;
}
if (pAppData->pValStartup != NULL) {
free(pAppData->pValStartup);
pAppData->pValStartup = NULL;
}
if (pAppData->pValLayout != NULL) {
free(pAppData->pValLayout);
pAppData->pValLayout = NULL;
}
}
/**
*
* @param pUserData
*/
static void __appPause(void *pUserData)
{
VideoLogWarning("== APP PAUSE ==");
if (pUserData == NULL) {
VideoLogError("[ERR] No exist pUserData.");
return;
}
VpAppData *pAppData = (VpAppData *) pUserData;
pAppData->bPause = TRUE;
#if 1
if (!vp_play_view_unrealize(pAppData->pPlayView)) {
VideoLogWarning("vp_play_view_unrealize is fail");
}
#else
if (!vp_play_view_get_popup_mode(pAppData->pPlayView, &bPopupMode)) {
VideoLogWarning("vp_play_view_get_popup_mode is fail");
}
if (bPopupMode == FALSE) {
if (!vp_play_view_unrealize(pAppData->pPlayView)) {
VideoLogWarning("vp_play_view_unrealize is fail");
}
}
#endif
}
/**
*
* @param pUserData
*/
static void __appResume(void *pUserData)
{
VideoLogWarning("== APP RESUME ==");
if (pUserData == NULL) {
VideoLogError("[ERR] No exist pUserData.");
return;
}
VpAppData *pAppData = (VpAppData *) pUserData;
pAppData->bPause = FALSE;
if (!vp_play_view_realize(pAppData->pPlayView)) {
VideoLogError("vp_play_view_realize is fail");
}
vp_play_view_live_stream_realize(pAppData->pPlayView);
}
/**
*
* @param event_info
* @param data
*/
void vp_low_battery(app_event_info_h event_info, void *data)
{
VpAppData *ad = (VpAppData *) data;
app_event_low_battery_status_e status = -1;
int ret = app_event_get_low_battery_status(event_info, &status);
if (ret == APP_ERROR_NONE) {
if (status <= APP_EVENT_LOW_BATTERY_POWER_OFF) {
__appExit(ad);
}
} else {
VideoLogInfo("Failed to get battery status. ret %d", ret);
}
return;
}
/**
*
* @param pEventInfo
* @param pUserData
*/
static void __appUpdateLanguage(app_event_info_h pEventInfo,
void *pUserData)
{
char *locale = NULL;
VpAppData *pAd = (VpAppData*) pUserData;
int retcode =
system_settings_get_value_string
(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
if (retcode != SYSTEM_SETTINGS_ERROR_NONE) {
VideoLogInfo
("[ERR] failed to get updated language!!! [retcode = retcode]",
retcode);
} else {
if (locale) {
elm_language_set(locale);
free(locale);
}
}
if (pAd) {
vp_play_view_handle_language_change(pAd->pPlayView);
}
}
/**
*
* @param argc
* @param argv
* @return
*/
EXPORT_API int main(int argc, char *argv[])
{
VpAppData sAppData = { 0, };
int nRet = -1;
ui_app_lifecycle_callback_s st_appEventService;
app_event_handler_h hLanguageChangedHandle;
app_event_handler_h hLowBatteryHandle;
nRet =
ui_app_add_event_handler(&hLanguageChangedHandle,
APP_EVENT_LANGUAGE_CHANGED,
__appUpdateLanguage, (void *) &sAppData);
if (nRet != APP_ERROR_NONE) {
VideoLogError
("APP_EVENT_LANGUAGE_CHANGED ui_app_add_event_handler failed : [%d]!!!",
nRet);
return -1;
}
nRet =
ui_app_add_event_handler(&hLowBatteryHandle, APP_EVENT_LOW_BATTERY,
vp_low_battery, (void *) &sAppData);
if (nRet != APP_ERROR_NONE) {
VideoLogError
("APP_EVENT_LOW_BATTERY ui_app_add_event_handler failed : [%d]!!!",
nRet);
return -1;
}
st_appEventService.create = __appCreate;
st_appEventService.terminate = __appExit;
st_appEventService.pause = __appPause;
st_appEventService.resume = __appResume;
st_appEventService.app_control = __appControl;
if (ui_app_main(argc, argv, &st_appEventService, &sAppData) !=
APP_ERROR_NONE) {
return -1;
}
return 0;
}
|