//Set the media progress rate void eclair_progress_rate_set(Eclair *eclair, double progress_rate) { if (!eclair || !eclair->video.video_object) return; eclair_position_set(eclair, progress_rate * emotion_object_play_length_get(eclair->video.video_object)); }
//Get the media progress rate double eclair_progress_rate_get(Eclair *eclair) { if (!eclair || !eclair->video.video_object) return 0.0; return (eclair_position_get(eclair) / emotion_object_play_length_get(eclair->video.video_object)); }
//Update text objects, progress bar... //Called when an new frame is decoded void eclair_update(Eclair *eclair) { char time_elapsed[10]; double position, length; if (!eclair) return; position = eclair_position_get(eclair); //Display subtitles eclair_subtitles_display_current_subtitle(&eclair->subtitles, eclair_position_get(eclair), eclair->video.subtitles_object); if (!eclair->video.video_object || !eclair->gui_window) return; //Update time text length = emotion_object_play_length_get(eclair->video.video_object); if (eclair->use_progress_bar_drag_for_time) { edje_object_part_drag_value_get(eclair->gui_window->edje_object, "progress_bar_drag", &position, NULL); position *= length; } eclair_utils_second_to_string(position, length, time_elapsed); eclair_all_windows_text_set(eclair, "time_elapsed", time_elapsed); //Update progress bar if (eclair->dont_update_progressbar) eclair->dont_update_progressbar = 0; else if (eclair->seek_to_pos >= 0.0) eclair->seek_to_pos = -1.0; edje_object_part_drag_value_set(eclair->gui_window->edje_object, "progress_bar_drag", position / length, 0.0); }
//Set the media position in seconds void eclair_position_set(Eclair *eclair, double position) { double media_length; if (!eclair || !eclair->video.video_object) return; media_length = emotion_object_play_length_get(eclair->video.video_object); if (position < 0.0) position = 0.0; else if (position > media_length) position = media_length; eclair->dont_update_progressbar = 1; eclair->seek_to_pos = position; emotion_object_position_set(eclair->video.video_object, eclair->seek_to_pos); }
static void _display_info(Evas_Object *o) { int w, h; printf("playing: %d\n", emotion_object_play_get(o)); printf("meta title: %s\n", emotion_object_meta_info_get(o, EMOTION_META_INFO_TRACK_TITLE)); printf("seek position: %0.3f\n", emotion_object_position_get(o)); printf("play length: %0.3f\n", emotion_object_play_length_get(o)); printf("is seekable: %d\n", emotion_object_seekable_get(o)); emotion_object_size_get(o, &w, &h); printf("video geometry: %dx%d\n", w, h); printf("video width / height ratio: %0.3f\n", emotion_object_ratio_get(o)); printf("\n"); }
static void dvb_obj_frame_decode_cb(void *data, Evas_Object *obj, void *event_info) { double pos, len; char buf[256]; int ph, pm, ps, pf, lh, lm, ls; pos = emotion_object_position_get(obj); len = emotion_object_play_length_get(obj); lh = len / 3600; lm = len / 60 - (lh * 60); ls = len - ((lh * 3600) + (lm * 60)); ph = pos / 3600; pm = pos / 60 - (ph * 60); ps = pos - ((ph * 3600) + (pm * 60)); pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100); snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i", ph, pm, ps, pf, lh, lm, ls); // edje_object_part_text_set(o_dvb_bg, "position", buf); }
static void _win_play_eval(Win *w) { Edje_Message_Float_Set *mf; w->play.position = emotion_object_position_get(w->emotion); w->play.length = emotion_object_play_length_get(w->emotion); if ((w->song) && (w->song->length != (int)w->play.length)) db_song_length_set(w->db, w->song, w->play.length); mf = alloca(sizeof(Edje_Message_Float_Set) + sizeof(double)); mf->count = 2; mf->val[0] = w->play.position; mf->val[1] = w->play.length; edje_object_message_send(elm_layout_edje_get(w->nowplaying), EDJE_MESSAGE_FLOAT_SET, MSG_POSITION, mf); if (w->play.playing_last == w->play.playing) return; w->play.playing_last = !w->play.playing; _win_play_pause_toggle(w); ecore_event_add(ENJOY_EVENT_PLAYER_CAPS_CHANGE, NULL, NULL, NULL); }
_emotion_position_update_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { Enna_View_Player_Video_Data *priv = data; Evas_Object *emotion; Evas_Object *edje; double v; time_t timestamp; struct tm *t; Eina_Strbuf *str; emotion = elm_video_emotion_get(priv->video); _update_time_part(priv->layout, "time_current.text", emotion_object_position_get(emotion)); _update_time_part(priv->layout, "time_duration.text", emotion_object_play_length_get(emotion)); timestamp = time(NULL); timestamp += emotion_object_play_length_get(emotion) - emotion_object_position_get(emotion); t = localtime(×tamp); str = eina_strbuf_new(); eina_strbuf_append_printf(str, "End at %02dh%02d", t->tm_hour, t->tm_min); elm_object_part_text_set(priv->layout, "time_end_at.text", eina_strbuf_string_get(str)); eina_strbuf_free(str); v = emotion_object_position_get(emotion) / emotion_object_play_length_get(emotion); edje = elm_layout_edje_get(priv->layout); edje_object_part_drag_value_set(edje, "time.slider", v, v);
double enna_mediaplayer_length_get(void) { return (mp->play_state == PAUSE || mp->play_state == PLAYING) ? emotion_object_play_length_get(mp->player) : 0.0; }
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); } }
static void _length_change_cb(void *data, Evas_Object *o, void *event_info) { fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o)); }