0

Mediaplayer is not streaming the right url. I think it's an issue with translation and compiling, but I am unsure.

http://translate.google.com/translate_tts?tl=zh-TW&q=大. This is the url I want it to stream. It includes the chinese character.

It's streaming something like http://translate.google.com/translate_tts?tl=zh-TW&q=a.

Here is a code snippet:

MediaPlayer mPlayer = new MediaPlayer();
try{

        mPlayer.setDataSource(url + chinese_array[0]);
        mPlayer.prepareAsync();

        Log.i("url", url + chinese_array[0]);

    }catch(Exception e){
        Log.e("mediaPlayer", e.toString());
    }

There are no logcat errors. The stream is just the wrong sound. I initialized the array by pulling from a sqlite database, so that the compiler won't have to compile any chinese - not that it can't.

The Log.i("url"... ) line yields the correct url, but the mediaplayer doesn't play the correct sound. It plays the sound of the below url, and I want the mp3 of the above url.

I've looked around for problems like this, but have not come across any similar questions.

Is there a work around? Why is the mediaplayer playing the wrong sound?

Thanks

ginsengtang
  • 751
  • 1
  • 7
  • 17

1 Answers1

0

I had this exact problem! Try using adding ie=UTF-8 to your URL. Specifically, http://www.translate.google.com/translate_tts?ie=utf-8&tl=zh-tw&q=大 That's what fixed it for me.

Edit Sketch of my implementation can be found here. I asked this question before and eventually figured it out myself after a LOT of fumbling. It was that ie=UTF-8 all along...

Community
  • 1
  • 1
Matter Cat
  • 1,538
  • 1
  • 14
  • 23