Esempio n. 1
0
void
my_object_change_uri (SnappyMP * myobj, gchar * uri)
{
  if (myobj != NULL)
    myobj->uri = uri;

  engine_open_uri (myobj->engine, uri);
  interface_load_uri (myobj->ui, uri);
  engine_play (myobj->engine);
}
Esempio n. 2
0
static VALUE roscil_pulse(VALUE obj, VALUE freq)
{
    PaStreamParameters *sp;
    int i;
    waveData *dp;

    Need_Float(freq);

    dp = (waveData *)malloc(sizeof(waveData));
    set_pulse_data(dp);
    dp->freq = NUM2DBL(freq);

    sp = (PaStreamParameters *)malloc(sizeof(PaStreamParameters));
    sp->hostApiSpecificStreamInfo = NULL;

    engine_start(sp);
    engine_play(sp, dp);
    engine_end();
}
Esempio n. 3
0
void
handle_method_call (GDBusConnection * connection,
    const gchar * sender,
    const gchar * object_path,
    const gchar * interface_name,
    const gchar * method_name,
    GVariant * parameters, GDBusMethodInvocation * invocation, SnappyMP * myobj)
{
  gboolean ret = TRUE;
  GError *error = NULL;

  if (g_strcmp0 (object_path, MPRIS_OBJECT_NAME) != 0 ||
      g_strcmp0 (interface_name, MPRIS_PLAYER_INTERFACE) != 0) {
    g_dbus_method_invocation_return_error (invocation,
        G_DBUS_ERROR,
        G_DBUS_ERROR_NOT_SUPPORTED,
        "Method %s.%s not supported", interface_name, method_name);
    return;
  }

  if (g_strcmp0 (method_name, "OpenUri") == 0) {
    gchar *uri;

    // g_print ("openUri.. uri: %s\n", uri);
    g_variant_get (parameters, "(s)", &uri);
    my_object_change_uri (myobj, uri);

    g_dbus_method_invocation_return_value (invocation, NULL);

  } else if (g_strcmp0 (method_name, "Next") == 0) {
    /// ToDo: next track call

    handle_result (invocation, ret, error);

  } else if (g_strcmp0 (method_name, "Play") == 0) {
    engine_play (myobj->engine);

    handle_result (invocation, ret, error);

  } else if (g_strcmp0 (method_name, "Pause") == 0) {
    change_state (myobj->engine, "Paused");

    handle_result (invocation, ret, error);
  } else if (g_strcmp0 (method_name, "Stop") == 0) {
    engine_stop (myobj->engine);

    handle_result (invocation, ret, error);

  } else if (g_strcmp0 (method_name, "Seek") == 0) {
    gint64 offset, position;
    gfloat relative;

    g_variant_get (parameters, "(x)", &offset);
    relative = offset / 100000000.0;
    position = myobj->engine->media_duration * relative;
    // g_print ("offset: %ld    relative: %f", offset, relative);
    engine_seek (myobj->engine, position, FALSE);

    handle_result (invocation, ret, error);

  }
}