Hello,
I try to make an extension which give music artist nane from the file data.
I succed to do this in an android studio sketch,
but when i copy code to have an AI extension i have error:
"The operation Text cannot accept the arguments: , [nothing]"
Here is the code:
Blockquote
package jml.mp3tags;
import android.media.MediaMetadataRetriever;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.util.MediaUtil;
import java.io.File;
@DesignerComponent(version = Mp3Tags.VERSION,
description = "obtention des tags d'un mp3" + "jm latour ",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "icone/music.png")
@SimpleObject(external = true)
public class Mp3Tags extends AndroidNonvisibleComponent implements Component {
private ComponentContainer container;
public static final int VERSION = 1;
public static String fichier="";
//public class MetaExtractActivity extends Activity {
public Mp3Tags(ComponentContainer container) {
super(container.$form());
this.container = container;
//artist(fichier);
}
MediaMetadataRetriever metaRetriever;
@SimpleFunction(description = "return file's artist")
public String artist(String song){
File file=new File(song);
String art=song;
metaRetriever = new MediaMetadataRetriever();
if (file.exists()) {
metaRetriever.setDataSource(song);
try {
art=metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
//art="null";
} catch (Exception e) {
art="Unknown Artist";
}
}else {
art="file not found";
}
return art;
}
}
The problem comes from "art=metaRetriever.extractMetadata" wichc seems put nothing in variable art.
if i code art="null"; in this place code works and return "null"...