來源:寧靜志遠 淡泊明志
昨天在QQ群上有人問題使用APPLET播放WAV的事情,自己還真沒有使用java 寫過多媒體處理,在網上找了一下相關的文章,有提到JMF框架的,於是找來安裝一下,沒有深入的研究JMF,初步覺得,使用方便,但是同時也給運行環境增加額外的負擔。
然後看到《用Java實現音頻播放》這篇文章,文章沒有作者信息,但是可以在天極找到原文。如有需要可以根據下邊的鏈接找到文章。
文章對javax.sound包的結構作了深入的講解,而且為MP3解碼提供的解決方案。最後介紹了一個簡單播放器的開發,因為篇幅,作者沒有把完 整的代碼送上,我仿照作者的思路,寫了個簡單的播放WAV文件的代碼,撇開複雜的線程,目的在展示播放WAV文件的實現代碼上。綿薄的功夫而已。
源代碼













































































































需要指出的
需要指出的一點是,
DataLine.Info info=new DataLine.Info(SourceDataLine.class,af);
sdl=(SourceDataLine) AudioSystem.getLine(info);
sdl.open(af);
sdl.start();
sourceDataLine在被寫入前需要被打開" sdl.start();" 這點作者沒有說明。
0 留言:
張貼留言