10

I'm trying to play audio from Url, using the below code:

            String url = "1451739079.mp3";
            MediaPlayer player = new MediaPlayer();
            player.setAudioStreamType(AudioManager.STREAM_MUSIC);
            try {
                player.setDataSource(url);
            }catch (IOException e){
                e.printStackTrace();
            }
            player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    mp.start();
                }
            });

But this is not at all working, showing error in logcat as:

   E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present

I've already visited this SO post, but of no help.

Please suggest how to play audio from Url?

Community
  • 1
  • 1
pratiti-systematix
  • 792
  • 11
  • 28
  • 1
    Possible duplicate of [Why MediaPlayer throws NOT present error when creating instance of it?](http://stackoverflow.com/questions/24501086/why-mediaplayer-throws-not-present-error-when-creating-instance-of-it)? Since the answer is given there. – se_bastiaan Jan 12 '16 at 10:57
  • Yeah, I already mentioned visiting that link....but of no help – pratiti-systematix Jan 12 '16 at 10:58
  • > It means your platform does not support QCMediaPlayer. Although, I'm not completely sure that your url is correct in any way. Try playing a correct http url. – se_bastiaan Jan 12 '16 at 10:59
  • okay, but then, how can I play media from Url? – pratiti-systematix Jan 12 '16 at 10:59
  • So your question is not what the error means as I first understood, rather how you should do this? Try to rephrase your question. And try replacing 1451739079.mp3 by https://archive.org/download/testmp3testfile/mpthreetest.mp3, since that first url that you have is pointing to nowhere. – se_bastiaan Jan 12 '16 at 11:03
  • Yeah, that's what I asked for, check the last line of my post. The url link is just for sample, I'm using a well-formed url, which is working fine on browser. – pratiti-systematix Jan 12 '16 at 11:05

0 Answers0