Giriş
Şu satırı dahil ederiz.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
Açıklaması şöyle
If you need to embed a media player into your Java desktop application, there are several options for this:1. You can use JavaFX Media API to implement all the required media player functionality as shown in this example.2. A bit outdated but still functional Java Media Framework can be a solution.3. You can integrate a third-party Java library like VLCJ which wraps the functionality of a native media player.
Açıklaması şöyle
The JavaFX Media API approach is cross-platform and can be used on Windows, Linux, and macOS. It works well for JavaFX. However, if you use Swing or SWT, you will need the bridges such as JFXPanel and FXCanvas.
constructor - Media
Media sound = new Media(getClass().getResource("/Audio/Paddle.m4a").toString());
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.play();
play metoduŞöyle yaparız.
String bip = "bip.mp3";
Media hit = new Media(new File(bip).toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(hit);
mediaPlayer.play();
setAutoPlay metodu
Şöyle yaparız.
Media media = new Media(getClass().getResource("1-1.mp4").toString());
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
mediaPlayer.setRate(1.25);
mediaPlayer.setMute(true);
Hiç yorum yok:
Yorum Gönder