Java stream mp3 from bytes
How to stream mp3 from bytes ? I'm getting the bytes from a file, but then how to start the sound ?
File file = new File(a);
FileInputStream fin = new FileInputStream(file);
开发者_Python百科 byte get_inside[] = new byte[(int)file.length()];
System.out.println(Integer.toBinaryString(fin.read(get_inside)));
This is the sample code of byte getting and the a is the file .
You should use the Java Sound API or the Java Media Framework. See the tutorial for an example of the Java Sound API.
Note that you shouldn't just call InputStream.read
once and assume you'll get the complete data, by the way - regardless of whether this is an MP3 or not.
You might be interested in my pure Java mp3 player: mp3transform.
精彩评论