Question: When executing:

```
path=os.path.dirname(__file__)+'/log.txt'
log=open(path,"w",encoding='utf-8')

```

I get:

```
log=open(path,'w',encoding='utf-8')
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1203, in __init__
raise IOError('invalid mode: %s' % mode)
IOError: invalid mode: w

```

I'm not sure why I can't write to the file?

Answer: 
There is no [documented method](http://developer.android.com/reference/android/media/MediaPlayer.html) for getting info on the currently playing file from a MediaPlayer instance, you'll need to make your app store that information itself in another way. If you're using a Service to keep track of your MediaPlayer instance (which I'd recommend) then this shouldn't be too hard.
I learned how to do it just now, so I don't know if it works on all versions of android yet. 

```
private void getTrackInfo(Uri audioFileUri) {
    MediaMetadataRetriever metaRetriever= new MediaMetadataRetriever();
    metaRetriever.setDataSource(getRealPathFromURI(audioFileUri));
    String artist = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
    String title = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);

}

private String getRealPathFromURI(Uri uri) {
    File myFile = new File(uri.getPath().toString());
    String s = myFile.getAbsolutePath();
    return s;
}

```