03-13-2009 09:39 PM
Hi,
I'm getting the following debug log when playing some WAV files from different URLs in a loop. I read the WAV files first using ByteArrayOutputStream and then call the javax.microedition.media.Player on each stream, any help would be appreciated! Note that the files are actually being played fine, albeit with large delay in between:
--------------------------------------------------
[STREAM] allocating big buffer [index: 0] [numStreams: 0]
[STREAM] allocating stream [index: 0] [size: 327680]
[STREAM] allocated stream [index: 0] [handle: 1799] [size: 327680]
SMP
treaming session aquired id=1799
MN: init0(0)=0
MN: load 0
AUDIOMANAGER: IOException
+++mediaError():MEDIA_LOADING (net.rim.device.internal.media.MediaPlayer@cea8aca3
+++unloadCleanup():MEDIA_LOADING (net.rim.device.internal.media.MediaPlayer@cea8aca3
MEDIA_PLAYER(-1): Setting state to:MEDIA_UNLOADED (net.rim.device.internal.media.MediaPlayer@cea8aca3) from:MEDIA_LOADING (net.rim.device.internal.media.MediaPlayer@cea8aca3
---unloadCleanup():MEDIA_UNLOADED (net.rim.device.internal.media.MediaPlayer@cea8aca3
---mediaError():MEDIA_UNLOADED (net.rim.device.internal.media.MediaPlayer@cea8aca3
Error initializing media, state is not MEDIA_LOADED: MEDIA_UNLOADED (net.rim.device.internal.media.MediaPlayer@cea8aca3
inside play loooooooop: Error initializing media.
Streaming done reason=1 prev-state=300
SMP
treaming session aquired id=1799
MN: init0(16777216)=0
MN: load 1
AUDIOMANAGER: IOException
+++mediaError():MEDIA_LOADING (net.rim.device.internal.media.MediaPlayer@231ab4b0
+++unloadCleanup():MEDIA_LOADING (net.rim.device.internal.media.MediaPlayer@231ab4b0
--------------------------------------------------
03-13-2009 10:03 PM
03-13-2009 10:23 PM
Hi Andrew,
Sure you can, here it is,
Thanks!
Udi
--------------------------------------------------
for (int mCount = loginId.length - 1; mCount >= 0; mCount--) {
try {
String murl = new String("http://192.168.0.111:8080/examples/jsp/msg-" + Integer.toString(mCount) + ".wav");
//String murl = new String("http://192.168.0.111:8080/examples/jsp/msg-0.wav");
// Open connection to the http url...
HttpConnection connection = (HttpConnection) Connector.open(murl);
DataInputStream dataIn = connection.openDataInputStream();
//byte[] buffer = new byte[1000];
byte[] buffer = new byte[1024];
int read = -1;
int lk = 0;
// Read the content from url.
ByteArrayOutputStream byteout = new ByteArrayOutputStream();
while ((read=dataIn.read(buffer))>=0) {
lk++;
byteout.write(buffer, 0, read);
}
dataIn.close();
connection.close();
// Fill InputStream to return with content read from the URL.
ByteArrayInputStream byteIn =
new ByteArrayInputStream(byteout.toByteArray());
HttpConnection conn = (HttpConnection) Connector.open(murl, Connector.READ_WRITE);
javax.microedition.media.Player player =
javax.microedition.media.Manager.createPlayer(byte
player.realize();
player.prefetch();
player.start();
while(player.getState() != 300) {
System.out.println("plaaaaaaaaaaaaaaaaaaatying ..... status: " + player.getState());
Thread.sleep(500);;
}
player.stop();
player.deallocate();
player.close();
byteIn.close();
Thread.sleep(1000);
System.gc();
}
catch(Exception e) {
System.out.println("inside play loooooooop: " + e.getMessage());
}
}
--------------------------------------------------
03-19-2009 10:37 AM
03-02-2010 04:48 AM
Hi,
I am also stuck with the same issue.. I tested my application on both 9000 device simulator with 4.6 os and 9630 device simulator with 4.7.1 os.
I get the same trace of statements in the console during execution.
Please help me out..
Thanks, raju.
03-02-2010 09:28 AM
I would write the file to the SDCard and see if it would be opened with the media player that came with the device. I have the same code (almost) working. Except that I create input stream to the player instead of from a http connection.
03-03-2010 12:45 AM
Hi Aviator, Nice to see ur reply...
Can't we stream the file instead of saving the file onto the SD Card.
The BufferedPlayblackdemo sample has not worked either on the simulators 9000 and 9630.