MediaException: MEDIA_UNAVAILABLE: G: \ 6 - Organ hockey music.mp3 (Cannot find the specified file) pops up with the https://yadi.sk/d/cd7Kmzma3Q2BWw file The code is very simple
File file = new File ("\ ... \ ..."); Media media = new Media (file); mistake. In the wilds of the Internet they talk about Code Point UTF - did not understand anything. I ask you for help.
|
1 answer
The file is fine. Try the following option to specify the path to the source:
import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.stage.Stage; import java.io.File; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { Button button = new Button("Play"); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File file = new File("C:/Users/UserName/Downloads/6 - Органная хоккейная музыка.mp3"); Media media = new Media(file.toURI().toASCIIString()); MediaPlayer player = new MediaPlayer(media); player.play(); } }); primaryStage.setScene(new Scene(button)); primaryStage.show(); } } |