Code:FileConnection fileConnection = (FileConnection) Connector.open(absolutePath); //absolutePath = file:///C:/Data/Sounds/test.mp4 InputStream inputStream = fileConnection.openInputStream(); byte [] fileBytes = new byte [((int) fileConnection.fileSize())]; int totalBytesRead = 0; int fileSize = fileBytes.length; int bytesRead = 0; while(totalBytesRead < fileSize){ bytesRead = inputStream.read(fileBytes, totalBytesRead, fileSize); totalBytesRead += bytesRead; } System.out.println("total bytes read: " + totalBytesRead); System.out.println("file size: " + fileSize); inputStream.close(); InputStream inStream = new ByteArrayInputStream(fileBytes); System.out.println("inStream OK"); Player player = Manager.createPlayer(inStream, "video/mp4"); System.out.println("Player OK"); fileConnection.close();
the code above throws the Exception: javax.microedition.media.MediaException: Could not create player.
the print outs:
im trying to use it to create a Player Object with a video mp4 file. this same code works for music files...total bytes read: 8939164
file size: 8939164
inStream OK
Exception e: javax.microedition.media.MediaException: Could not create player.
in addition, when i tried
it works. so, why i cant use an InputStream to do it? how can i fix it?Code:Player player = Manager.createPlayer(absolutePath);

Reply With Quote


