Skip to content

Instantly share code, notes, and snippets.

@bluepapa32
Created January 16, 2010 15:01
Show Gist options
  • Save bluepapa32/278850 to your computer and use it in GitHub Desktop.
Save bluepapa32/278850 to your computer and use it in GitHub Desktop.
How to use MediaPlayer
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.stage.Stage;
function run(args: String[]) {
var media = Media {
source: args[0]
};
var player = MediaPlayer {
media: media
autoPlay: true
};
var stage:Stage = Stage {
title: "Media Player";
visible: true;
scene: Scene {
width: 640
height: 320
fill: Color.BLACK
content: [
MediaView {
fitWidth: bind stage.scene.width
mediaPlayer: player
onMouseClicked: function(e) {
if (player.paused) {
player.play();
} else {
player.pause();
}
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment