Page Example

Metadata-editor Sample Overview

Mobile native

The Metadata Editor sample application demonstrates how to retrieve and modify metadata using the Metadata Editor API.

The following figure illustrates the main view of the Metadata Editor application.

Figure: Metadata Editor screen

Metadata Editor screen

Prerequisites

To ensure proper application execution, the following privilege must be set:

  • http://tizen.org/privilege/mediastorage

Implementation

To get and update the metadata information in the media file:

  1. Get the metadata using the input path in the get_clicked_cb() function. Each parameter sets a text box to display.
    static 
    void get_clicked_cb(void *data, Evas_Object *obj, void *event_info)
    {
       ret = metadata_editor_create(&metadata);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
       snprintf(full_path, sizeof(full_path), "%s/%s", media_path, elm_object_text_get(t_path));
       ret = metadata_editor_set_path(metadata, full_path);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
    
       ret = metadata_editor_get_metadata(metadata, METADATA_EDITOR_ATTR_ARTIST, &artist);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
       elm_object_text_set(item_artist, artist);
       ret = metadata_editor_get_metadata(metadata, METADATA_EDITOR_ATTR_TITLE, &title);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
       metadata_editor_destroy(metadata);
    }
    
  2. Update the metadata.

    The user can change the metadata parameters by clicking on an item and adding new data. When they have modified the metadata, they click the Update Metadata button, which calls the update_clicked_cb() function.

    {
       ret = metadata_editor_create(&metadata);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
       snprintf(full_path, sizeof(full_path), "%s/%s", media_path, elm_object_text_get(t_path));
       ret = metadata_editor_set_path(metadata, full_path);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
    
       if (media_path) 
       {
          free(media_path);
          media_path = NULL;
       }
    
       ret = metadata_editor_set_metadata(metadata, METADATA_EDITOR_ATTR_ARTIST, elm_object_text_get(item_artist));
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
    
       ret = metadata_editor_update_metadata(metadata);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
       ret = metadata_editor_destroy(metadata);
       if (ret != METADATA_EDITOR_ERROR_NONE) 
       {
          err_popup(ret);
    
          return;
       }
    }