CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2000
    Posts
    4

    how to play a *.midi files in loop??? urgent!!!

    In less than 5H i have to give back to my teacher a java application game that i juste have finished but.....i have to play a files.midi in loop and i don't know the easiest way to proceed.....( i'm a beginner so please.....i need detailed feedback.....thnaks.)


  2. #2
    Join Date
    Mar 2000
    Location
    Portland, OR, USA
    Posts
    41

    Re: how to play a *.midi files in loop??? urgent!!!

    Try this way:


    import java.applet.*;
    import java.net.*;

    public class MidiLoop extends Applet
    {
    // use your MIDI file name here:
    protected final String SOUND_FILE_NAME = "littlecz.mid";

    // applet entry point
    public void init()
    {
    // ... any operators
    try
    {
    // compose URL path to your midi file
    URL url = new URL(getCodeBase(), SOUND_FILE_NAME);
    // get audio clip reference
    AudioClip audioClip = this.getAudioClip(url);
    // play clip in infinite loop
    audioClip.loop();
    }
    catch(MalformedURLException ex)
    {
    System.out.println("can't load sound file");
    }

    // ...
    }
    }








Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured