The University of Queensland Homepage
UQ VisLab UQ VisLab

 BackgroundSound Example Code
401

Adding Sound
BackgroundSound Example Code


MediaContainer music = new MediaContainer( "canon.wav" );
. . .
TransformGroup group = new TransformGroup( );
. . .
BackgroundSound sound = new BackgroundSound( );
sound.setSoundData( music );
sound.setEnable( true ); // Start it playing
sound.setLoop( -1 );     // Loop forever
. . .
sound.setSchedulingBounds( bounds );
group.addChild( sound );