Audio streaming. Restore playback position after lose internet connection

ilya.shknaj ilya.shknaj at gmail.com
Wed May 28 07:10:57 PDT 2014


Hello. I am new in gstreamer.
I want use gstreamer for play music from internet. If user lost connection i
want restore play from previous position, when connection restored, but if i
call play, audio start playing from start, not from prev position.

part my code. 

static void gst_native_play (JNIEnv* env, jobject thiz) {
  CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
  if (!data) return;
  GST_DEBUG ("Setting state to PLAYING");
  data->target_state = GST_STATE_PLAYING;
  data->is_live = (gst_element_set_state (data->pipeline, GST_STATE_PLAYING)
== GST_STATE_CHANGE_NO_PREROLL);
}

void gst_native_set_uri (JNIEnv* env, jobject thiz, jstring uri) {
  GST_DEBUG ("Call gst_native_set_uri");
  CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
  if (!data || !data->pipeline) return;
  const jbyte *char_uri = (*env)->GetStringUTFChars (env, uri, NULL);
  GST_DEBUG ("Setting URI to %s", char_uri);
  if (data->target_state >= GST_STATE_READY)
    gst_element_set_state (data->pipeline, GST_STATE_READY);
  g_object_set(data->pipeline, "uri", char_uri, NULL);
  (*env)->ReleaseStringUTFChars (env, uri, char_uri);
  data->duration = GST_CLOCK_TIME_NONE;
  data->is_live = (gst_element_set_state (data->pipeline,
data->target_state) == GST_STATE_CHANGE_NO_PREROLL);
}

static void *app_function (void *userdata) {
  ...
  data->pipeline = gst_parse_launch("playbin buffer-size=8192", &error);

}

from java 
...
native_set_uri("http://...");
native_play();

when connection restored
...
native_play();



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Audio-streaming-Restore-playback-position-after-lose-internet-connection-tp4667244.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list