Languages

Menu
Sites
Language
File Path Issues

Hey all,

Creating a little widget application to get my feet wet with the platform

 

Purpose of widget is to click a button and play a wav file

simple right?

I got soo spoiled programming in python

Anyway

Im encountering 2 problems

I am unable to create the correct path for the wav file

here is my code below

 

void
playWAV()
{
   int wav_player_id;
   wav_player_error_e ret;
   const char* wav_path = app_get_resource_path() + "failVio.wav";

   ret = wav_player_start(wav_path, SOUND_TYPE_MEDIA, _playback_completed_cb, (void*)wav_path, &wav_player_id);
}

 

Error is Description    Resource    Path    Location    Type
invalid operands to binary expression ('char *' and 'char *')    worldssmallestviolin.c    /WorldsSmallestViolin/src    line 29    C/C++ Problem

Which i think is an issue with typecasting but im a bit fuzzy

 

2nd issue

Trying to create a button with an icon

/*Create Button in GUI*/
    wid->button = elm_button_add(wid->conform);
    /*elm_object_text_set(wid->button, "Click me");*/
    wid->icon = elm_icon_add(wid->button);
    elm_image_file_set(wid->icon, "icon.png", NULL);
    elm_object_part_content_set(wid->button, "icon", wid->icon);
    evas_object_resize(wid->button, w, h);

    evas_object_smart_callback_add(wid->button, "clicked", _button_click_cb, NULL);
    evas_object_show(wid->button);

 

I first created a button with text which worked just fine but when i comment out the text line and add the api tutorial button code to add an icon i get a blank screen

 

BTW does anyone have a full working wigdet project they would be willing to share?  I do best when i can see a full project rather than snippets

Thansk for the help all!!

 

 

 

 

 

Responses

2 Replies
Jiwon Kim

I think it's better.

1st :

const char* wav_path = app_get_resource_path() + "failVio.wav";

-> #include <glib.h>

    char *res_path = app_get_resource_path();
    char *wav_path = g_strconcat(res_path, "/", "failVio.wav", NULL);
    free(res_path); // memory free is important!!

    // memory of wav_path also should be released after use in callback.

 

2nd :

elm_image_file_set(wid->icon, "icon.png", NULL);

-> #include <glib.h>

    char *res_path = app_get_resource_path();
    char *icon_path = g_strconcat(res_path, "/", "failVio.wav", NULL);
    free(res_path); // memory free is important!!

    elm_image_file_set(wid->icon, icon_path, NULL);
    free(icon_path);

 

tim budney

Thanks for the response!

Ok lets see if i understand this before i do a blind copy past

g_strconcat() - used to put a string and a char together and return a char? forced typecasting correct?

 

free (res_path) releases memory when complete right?

i see - same problem as above.  Ok feel better now going to take another stab!!