08-25-2009 11:11 AM
Hi All,
I wanna play the song through streaming.
I wanna play audio File. But instead of connection with the specific file. I wanna pass the array of bytes directly to the stream,and then play those bytes to the players.
How can I achieve this ?
Solved! Go to Solution.
08-26-2009 09:07 AM - edited 08-26-2009 09:08 AM
Hi,
I wanna play audio player, directly by passing array of bytes...
08-26-2009 09:19 AM
Having direct experience, I can tell you that the streaming API is broken (not functional) in OS versions prior to 4.3. I believe somewhere after 4.3 they enabled streaming and I know for certain that its available in 4.5. So the first thing you'll need t odo is upgrade beyond 4.3 if you haven't already. Next you can try invoking the J2ME MMAPI call that accepts an input stream and see if that works. I haven't tried this yet but I'm planning on doing so. Post back on your progress cause I'd love to know how well and on which devices this works. Here's the API call you'll want to look at:
javax.microedition.media.Player player = javax.microedition.media.Manager.createPlayer(getA
08-26-2009 01:00 PM
You can always use a custom DataSource class. It works with all OS versions.
Rab
08-26-2009 01:11 PM
08-27-2009 01:00 AM
ByteArrayInputStream in2 = null; try { FileConnection fileConnection = (FileConnection)Connector.open("file:///SDCard/Bla
ckberry/music/1.wav", Connector.READ ); InputStream inputStream = fileConnection.openDataInputStream(); byte[] audioData = new byte[(int)fileConnection.fileSize()]; inputStream.read(audioData,0,audioData.length); { in2 = new ByteArrayInputStream(audioData); } } catch (Exception ex) { System.err.println("Error open file connection."+ex.toString()); } secondPlayer = javax.microedition.media.Manager.createPlayer((Inp utStream)in2, "audio/wav"); // secondPlayer.addPlayerListener(this); secondPlayer.realize(); secondVolumeControl = getVolumeControl(secondPlayer); if (secondVolumeControl != null) secondVolumeControl.setLevel(90); secondPlayer.prefetch(); secondPlayer.start();
thanks every one, finally i found the solution.It is possible by taking the ByteArrayInputStream, and passing the array of bytes of any wave file.But the array of bytes should be in the proper sequence as it store in the Wave File.
Thanks all...
08-27-2009 10:38 AM
08-27-2009 01:41 PM
Just one remark:
this solution ( if I am not mistaken ) requires the entire file to be downloaded before starting the player.
The solution using the DataSource will allow you to play while downloading.
Rab
08-31-2009 02:47 PM
09-01-2009 01:16 AM
Hi,
If possible, then, may you plz explain more clearly ?