Problems playing streaming audio on Android Samsung Galaxy S

I just released my first Android app in my life. This is Audiko .

I found an error that occurs in the Samsung Galaxy S during an mp3 streaming file when I use Android MediaPlayer.

In the logs, I see the following:

E/PlayerDriver( 2747): PlayerDriver::it is a not Protected file E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl D/ ( 2747): PVFile::GetFileName E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl E/ ( 2747): IIIIIII Inside Constructor of PVMFMemoryBufferReadDataStreamImpl V/PlayerDriver( 2747): Completed command PLAYER_INIT status=-1 E/PlayerDriver( 2747): Command PLAYER_INIT completed with an error or info -1 E/MediaPlayer(13523): error (1, -1) E/MediaPlayer(13523): Error (1,-1) 

Any suggestions on what this could be?

+4
source share
2 answers

I had problems like this on some devices. Itโ€™s best to just temporarily download the file and play this version instead of streaming. That is, it will work if the ringtone is relatively small, which, I think, usually takes place.

0
source

I came across something very similar. I use Galaxy S2 for debugging and trying to play a direct radio stream, I got all kinds of errors and problems. The first thing you need to know is that since some devices support wma files (Windows Media Audio format), but Galaxy doesnโ€™t, unless you find a way to convert this stream to a playable stream, you have a problem.

The solution (view) I found for the problem is the following: since I read for a long time what you can do, instead of using MediaPlayer and try to use InputStream to in a straightforward way, read with audio (right now I only worked with Mp3, because, as I said , wma will not work), get a few seconds of audio in an mp3 file, and then use MediaPlayer to play this file locally, while re-buffering the next part of the sound in a second file, and then just play back and forth these files ( you can set the length of each file)

I leave you part of the code that I tried to implement and worked for buffering and playing mp3 on my phone, but I did not continue the project, but I have not yet found a resolution solution for wma.

 public void onClick(View v) { try { URL url = new URL("http://........./myStation.mp3"); InputStream inputStream = url.openStream(); long bytesRead = 0; File root = android.os.Environment.getExternalStorageDirectory(); File dir = new File (root.getAbsolutePath() + "/usbStorage"); if(dir.exists()== false) { dir.mkdirs(); } File outputSource = new File(dir, "test.mp3"); FileOutputStream fileOutputStream = new FileOutputStream(outputSource); //Log.d(LOG_TAG, "FileOutputStream: " + outputSource); int c; int howManyBytes = 12000; //You decide the amount of bytes to read because the live stream while keep on going forver while ((c = inputStream.read()) != 10000) { fileOutputStream.write(c); bytesRead++; if (bytesRead > howManyBytes) break; } fileOutputStream.close(); MediaPlayer mp = MediaPlayer.create(this, Uri.fromFile(outputSource)); mp.start(); // no need to call prepare(); create() does that for you } catch(Exception e) { Log.e("radio", e.getMessage()); } } 
0
source

Source: https://habr.com/ru/post/1338436/


All Articles