import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.paint.Color;
import javafx.scene.media.*;
def vid = "
http://www.320sms.com/videos/Kung Fu Hustle[Eng]DVDRip-Benny~1.flv"; // CHANGE AS NEEDED
var isPlaying = false;
def myMediaPlayer = MediaPlayer {
media: Media {source: vid}
}
def myMediaView = MediaView {
onMousePressed: function(event){
// take action
if(isPlaying){
myMediaPlayer.pause();
}else{
myMediaPlayer.play();
}
// toggle play state
isPlaying = not isPlaying;
}
mediaPlayer: myMediaPlayer
}
function run(){
Stage {
title: "JavaFX Video Player"
scene: Scene {
width: 800 // CHANGE AS NEEDED
height: 600 // CHANGE AS NEEDED
fill: Color.BLACK
content: [myMediaView]
}
}
}
No comments:
Post a Comment