This site requires JavaScript, please enable it in your browser!
Greenfoot back
vessaliuzz
vessaliuzz wrote ...

2015/6/26

how to loop sound smoothly

vessaliuzz vessaliuzz

2015/6/26

#
this my class mulai, contain sound that i want to play and loop public mulai() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1,false); prepare(); play(); loop(); } private void prepare(){ //fungsi untuk menyiapkan objek untuk ditampilkan BtnMulai btnMulai = new BtnMulai(); BtnPetunjuk btnPetunjuk = new BtnPetunjuk(); BtnCredit btnCredit = new BtnCredit(); BtnKeluar btnKeluar = new BtnKeluar(); Volume volume = new Volume(); addObject(btnMulai, 310, 170);//menambahkan objek btnMulai pada world addObject(btnPetunjuk, 310, 230);//menambahkan objek btnMulai pada world addObject(btnCredit,310,290); addObject(btnKeluar, 310,350); addObject(volume, 30,30); } GreenfootSound music = new GreenfootSound("dirdiran.mp3"); public void play() { music.play(); } public void loop() { music.playLoop(); } public void stop() { music.stop(); } } and this my mute button */ public class Volume extends Actor { private boolean isMuted; public void act() { if(Greenfoot.mouseClicked(this)){ isMuted = !isMuted; updateState(); } } private void updateState() { if(isMuted) { setImage("muted.png"); mulai world = (mulai) getWorld(); world.music.stop(); } else { setImage("fullVolume.png"); mulai world = (mulai) getWorld(); world.music.playLoop(); } } and it error when song is ended. the error line like this Exception in thread "SoundStream:file:/D:/kapeh/marbles/sounds/dirdiran.mp3" java.lang.ArrayIndexOutOfBoundsException: 580 at javazoom.jl.decoder.LayerIIIDecoder.huffman_decode(LayerIIIDecoder.java:795) at javazoom.jl.decoder.LayerIIIDecoder.decode(LayerIIIDecoder.java:278) at javazoom.jl.decoder.LayerIIIDecoder.decodeFrame(LayerIIIDecoder.java:219) at javazoom.jl.decoder.Decoder.decodeFrame(Decoder.java:147) at greenfoot.sound.Mp3AudioInputStream.read(Mp3AudioInputStream.java:230) at greenfoot.sound.SoundStream.run(SoundStream.java:302) at java.lang.Thread.run(Thread.java:745)
danpost danpost

2015/6/26

#
The information tags within your 'mp3' files are not handled well with greenfoot. Re-save the file without them.
vessaliuzz vessaliuzz

2015/6/30

#
oooo, i see, i changed song with wav format, it's loop. thanks dude
You need to login to post a reply.