()
| 48 | } |
| 49 | |
| 50 | private int init() { |
| 51 | try { |
| 52 | fis = new FileInputStream(mp3file); |
| 53 | } catch (FileNotFoundException e) { |
| 54 | Com.DPrintf("MP3 Player File: " + mp3file +" failed to open.\n"); |
| 55 | return -1; |
| 56 | } |
| 57 | |
| 58 | bis = new BufferedInputStream (fis); |
| 59 | bs = new Bitstream (bis); |
| 60 | |
| 61 | try { |
| 62 | player = new Player(bis); |
| 63 | } catch (JavaLayerException e1) { |
| 64 | Com.DPrintf("MP3 Player failed to initialize player.\n"); |
| 65 | return -1; |
| 66 | } |
| 67 | |
| 68 | try { |
| 69 | totalbytes = fis.available(); |
| 70 | } catch (IOException e1) { |
| 71 | Com.DPrintf("MP3 Player failed to initialize totalbytes.\n"); |
| 72 | } // bytes |
| 73 | |
| 74 | totallength = player.getPosition(); // milliseconds |
| 75 | iscomplete = false; |
| 76 | InputStream id3in = bs.getRawID3v2(); |
| 77 | |
| 78 | if (id3in != null) { |
| 79 | BufferedInputStream id3 = new BufferedInputStream (id3in); |
| 80 | |
| 81 | StringBuffer id3out = new StringBuffer (); |
| 82 | |
| 83 | int _char; |
| 84 | try { |
| 85 | while ((_char = id3.read())!=-1) |
| 86 | id3out.append((char)_char); |
| 87 | } catch (IOException e) { |
| 88 | Com.DPrintf("MP3 player id3out.append failed\n"); |
| 89 | } |
| 90 | |
| 91 | try { |
| 92 | id3.close(); |
| 93 | } catch (IOException e) { |
| 94 | Com.DPrintf("MP3 player id3.close failed\n"); |
| 95 | } |
| 96 | id3v2 = id3out.toString(); |
| 97 | } else |
| 98 | id3v2 = ""; |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | public boolean isComplete() { |
| 103 | if (iscomplete == true) |
no test coverage detected