static void relative_seek (GstPlay * play, gdouble percent) { gint64 dur = -1, pos = -1; g_return_if_fail (percent >= -1.0 && percent <= 1.0); g_object_get (play->player, "position", &pos, "duration", &dur, NULL); if (dur <= 0) goto seek_failed; pos = pos + dur * percent; if (pos > dur) { if (!play_next (play)) { g_print ("\nReached end of play list.\n"); g_main_loop_quit (play->loop); } } else { if (pos < 0) pos = 0; gst_player_seek (play->player, pos); } return; seek_failed: { g_print ("\nCould not seek.\n"); } }
static void native_seek (JNIEnv * env, jobject thiz, jlong position) { Player *player = GET_CUSTOM_DATA (env, thiz, native_player_field_id); if (!player) return; gst_player_seek (player->player, position); }
static void relative_seek (GstPlay * play, gdouble percent) { gint64 dur = -1, pos = -1; g_return_if_fail (percent >= -1.0 && percent <= 1.0); g_object_get (play->player, "position", &pos, "duration", &dur, NULL); if (dur <= 0) { g_print ("\nCould not seek.\n"); return; } pos = pos + dur * percent; if (pos < 0) pos = 0; gst_player_seek (play->player, pos); }