Javaでmp3ファイルを再生する方法を知っている人はいますか? 再生したい効果音が少しあります。これが私が持っているものです
import java.io.*;
import java.media.*;
File mp3Correct;
Player correct;
/* Load mp3 files */
mp3Correct = new File ("C:\\correct.mp3");
/* Create media players */
correct = Manager.createPlayer( mp3Correct.toURI() ); //<--error
/* Play the sound effect */
correct.start();
これはエラーメッセージです:
createPlayer(URI) に適したメソッドが見つかりません
method Manager.createPlayer(DataSource) is not applicable (actual argument URI cannot be converted to DataSource by method invocation conversion) method Manager.createPlayer(MediaLocator) is not applicable (actual argument URI cannot be converted to MediaLocator by method invocation conversion) method Manager.createPlayer(URL) is not applicable (actual argument URI cannot be converted to URL by method invocation conversion)
Javaのドキュメントによると、
Player を作成する最も簡単な方法は、URI 構文のロケーターから作成することです。ロケーターを指定すると、createPlayer は、ロケーターによって識別されたメディアの処理に適したプレーヤーを作成します。
しかし、私は自分が間違っていることを知りません。誰でも助けることができますか?ありがとうございました!