Java equivalent of C# system.beep?

后端 未结 8 1362
半阙折子戏
半阙折子戏 2021-01-01 10:31

I am working on a Java program, and I really need to be able to play a sound by a certain frequency and duration, similarly to the c# method System.Beep, I know how to use i

8条回答
  •  一个人的身影
    2021-01-01 10:57

    I don't think there's a way to play tunes1 with "beep" in portable2 Java. You'll need to use the javax.sound.* APIs I think ... unless you can find a third-party library that simplifies things for you.

    If you want to go down this path, then this page might give you some ideas.


    1 - Unless your users are all tone-deaf. Of course you can do things like beeping in Morse code ... but that's not a tune.

    2 - Obviously, you could make native calls to a Windows beep function. But that would not be portable.

提交回复
热议问题