static void _playback_stopped_cb(void *data, Evas_Object *o, void *event_info) { printf("Emotion playback stopped.\n"); emotion_object_play_set(o, EINA_FALSE); emotion_object_position_set(o, 0); }
//Play a new file void eclair_play_file(Eclair *eclair, const char *path) { if (!eclair) return; if (!eclair->video.video_object) { eclair->start_playing = 1; return; } if (path) { emotion_object_file_set(eclair->video.video_object, path); emotion_object_play_set(eclair->video.video_object, 0); eclair_progress_rate_set(eclair, 0.0); eclair->state = ECLAIR_PAUSE; eclair_play(eclair); eclair_subtitles_load_from_media_file(&eclair->subtitles, path); if (eclair->video.video_window) { if (emotion_object_video_handled_get(eclair->video.video_object)) ecore_evas_show(eclair->video.video_window); else ecore_evas_hide(eclair->video.video_window); } } else eclair_stop(eclair); }
int enna_mediaplayer_pause(void) { emotion_object_play_set(mp->player, EINA_FALSE); mp->play_state = PAUSE; ecore_event_add(ENNA_EVENT_MEDIAPLAYER_PAUSE, NULL, NULL, NULL); return 0; }
//Pause the playback void eclair_pause(Eclair *eclair) { if (!eclair || (eclair->state != ECLAIR_PLAYING) || !eclair->video.video_object) return; emotion_object_play_set(eclair->video.video_object, 0); eclair_send_signal_to_all_windows(eclair, "signal_pause"); eclair->state = ECLAIR_PAUSE; }
int enna_mediaplayer_stop(void) { emotion_object_play_set(mp->player, EINA_FALSE); emotion_object_position_set(mp->player, 0); mp->play_state = STOPPED; evas_object_hide(mp->player); evas_object_show(enna->layout); ecore_event_add(ENNA_EVENT_MEDIAPLAYER_STOP, NULL, NULL, NULL); return 0; }
int enna_mediaplayer_play(Enna_Playlist *enna_playlist) { mp->cur_playlist = enna_playlist; switch (mp->play_state) { case STOPPED: { Enna_File *item; item = eina_list_nth(enna_playlist->playlist, enna_playlist->selected); emotion_object_play_set(mp->player, EINA_FALSE); if (item && item->uri) emotion_object_file_set(mp->player, item->mrl); emotion_object_play_set(mp->player, EINA_TRUE); if (item && item->type == ENNA_FILE_FILM) { evas_object_show(mp->player); evas_object_hide(enna->layout); } mp->play_state = PLAYING; ecore_event_add(ENNA_EVENT_MEDIAPLAYER_START, NULL, NULL, NULL); break; } case PLAYING: enna_mediaplayer_pause(); break; case PAUSE: emotion_object_play_set(mp->player, EINA_TRUE); mp->play_state = PLAYING; ecore_event_add(ENNA_EVENT_MEDIAPLAYER_UNPAUSE, NULL, NULL, NULL); break; default: break; } return 0; }
void dvb_init(char *module, char *file, char *swallow) { Evas_Object *o; if (o_dvb_bg) return; if (mdl) free(mdl); mdl = strdup(module); if (swal) free(swal); swal = strdup(swallow); o = edje_object_add(evas); edje_object_file_set(o, theme, "video_container"); o_dvb_bg = o; o = emotion_object_add(evas); if (!emotion_object_init(o, module)) { printf("ERROR!\n"); } evas_object_smart_callback_add(o, "frame_decode", dvb_obj_frame_decode_cb, NULL); evas_object_smart_callback_add(o, "frame_resize", dvb_obj_frame_resize_cb, NULL); evas_object_smart_callback_add(o, "length_change", dvb_obj_length_change_cb, NULL); evas_object_smart_callback_add(o, "decode_stop", dvb_obj_stopped_cb, NULL); evas_object_smart_callback_add(o, "channels_change", dvb_obj_channels_cb, NULL); evas_object_smart_callback_add(o, "title_change", dvb_obj_title_cb, NULL); evas_object_smart_callback_add(o, "progress_change", dvb_obj_progress_cb, NULL); evas_object_smart_callback_add(o, "ref_change", dvb_obj_ref_cb, NULL); evas_object_smart_callback_add(o, "button_num_change", dvb_obj_button_num_cb, NULL); evas_object_smart_callback_add(o, "button_change", dvb_obj_button_cb, NULL); o_dvb = o; channel = 0; emotion_object_file_set(o_dvb, "dvb://0"); emotion_object_play_set(o_dvb, 1); emotion_object_audio_mute_set(o_dvb, 0); emotion_object_audio_volume_set(o_dvb, 1.0); layout_swallow(swallow, o_dvb_bg); edje_extern_object_aspect_set(o_dvb, EDJE_ASPECT_CONTROL_BOTH, 640, 480); edje_object_part_swallow(o_dvb_bg, "video", o_dvb); dvb_resize(); evas_object_show(o_dvb); evas_object_show(o_dvb_bg); _hide_timer = ecore_timer_add(10.0, dvb_menu_bg_hide_tmer_cb, NULL); /* FIXME: add this video to recently played list */ }
static void _win_song_set(Win *w, Song *s) { Edje_Message_Int mi; Song *previous; char str[32]; w->play.position = 0.0; w->play.length = 0.0; previous = w->song; w->song = s; if (!s) goto end; if (s->trackno > 0) snprintf(str, sizeof(str), "%d", s->trackno); else str[0] = '\0'; edje_object_part_text_set(w->edje, "ejy.text.trackno", str); edje_object_part_text_set(w->edje, "ejy.text.title", s->title); edje_object_part_text_set(w->edje, "ejy.text.album", s->album); edje_object_part_text_set(w->edje, "ejy.text.artist", s->artist); edje_object_part_text_set(w->edje, "ejy.text.genre", s->genre); mi.val = s->rating; edje_object_message_send(elm_layout_edje_get(w->nowplaying), EDJE_MESSAGE_INT, MSG_RATING, &mi); emotion_object_file_set(w->emotion, s->path); emotion_object_position_set(w->emotion, w->play.position); w->play.playing = EINA_TRUE; w->play.playing_last = EINA_FALSE; emotion_object_play_set(w->emotion, EINA_TRUE); emotion_object_audio_volume_set(w->emotion, w->play.volume); end: if ((!w->play.playing) && (w->timer.play_eval)) { ecore_timer_del(w->timer.play_eval); w->timer.play_eval = NULL; } else if ((w->play.playing) && (!w->timer.play_eval)) w->timer.play_eval = ecore_timer_loop_add (0.1, _win_play_eval_timer, w); _win_nowplaying_update(w, previous); _win_play_eval(w); _win_toolbar_eval(w); ecore_event_add(ENJOY_EVENT_PLAYER_CAPS_CHANGE, NULL, NULL, NULL); ecore_event_add(ENJOY_EVENT_PLAYER_TRACK_CHANGE, NULL, NULL, NULL); }
void enna_mediaplayer_shutdown(void) { if (!mp) return; ENNA_FREE(mp->uri); ENNA_FREE(mp->label); ENNA_FREE(mp->engine); emotion_object_play_set(mp->player, EINA_FALSE); if (mp->player) evas_object_del(mp->player); ENNA_FREE(mp); }
EAPI void _emotion_open_done(Evas_Object *obj) { Smart_Data *sd; E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); sd->open = 1; if (sd->remember_jump) emotion_object_position_set(obj, sd->remember_jump); if (sd->remember_play != sd->play) emotion_object_play_set(obj, sd->remember_play); evas_object_smart_callback_call(obj, SIG_OPEN_DONE, NULL); }
static void dvb_obj_stopped_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *o; char buf[256]; printf("dvb stopped!\n"); o = emotion_object_add(evas_object_evas_get(obj)); if (!emotion_object_init(o, mdl)) { printf("ERROR!\n"); } evas_object_del(o_dvb); evas_object_smart_callback_add(o, "frame_decode", dvb_obj_frame_decode_cb, NULL); evas_object_smart_callback_add(o, "frame_resize", dvb_obj_frame_resize_cb, NULL); evas_object_smart_callback_add(o, "length_change", dvb_obj_length_change_cb, NULL); evas_object_smart_callback_add(o, "decode_stop", dvb_obj_stopped_cb, NULL); evas_object_smart_callback_add(o, "channels_change", dvb_obj_channels_cb, NULL); evas_object_smart_callback_add(o, "title_change", dvb_obj_title_cb, NULL); evas_object_smart_callback_add(o, "progress_change", dvb_obj_progress_cb, NULL); evas_object_smart_callback_add(o, "ref_change", dvb_obj_ref_cb, NULL); evas_object_smart_callback_add(o, "button_num_change", dvb_obj_button_num_cb, NULL); evas_object_smart_callback_add(o, "button_change", dvb_obj_button_cb, NULL); o_dvb = o; snprintf(buf, sizeof(buf), "dvb://%i", channel); emotion_object_file_set(o_dvb, buf); emotion_object_play_set(o_dvb, 1); emotion_object_audio_mute_set(o_dvb, 0); emotion_object_audio_volume_set(o_dvb, 1.0); layout_swallow(swal, o_dvb_bg); edje_extern_object_aspect_set(o_dvb, EDJE_ASPECT_CONTROL_BOTH, 640, 480); edje_object_part_swallow(o_dvb_bg, "video", o_dvb); dvb_resize(); evas_object_show(o_dvb); // if (!dvb_stopped_job) // dvb_stopped_job = ecore_job_add(dvb_stopped_job_cb, data); }
//Stop the playback and hide the video window void eclair_stop(Eclair *eclair) { if (!eclair) return; if (eclair->video.video_object) { emotion_object_play_set(eclair->video.video_object, 0); eclair_progress_rate_set(eclair, 0.0); } eclair_all_windows_text_set(eclair, "time_elapsed", "0:00"); eclair_send_signal_to_all_windows(eclair, "signal_stop"); if (eclair->video.video_window) ecore_evas_hide(eclair->video.video_window); eclair->state = ECLAIR_STOP; }
//TODO: redundant with play_current? //Play the current file if state is STOP or resume if state is PAUSE void eclair_play(Eclair *eclair) { if (!eclair) return; if (!eclair->video.video_object) { eclair->start_playing = 1; return; } if (eclair->state == ECLAIR_PAUSE) { emotion_object_play_set(eclair->video.video_object, 1); eclair_send_signal_to_all_windows(eclair, "signal_play"); eclair->state = ECLAIR_PLAYING; } else if (eclair->state == ECLAIR_STOP) eclair_play_current(eclair); }
int main(int argc, const char *argv[]) { Ecore_Evas *ee; Evas *e; Evas_Object *bg, *em; int i; if (argc < 2) { printf("One argument is necessary. Usage:\n"); printf("\t%s <filename>\n", argv[0]); } eina_init(); for (i = 1; i < argc; i++) filenames = eina_list_append(filenames, eina_stringshare_add(argv[i])); curfile = filenames; if (!ecore_evas_init()) return EXIT_FAILURE; /* this will give you a window with an Evas canvas under the first * engine available */ ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); if (!ee) goto error; ecore_evas_show(ee); /* the canvas pointer, de facto */ e = ecore_evas_get(ee); /* adding a background to this example */ bg = evas_object_rectangle_add(e); evas_object_name_set(bg, "our dear rectangle"); evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ evas_object_move(bg, 0, 0); /* at canvas' origin */ evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ evas_object_show(bg); /* Creating the emotion object */ em = _create_emotion_object(e); emotion_object_file_set(em, eina_list_data_get(curfile)); evas_object_move(em, 0, 0); evas_object_resize(em, WIDTH, HEIGHT); evas_object_show(em); evas_object_smart_callback_add(em, "frame_decode", _frame_decode_cb, NULL); evas_object_smart_callback_add(em, "length_change", _length_change_cb, NULL); evas_object_smart_callback_add(em, "position_update", _position_update_cb, NULL); evas_object_smart_callback_add(em, "progress_change", _progress_change_cb, NULL); evas_object_smart_callback_add(em, "frame_resize", _frame_resize_cb, NULL); evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em); evas_object_focus_set(bg, EINA_TRUE); emotion_object_play_set(em, EINA_TRUE); ecore_main_loop_begin(); ecore_evas_free(ee); ecore_evas_shutdown(); return 0; error: fprintf(stderr, "you got to have at least one evas engine built and linked" " up to ecore-evas for this example to run properly.\n"); EINA_LIST_FREE(filenames, curfile) eina_stringshare_del(eina_list_data_get(curfile)); ecore_evas_shutdown(); eina_shutdown(); return -1; }
static void _on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info) { Evas_Event_Key_Down *ev = event_info; Evas_Object *em = data; if (!strcmp(ev->keyname, "Return")) { emotion_object_play_set(em, EINA_TRUE); } else if (!strcmp(ev->keyname, "space")) { emotion_object_play_set(em, EINA_FALSE); } else if (!strcmp(ev->keyname, "Escape")) { ecore_main_loop_quit(); } else if (!strcmp(ev->keyname, "t")) { int w, h; emotion_object_size_get(em, &w, &h); fprintf(stderr, "example -> size: %dx%d\n", w, h); } else if (!strcmp(ev->keyname, "s")) { float len, pos; len = emotion_object_play_length_get(em); pos = 0.98 * len; fprintf(stderr, "skipping to position %0.3f\n", pos); emotion_object_position_set(em, pos); } else if (!strcmp(ev->keyname, "1")) { fprintf(stderr, "setting speed to 1.0\n"); emotion_object_play_speed_set(em, 1.0); } else if (!strcmp(ev->keyname, "2")) { fprintf(stderr, "setting speed to 2.0\n"); emotion_object_play_speed_set(em, 2.0); } else if (!strcmp(ev->keyname, "n")) { const char *file; if (!curfile) curfile = filenames; else curfile = eina_list_next(curfile); file = eina_list_data_get(curfile); fprintf(stderr, "playing next file: %s\n", file); emotion_object_file_set(em, file); } else if (!strcmp(ev->keyname, "p")) { const char *file; if (!curfile) curfile = eina_list_last(filenames); else curfile = eina_list_prev(curfile); file = eina_list_data_get(curfile); fprintf(stderr, "playing next file: %s\n", file); emotion_object_file_set(em, file); } else if (!strcmp(ev->keyname, "d")) { evas_object_del(em); } else if (!strcmp(ev->keyname, "l")) { // force frame dropping sleep(5); } else { fprintf(stderr, "unhandled key: %s\n", ev->keyname); } }
void dvb_key(Evas_Event_Key_Down *ev) { if (!strcmp(ev->keyname, "bracketleft")) { edje_object_signal_emit(o_dvb_bg, "active", ""); } else if (!strcmp(ev->keyname, "bracketright")) { edje_object_signal_emit(o_dvb_bg, "active", ""); } else if (!strcmp(ev->keyname, "p")) { /* FIXME: play info display end */ jump = 0.0; emotion_object_play_set(o_dvb, 1); edje_object_signal_emit(o_dvb_bg, "active", ""); } else if (!strcmp(ev->keyname, "space")) { /* FIXME: play info display */ jump = 0.0; if (emotion_object_play_get(o_dvb)) emotion_object_play_set(o_dvb, 0); else emotion_object_play_set(o_dvb, 1); edje_object_signal_emit(o_dvb_bg, "active", ""); } else if (!strcmp(ev->keyname, "Up")) { channel++; { char buf[256]; snprintf(buf, sizeof(buf), "dvb://%i", channel); emotion_object_file_set(o_dvb, buf); } } else if (!strcmp(ev->keyname, "Down")) { channel--; if (channel < 0) { channel = 0; } else { char buf[256]; snprintf(buf, sizeof(buf), "dvb://%i", channel); emotion_object_file_set(o_dvb, buf); } } else if (!strcmp(ev->keyname, "Left")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_LEFT); else if (!strcmp(ev->keyname, "Right")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_RIGHT); else if (!strcmp(ev->keyname, "Return")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_SELECT); else if (!strcmp(ev->keyname, "n")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_MENU1); else if (!strcmp(ev->keyname, "Prior")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_PREV); else if (!strcmp(ev->keyname, "Next")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_NEXT); else if (!strcmp(ev->keyname, "0")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_0); else if (!strcmp(ev->keyname, "1")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_1); else if (!strcmp(ev->keyname, "2")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_2); else if (!strcmp(ev->keyname, "3")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_3); else if (!strcmp(ev->keyname, "4")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_4); else if (!strcmp(ev->keyname, "5")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_5); else if (!strcmp(ev->keyname, "6")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_6); else if (!strcmp(ev->keyname, "7")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_7); else if (!strcmp(ev->keyname, "8")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_8); else if (!strcmp(ev->keyname, "9")) emotion_object_event_simple_send(o_dvb, EMOTION_EVENT_9); else if (!strcmp(ev->keyname, "k")) { /* FIXME: volume display */ emotion_object_audio_volume_set(o_dvb, emotion_object_audio_volume_get(o_dvb) - 0.1); } else if (!strcmp(ev->keyname, "l")) { /* FIXME: volume display */ emotion_object_audio_volume_set(o_dvb, emotion_object_audio_volume_get(o_dvb) + 0.1); } else if (!strcmp(ev->keyname, "m")) { /* FIXME: volume display */ if (emotion_object_audio_mute_get(o_dvb)) emotion_object_audio_mute_set(o_dvb, 0); else emotion_object_audio_mute_set(o_dvb, 1); } else if (!strcmp(ev->keyname, "s")) { /* FIXME: save position for this video */ main_mode_pop(); jump = 0.0; dvb_shutdown(); } else if (!strcmp(ev->keyname, "Home")) { /* FIXME: pop up menu for options etc. */ } else if (!strcmp(ev->keyname, "Insert")) { /* FIXME: program ? */ } else if (!strcmp(ev->keyname, "Pause")) { /* FIXME: standby ? */ } else if (!strcmp(ev->keyname, "End")) { /* FIXME: input ? */ } else if (!strcmp(ev->keyname, "BackSpace")) { /* FIXME: catv/clear ? */ } else if (!strcmp(ev->keyname, "t")) { /* FIXME: tool ? */ } else if (!strcmp(ev->keyname, "g")) { /* FIXME: tv guide ? */ } else if (!strcmp(ev->keyname, "period")) { /* FIXME: ch up ? */ } else if (!strcmp(ev->keyname, "comma")) { /* FIXME: ch down ? */ } else if (!strcmp(ev->keyname, "Tab")) { /* FIXME: photo ? */ } else if (!strcmp(ev->keyname, "q")) { /* FIXME: repeat ? */ } else if (!strcmp(ev->keyname, "w")) { /* FIXME: rotate ? (zoom mode) */ } else if (!strcmp(ev->keyname, "n")) { /* FIXME: play info display toggle */ } }
int main(int argc, char** argv) { Eina_Bool ret; Ecore_Evas *ecore_evas; Evas *evas; Evas_Object *bg, *video; Evas_Map *m; if(argc != 2) { fprintf(stderr, "Usage: %s moviefile\n", argv[0]); return 1; } ecore_init(); ecore_evas_init(); emotion_init(); ecore_evas = ecore_evas_new ("software_x11", 300, 200, WINDOW_WIDTH, WINDOW_HEIGHT, NULL); if (!ecore_evas) goto end; ecore_evas_callback_delete_request_set(ecore_evas, main_delete_request); // ecore_evas_callback_resize_set(ecore_evas, main_resize); ecore_evas_title_set(ecore_evas, "Evas Media Test Program"); // ecore_evas_name_class_set(ecore_evas, "evas_media_test", "main"); ecore_evas_show(ecore_evas); evas = ecore_evas_get(ecore_evas); bg = evas_object_rectangle_add(evas); evas_object_color_set(bg, 0x00, 0x00, 0x00, 0xff); evas_object_move(bg, 0, 0); evas_object_resize(bg, WINDOW_WIDTH, WINDOW_HEIGHT); evas_object_show(bg); video = emotion_object_add(evas); evas_object_move(video, 0, 0); evas_object_resize(video, WINDOW_WIDTH, WINDOW_HEIGHT); ret = emotion_object_init(video, "gstreamer"); if(ret != EINA_TRUE) { fprintf(stderr, "faild to emotion_object_init\n"); goto end; } ret = emotion_object_file_set(video, argv[1]); if(ret != EINA_TRUE) { fprintf(stderr, "emotion_object_file_set\n"); goto end; } emotion_object_play_set(video, EINA_TRUE); evas_object_show(video); m = evas_map_new(4); evas_map_util_points_populate_from_object(m, video); // 2d rotate // evas_map_util_rotate(m, 90, 0 + (WINDOW_WIDTH/2), 0 + (WINDOW_HEIGHT/2)); // 3d rotate //evas_map_util_3d_rotate(m, 10.0, 10.0, 0.0, 0, 0, 0); evas_object_map_set(video, m); evas_object_map_enable_set(video, EINA_TRUE); ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_cb, video); ecore_main_loop_begin(); end: if(ecore_evas) ecore_evas_free(ecore_evas); evas_map_free(m); emotion_shutdown(); ecore_evas_shutdown(); ecore_shutdown(); return 0; }
int main(int argc, const char *argv[]) { Ecore_Evas *ee; Evas *e; Evas_Object *bg, *em; const char *filename = NULL; const char *module = NULL; if (argc < 2) { printf("At least one argument is necessary. Usage:\n"); printf("\t%s <filename> [module_name]\n", argv[0]); goto error; } filename = argv[1]; if (argc >= 3) module = argv[2]; if (!ecore_evas_init()) return EXIT_FAILURE; /* this will give you a window with an Evas canvas under the first * engine available */ ee = ecore_evas_new(NULL, 10, 10, WIDTH, HEIGHT, NULL); if (!ee) goto error; ecore_evas_show(ee); /* the canvas pointer, de facto */ e = ecore_evas_get(ee); /* adding a background to this example */ bg = evas_object_rectangle_add(e); evas_object_name_set(bg, "our dear rectangle"); evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ evas_object_move(bg, 0, 0); /* at canvas' origin */ evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ evas_object_show(bg); /* Creating the emotion object */ em = emotion_object_add(e); /* Try to load the specified module - NULL for auto-discover */ if (!emotion_object_init(em, module)) fprintf(stderr, "Emotion: \"%s\" module could not be initialized.\n", module); _display_info(em); _setup_emotion_callbacks(em); if (!emotion_object_file_set(em, filename)) fprintf(stderr, "Emotion: Could not load the file \"%s\"\n", filename); evas_object_move(em, 0, 0); evas_object_resize(em, WIDTH, HEIGHT); evas_object_show(em); emotion_object_play_set(em, EINA_TRUE); ecore_main_loop_begin(); ecore_evas_free(ee); ecore_evas_shutdown(); return 0; ecore_evas_free(ee); error: ecore_evas_shutdown(); return -1; }