这个周末我再试一次,再次搜索,并从不同的网站一起搜索了一个工作代码,但没有一个完整的工作解决方案。
为了在未来的项目中使用更舒适,我为我做了一个小型的aac播放库。
由于很难找到合适的解决方案,我想与您分享,希望将来有一个问题相同的人会更轻松一点。
以下代码是我写的lib的片段。 您可以在AACPlayer上查看我的GitHub上的整个lib。
该lib /解决方案使用aac解码器JAAD 。
public static void play(File[] files) { // local vars byte[] b; // array for the actual audio Data during the playback AudioTrack track; // track we are playing atm AudioFormat af; // the track's format SourceDataLine line; // the line we'll use the get our audio to the speaker's Decoder dec; // decoder to get the audio bytes Frame frame; // SampleBuffer buf; // int currentTrack; // index of current track from playlist MP4Container cont; // container to open the current track with Movie movie; // and get the content from the container try { // for-next loop to play each titel from the playlist once for (currentTrack = 0; currentTrack < files.length; currentTrack++) { cont = new MP4Container(new RandomAccessFile(files[currentTrack], "r")); // open titel with random access movie = cont.getMovie(); // get content from container, List